Convert type names which match their containing module to "t"
commit0c3401198cb808cab244bf4a1107c42187893fce
authorJake Bailey <jakebailey@fb.com>
Fri, 5 Aug 2022 17:14:56 +0000 (5 10:14 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 5 Aug 2022 17:14:56 +0000 (5 10:14 -0700)
treecd0c128bd2acf607ba1195f7f81a5c7fc59826ec
parent733b39b47409e5e73fd6fe6d16c8d8bf71b775ae
Convert type names which match their containing module to "t"

Summary:
In OCaml we often define types with the name `t` when the type name would be the same as the module name (e.g., `Path.t`, `RelativePath.t`, `Pos.t`, `SSet.t`, `SMap.t`). In hh_oxidize, we used the module name to generate the Rust type name (e.g., `relative_path::RelativePath`, `pos::Pos`, `s_set::SSet`).

Perform the same conversion in reverse by keeping track of the current module name in the rewriting phase, and rewriting type names to `t` if they match the current module name. Also rewrite qualified names like `pos::Pos` to `Pos.t`.

Reviewed By: edwinsmith

Differential Revision: D38442266

fbshipit-source-id: 6ac8b1c1f943d2aad0f2ca5016c3769c4ab4affa
hphp/hack/src/rust_to_ocaml/src/convert.rs
hphp/hack/src/rust_to_ocaml/src/ir.rs
hphp/hack/src/rust_to_ocaml/src/ir/display.rs
hphp/hack/src/rust_to_ocaml/src/rewrite_types.rs
hphp/hack/src/rust_to_ocaml/src/rust_to_ocaml.rs
hphp/hack/test/rust_to_ocaml/bool_alias.rs [moved from hphp/hack/test/rust_to_ocaml/bool.rs with 100% similarity]
hphp/hack/test/rust_to_ocaml/bool_alias.rs.exp [moved from hphp/hack/test/rust_to_ocaml/bool.rs.exp with 100% similarity]
hphp/hack/test/rust_to_ocaml/option.rs
hphp/hack/test/rust_to_ocaml/option.rs.exp
hphp/hack/test/rust_to_ocaml/type_name_matches_module_name.rs [new file with mode: 0644]
hphp/hack/test/rust_to_ocaml/type_name_matches_module_name.rs.exp [new file with mode: 0644]