1. 28 1月, 2022 3 次提交
    • A
      Option to log non-singleton disjunctions in subtyping · 0e50a67a
      Andrew Kennedy 提交于
      Summary: To aid investigation of arbitrary resolution of disjunctions, introduce logging of non-singleton disjunctions created during subtyping.
      
      Differential Revision: D33817726
      
      fbshipit-source-id: c8a66e3f8418e23ab49afb2500e017201f886db8
      0e50a67a
    • E
      Remove prefixes from field names · 105494c8
      Edwin Smith 提交于
      Summary: This is the way
      
      Differential Revision: D33793092
      
      fbshipit-source-id: 1e88436661dd3998cc4dd1aa632433da88388bf7
      105494c8
    • M
      Move side effect out of `typing_well_formedness` · 6a95b672
      Michael Thomas 提交于
      Summary:
      As part of the error refactor we want our core typing functions to return a list of errors rather than adding them as a side-effect
      
      This diff changes the `typing_well_formedness` API to return a list of `Typing_error.t` rather than adding them to the global table in `errors.ml`.
      
      Reviewed By: CatherineGasnier
      
      Differential Revision: D33683912
      
      fbshipit-source-id: 9e6ff5f9c7f092fea06f427f0f83dd8db91cafff
      6a95b672
  2. 27 1月, 2022 15 次提交
    • H
      Convert comment into docblock · 9d48b774
      Henri Verroken 提交于
      Summary:
      These useful comments would even be more useful if they're prefixed with 3 slashes: then they'll be included in the docblocks
      
      Facbebook;
      
      They should show up in: https://www.internalfb.com/intern/rustdoc/hphp/hack/src/rupro:hackrs/hackrs/index.html
      
      Reviewed By: enetsee
      
      Differential Revision: D33817225
      
      fbshipit-source-id: b1beb60bd90f9938d6de4f40255452fdbfa99647
      9d48b774
    • A
      rust: autocargo run · 9ca550aa
      Alex Hornby 提交于
      Summary: Run autocargo before doing any other changes, likely some or all of this will rebase away
      
      Reviewed By: c-ryan747
      
      Differential Revision: D33790131
      
      fbshipit-source-id: fe6c761a09b300e482b5eb9c9c1465716d35dded
      9ca550aa
    • E
      Remove several unnecessary allow(needless_lifetimes) attributes. · a5d92b50
      Edwin Smith 提交于
      Summary:
      I'm expecting phabricator's clippy to yell if any of these were needed,
      and it didn't. A local run of clippy also didn't complain.  I suspect some of
      these might have existed before we adopted Rust edition 2018 idioms,
      and became unnecessary during that cleanup.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33733027
      
      fbshipit-source-id: 0fcbce235c5e7ad36d826e490ba1cbae16368cfc
      a5d92b50
    • J
      Allow HH\FIXME\UNSAFE_CAST to be automatically polymorphic on readonly · 06437a7c
      James Wu 提交于
      Summary: UNSAFE_CAST should treat its output as readonly implicitly if the input is readonly
      
      Reviewed By: oulgen
      
      Differential Revision: D33735406
      
      fbshipit-source-id: 6f84994d2b132b0a26068630b43c496de819e99e
      06437a7c
    • M
      Replace use of facts parser with decl parser in OCaml FFI · 926c7871
      Millie Chen 提交于
      Summary:
      Now that the new facts has been [rolled out to 100%](https://www.internalfb.com/diff/D33688656), it might be a good time to start preparing for replacement of the old facts parser.
      
      To that end, this diff
      - Renames `extract_facts_as_json_ffi0` to `extract_facts_as_json_ffi`. This is the FFI accessed by the [OCaml code](https://www.internalfb.com/code/fbsource/[0bc043f095f3ecc418bc16c5c71ba43de9c2d938]/fbcode/hphp/hack/src/facts/facts_parser.ml?lines=38)
      - Within that function, replaces `facts_parser::from_text` with `direct_decl_parser::parse_decls_without_reference_text` + `facts::Facts::facts_of_decls`
      - Removes 2 unused FFIs, `extract_facts_ffi0` and `facts_to_json`
      
      In later diffs we'll refactor out further dependencies on the facts parser and eventually delete it.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33721383
      
      fbshipit-source-id: bbf7845f00590dad24fd4aa7f9fec90fe01d2d15
      926c7871
    • M
      Move helper from facts_parser.rs to facts.rs · 8031c66e
      Millie Chen 提交于
      Summary: With the new decl parser based facts [rolled out to 100%](https://www.internalfb.com/diff/D33688656), we're hoping to eventually remove `facts_parser.rs`. This diff removes a dependency on that file by copying over a helper function.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33721403
      
      fbshipit-source-id: 727d688ae155e7deba1611d3989436e3e771f6f2
      8031c66e
    • W
      Add hover docs for the abstract keyword · 457bf580
      Wilfred Hughes 提交于
      Summary: `abstract final` classes often confuse errors. Add hover docs to `abstract` to clarify that `abstract` classes cannot be instantiated, so `abstract final` makes sense for utility classes.
      
      Differential Revision: D33724813
      
      fbshipit-source-id: 7b5a4fe872f1dac979a48b3955d020fb52018013
      457bf580
    • H
      Output timing info as well · 6c4a4c44
      Hasnain Lakhani 提交于
      Summary:
      This makes it easier to do performance measurements.
      
      Note that we won't capture the time taken to dump the actual trace output - I
      wanted to still dump the metadata at the top of the file.
      
      I also changed the filename scheme to include the request start time so
      multiple requests to the same endpoint will now produce multiple files.
      
      Reviewed By: dkgi
      
      Differential Revision: D33779681
      
      fbshipit-source-id: 93e5e8ba0c2cf1dbea70db9fa6f899a3f4b7b8d2
      6c4a4c44
    • W
      Support hover and go-to-definition on type parameters · f4d78ec3
      Wilfred Hughes 提交于
      Summary: Allow users to hover over type variables to see information about them, and go to their definitions.
      
      Differential Revision: D33722495
      
      fbshipit-source-id: 4c15a9fd8209aa95a14dd12d870c279c09a32e01
      f4d78ec3
    • T
      Remove array_cast option from tco_migration_flags list · 186b4d9a
      Thomas Jiang 提交于
      Summary: I don't believe the `array_cast` option in the `tco_migration_flags` list is being used to control anything in Hack anymore. This diff simply removes it from the list of options. I am leaving the empty list in case people want to use it in the future. I'll put up a diff if people want to commandeer to remove the `tco_migration_flags` list entirely.
      
      Reviewed By: jamesjwu
      
      Differential Revision: D33673571
      
      fbshipit-source-id: 4c1600024b5cc25caf96ecf931ab7d30bd47c3a9
      186b4d9a
    • J
      Cut over to the Facts Decl parser and deprecate the legacy Facts parser · cd9e5f48
      Jeff Hemphill 提交于
      Summary: Facts now uses a parser based on Hack's decl parser. We've been using this new decl parser everywhere with no issues or differences in behavior. I'd like to start removing the old code.
      
      Reviewed By: rodmk
      
      Differential Revision: D33781412
      
      fbshipit-source-id: fd226d0f7d8f27110584f8270a60e691d8bca84a
      cd9e5f48
    • C
      clean-up code checking override keyword · 5c9290f9
      Catherine Gasnier 提交于
      Summary:
      Multiple fixes here:
      - move logic into helper function check_override_keyword
      - rename the `override` flag to `superfluous_override` and document it in Typing_defs_flags
      - rename error Should_be_override to Should_not_be_override because...
      - eliminate one Pos_or_decl downcast by fetching method position from AST instead of decl store.
      
      Reviewed By: andrewjkennedy
      
      Differential Revision: D33766932
      
      fbshipit-source-id: 0df414af42290325d3b9b5286c64974c306f442e
      5c9290f9
    • J
      Use Arc instead of Rc in hcons · 37dc9fc9
      Jake Bailey (Hacklang) 提交于
      Summary: Switch to Arc so that values can be shared (and sent) between threads.
      
      Differential Revision: D33782216
      
      fbshipit-source-id: f9866f7f8df9969a612cf78221416898563bade2
      37dc9fc9
    • M
      Make always interp work for prologues · cf66b1e5
      Michael O'Farrell 提交于
      Summary: Prologues were emitted even for functions marked always interp.  This is probably not what was intended.  Move the check to shouldTranslateNoSizeLimit, so it gets used by both prologues and bodies.
      
      Reviewed By: ricklavoie
      
      Differential Revision: D33714769
      
      fbshipit-source-id: 3440cc2b90dd6d8459bd77491ff9aadb526a36f4
      cf66b1e5
    • E
      Tweak argv.php expected path · b2c4a65b
      Edwin Smith 提交于
      Summary:
      The expected path in this test depends on buck v1's buck-out layout.
      Generalize it to accept buck v2's layout.
      
      Reviewed By: oulgen
      
      Differential Revision: D33727696
      
      fbshipit-source-id: 78a4d031aab85ef88b035da25bd204265a269f80
      b2c4a65b
  3. 26 1月, 2022 22 次提交
    • E
      Fix some clippy lint. · 7c65f54e
      Edwin Smith 提交于
      Summary:
      For some reason, the other day, I decided to run clippy on the hack Rust codebase
      to see what turned up. This is the result of a first pass of easy fixes.
      
      Differential Revision: D33740377
      
      fbshipit-source-id: 3c2462f1578abfc69fd7f44df8a4a4abbceec6e7
      7c65f54e
    • C
      Daily `common/rust/cargo_from_buck/bin/autocargo` · 4f1413ed
      CodemodService Bot 提交于
      Reviewed By: yancouto
      
      Differential Revision: D33785843
      
      fbshipit-source-id: 2a5375af817936ee72bd44e5f03c632adb0ec01b
      4f1413ed
    • C
      setup_env_for_class_def_check helper · 026f82dd
      Catherine Gasnier 提交于
      Summary:
      This diff is a first of a series of refactoring in typing_toplevel.
      My high-level goal is to make it easier to add landmarks annotation in view of profiling everything.
      
      Reviewed By: andrewjkennedy
      
      Differential Revision: D33766931
      
      fbshipit-source-id: 30f0b55b815361adf875357d8ce990433eff6f49
      026f82dd
    • M
      Create a `Variance` type · 6c1edccc
      Michael Thomas 提交于
      Summary: In the OCaml codebase, variance appears all over the place, both implictly (e.g. in the inference environment) and explicitly. We should prefer to have a single implementation and start defining functions over that type in terms of standard traits
      
      Differential Revision: D33743419
      
      fbshipit-source-id: 32884bc8546db27544d6ab85279955f723039bb0
      6c1edccc
    • K
      clean up naming style · f3745464
      Katy Voor 提交于
      Summary:
      - Just a couple fastmods.
      - Naming style we initially made a couple months ago feels a bit redundant now as we add more ffi bridges.
      `rust_compile_ffi_bridge` -> `compiler_ffi` for bytecode entrypoint
      `rust_parser_ffi_bridge` -> `parser_ffi`
      
      Very open to other suggestions. Just seems weird to have "rust" when its rust code and "bridge" when all ffis are bridges.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33722397
      
      fbshipit-source-id: 01fde351820ae5bae8d0bf713de0db5ca2450d08
      f3745464
    • N
      Add ReleaseShallow and DecReleaseCheck IR-ops · b1c4a5a5
      Niharika Devanathan 提交于
      Summary:
      In addition to freeing memory, the Release method on array like types also inspects the elements so as to decrement the refcount for each of them. However, for arrays that contain non refcounted types/values, iterating through the elements is redundant.
      
      This diff introduces a profile based optimization which replaces a DecRef which is likely to invoke the destructor of an array like with a pair of two new IR-ops DecReleaseCheck (which checks decrements the refcount and checks if the object should be released) and ReleaseShallow (frees memory associated with the object).
      
      This diff only applies this optimization to a vector containing elements that aren't refcounted. Future changes will expand the scope of this optimization.
      
      Differential Revision: D32731946
      
      fbshipit-source-id: ea6c08e42a331ca2177d4899e69c2d19ad33ad28
      b1c4a5a5
    • N
      Add a counter for array of uncounted destruction to decref profile · b21253da
      Niharika Devanathan 提交于
      Summary:
      Add a counter to decref profile that measures the number of times we destroy an array of uncounted elements.
      This counter will be replaced by the more generic nested DecRef profile once the profile is moved to shared
      memory (D33174281).
      
      Differential Revision: D33664082
      
      fbshipit-source-id: d310a07045e6bb9f2351b9d62776ee449199f33f
      b21253da
    • W
      Factor the hint pretty-printer out of serverExtractStandalone · 78c3b9d7
      Wilfred Hughes 提交于
      Summary: Used in the next diff.
      
      Differential Revision: D33720687
      
      fbshipit-source-id: 3086500e0d28a1bbc89dfeaa325900b42deb15f4
      78c3b9d7
    • J
      Make DB transactions implicit · d3fca6b8
      Jeff Hemphill 提交于
      Summary:
      Previously, `AutoloadDB` exposed a `SQLiteTxn` object, representing an outstanding transaction, to callers. I'm planning on creating a MySQL implementation of `AutoloadDB`, which... won't be using `SQLiteTxn` objects. Based on the way the C++ MySQL client (Squangle) is written, based on the fact that, with a networked DB, transactions must be begun and committed asynchronously, and based on the fact that `AutoloadDB` doesn't actually *use* fine-grained transactions, I think it makes more sense to roll transactions into the `AutoloadDB` connection itself.
      
      Now, whenever you get an AutoloadDB connection, you are always querying the same snapshot of the DB, for the lifetime of the connection.
      
      Unfortunately, "the lifetime of the connection" is currently the lifetime of the thread, since `AutoloadDB` is implemented as a thread local. This caused `SymbolMapTest` to break, since most tests update the DB in a different thread than where we query it. I've fixed the test by adding `getDB().commit()` to `waitForDBUpdate()`, which refreshes the transaction.
      
      Reviewed By: bdchik
      
      Differential Revision: D33696872
      
      fbshipit-source-id: d6af00c5d46eacf32cb1212835835dbd2da61903
      d3fca6b8
    • J
      Extract hcons into separate crate · 81b26f26
      Jake Bailey (Hacklang) 提交于
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33773246
      
      fbshipit-source-id: c2dea8814c2f2db354662288c354e4b8539b08df
      81b26f26
    • J
      Remove AstProvider's cache · 8e8f26c4
      Jake Bailey (Hacklang) 提交于
      Summary: We've been working on removing the AstProvider cache in hh_server, so I think it's best not to introduce one in rupro. The cache does not currently prevent redundant work: decls are parsed using the decl-parser (not the AST-parser), so each file is only parsed once immediately before typechecking.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33773120
      
      fbshipit-source-id: 74f933a73f2a4a8fe7505b184d59fd125bd324cd
      8e8f26c4
    • J
      Remove use of AstProvider in TypingCheckJob · 85cf9a74
      Jake Bailey (Hacklang) 提交于
      Summary: I think it's strange that the typechecker accepts a FileInfo and requests per-decl ASTs from an AST cache. It seems like it would be more straightforward to accept a full-file AST and iterate over it. If we do things that way, and use the DefsIterator introduced in the previous diff, we can entirely remove the fileinfo and nast modules in rupro.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33773063
      
      fbshipit-source-id: 8de205c553c7516438f42a40da49b3ed8098bebd
      85cf9a74
    • J
      Add DefsIterator for aast::Program · 5af869ac
      Jake Bailey (Hacklang) 提交于
      Summary: Add an iterator over the Defs in a Program for convenience.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33772039
      
      fbshipit-source-id: 522c236d7561583525982b8441864e57ae1e860a
      5af869ac
    • J
      Make aast::Program a struct rather than an alias · 837fcf45
      Jake Bailey (Hacklang) 提交于
      Summary: I want to give the aast::Program type some methods, but it's currently an alias for Vec<Def>, so that's not allowed. Have hh_oxidize convert it to a newtype, so that we can define methods for it.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33721950
      
      fbshipit-source-id: dcdf33504adbf157e3e4d4cee093d4851226e209
      837fcf45
    • J
      Add helper Conser<[u8]>::mk_bstr · 756cf6f2
      Jake Bailey (Hacklang) 提交于
      Summary: Add a helper which returns Hc<BStr>. Might be useful if we need byte strings (maybe for shape field names, which can be string literals?).
      
      Differential Revision: D33714988
      
      fbshipit-source-id: fff4ffd7fcf014794056e792c9ba6acf694d9e16
      756cf6f2
    • J
      Factor out common logic in mk and mk_from_ref · 57c6f6cc
      Jake Bailey (Hacklang) 提交于
      Summary: as suggested by aorenste on D33698454
      
      Differential Revision: D33712523
      
      fbshipit-source-id: 5fc71a19279f7c1caa90f00bc227abad3579c405
      57c6f6cc
    • J
      Support hash-consing of byte strings · cf227a40
      Jake Bailey (Hacklang) 提交于
      Summary: Extend `mk_str` (added in the previous diff) so that it can support arbitrary types of slices. Add an `mk_str` helper so that a `Conser<[u8]>` can conveniently produce `Hc<str>` values (which will be shared with hash-consed byte strings containing the same contents).
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33698452
      
      fbshipit-source-id: 2d00631e67a3254610cb8b1351af672e4faa8d43
      cf227a40
    • J
      Change representation of Symbol from Hc<Box<str>> to Hc<str> · efbbc59b
      Jake Bailey (Hacklang) 提交于
      Summary: The previous two diffs laid the foundation for storing dynamically sized types in an Hc, which this diff does (by adding the `?Sized` bound). This allows us to construct `Hc<str>` instead of `Hc<Box<str>>`, getting rid of an unnecessary indirection.
      
      Differential Revision: D33698454
      
      fbshipit-source-id: 0865c0f9b041a68a7bb6b7bddf66a378f985d66c
      efbbc59b
    • J
      Store weak pointers by hash · e5c35478
      Jake Bailey (Hacklang) 提交于
      Summary:
      Currently, a Conser stores a map from T -> Weak<T>. This means that there's one copy of T stored in the map as a key, and a second, ref-counted copy stored on the heap (which will be destroyed if its strong refcount drops to 0, and freed on the next Conser::gc invocation). Ideally, we should just store a single copy on the heap! Having an owned version inside the map also makes it impossible for us to reclaim some unused memory: if we hashcons a value containing other hashconsed values, those other values will be strongly referenced by the value we store as the map's key.
      
      If we key the table by value hashes instead, we avoid these problems at the cost of needing to handle collisions. I've punted on collision handling in this diff (u64 is a pretty big space). Additionally, since we no longer need to store an owned copy of the value in the map, we're able to hashcons unsized types like `str`. The next diff removes an indirection in `Symbol` by switching its representation from `Hc<Box<str>>` to `Hc<str>` now that this is possible.
      
      Reviewed By: edwinsmith
      
      Differential Revision: D33698451
      
      fbshipit-source-id: 4e74f97ddd64af32fb5a3ec006c40d94ebfc1f36
      e5c35478
    • J
      Remove tag in Hc · 745a1884
      Jake Bailey (Hacklang) 提交于
      Summary:
      Each hash-consed value is associated with a unique tag, so that we can test for equality between values just by comparing the tags. This strategy is described in [this paper](https://www.lri.fr/~filliatr/ftp/publis/hash-consing2.pdf) and implemented in [this Rust library](https://docs.rs/hashconsing/1.3.0/hashconsing/index.html), which may have inspired our own hcons implementation. The paper notes that a tag must be used rather than pointer values because of the garbage collector. While the GC shouldn't be a problem for testing equality (there will still be only one copy of each hash-consed value, and all pointers to it will be equal to one another), the paper describes building balanced-tree datastructures using tags as the key. Using pointers as keys for those data structures wouldn't be suitable, since a hashconsed value may be moved after it is inserted into the container.
      
      This isn't a concern for us: we don't currently have data structures for hash-consed terms which key off the tag or pointer-value, and even if we did, there is no GC to move our ref-counted values. I think we could just use pointer-values rather than tags. This should help performance: when performing an equality test, there's no need to dereference the pointer to get the tag.
      
      Additionally, since there's no longer a need for an HcImpl struct to store the tag, we can more easily hash-cons unsized types like `str`. A later diff in the stack switches the representation of `Symbol` from `Hc<Box<str>>` to `Hc<str>` now that this is possible.
      
      Differential Revision: D33698453
      
      fbshipit-source-id: 7817151c45489cb19bbb78b8d32972ae5245a65f
      745a1884
    • J
      Use Hc::clone explicitly · b8b53cec
      Jake Bailey (Hacklang) 提交于
      Summary: Maybe it's valuable to make explicit that we're only bumping a refcount here rather than deeply cloning a data structure (just as one would do with `Rc::clone`, as in D33671668).
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33698450
      
      fbshipit-source-id: 98a4c1088df8aa1ff5bfda3de126a0ef5c06d95b
      b8b53cec
    • J
      Make Symbol a type alias for Hc<Box<str>> · 20ff1590
      Jake Bailey (Hacklang) 提交于
      Summary: Instead of making Symbol an opaque type, just make it an alias. Then, if we provide convenient impls for `Hc<Box<str>>` (like `AsRef<Path>` or `PartialEq<String>`) they can be used directly without having to write forwarding impls for the `Symbol` type.
      
      Reviewed By: shayne-fletcher
      
      Differential Revision: D33698455
      
      fbshipit-source-id: caa1367c95ecde17e42d99abe48b7202ab8c6e94
      20ff1590