summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/encoder.rs
AgeCommit message (Collapse)AuthorLines
2023-05-24Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, ↵Matthias Krüger-2/+2
r=compiler-errors Rename `traits_in_crate` query to `traits` > NOTE: Not named just `traits` due to a naming conflict. This can, in fact, be easily avoided.
2023-05-23Rename `traits_in_crate` query to `traits`Maybe Waffle-2/+2
2023-05-19Auto merge of #111641 - michaelwoerister:debugger-visualizer-fixes, r=cjgillotbors-4/+12
Fix dependency tracking for debugger visualizers This PR fixes dependency tracking for debugger visualizer files by changing the `debugger_visualizers` query to an `eval_always` query that scans the AST while it is still available. This way the set of visualizer files is already available when dep-info is emitted. Since the query is turned into an `eval_always` query, dependency tracking will now reliably detect changes to the visualizer script files themselves. TODO: - [x] perf.rlo - [x] Needs a bit more documentation in some places - [x] Needs regression test for the incr. comp. case Fixes https://github.com/rust-lang/rust/issues/111226 Fixes https://github.com/rust-lang/rust/issues/111227 Fixes https://github.com/rust-lang/rust/issues/111295 r? `@wesleywiser` cc `@gibbyfree`
2023-05-18Auto merge of #111345 - jyn514:cfg-release-caching, r=cjgillot,est31bors-1/+1
Only depend on CFG_VERSION in rustc_interface This avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`. cc https://github.com/rust-lang/rust/issues/76720 - this won't fix it, and I'm not suggesting we turn this on by default, but it will make it less painful for people who do have `omit-git-hash` on as a workaround.
2023-05-17Only depend on CFG_VERSION in rustc_interfacejyn-1/+1
this avoids having to rebuild the whole compiler on each commit when `omit-git-hash = false`.
2023-05-16Move DebuggerVisualizerFile types from rustc_span to rustc_middleMichael Woerister-3/+2
2023-05-16Rollup merge of #111533 - clubby789:drop-tracking-error, r=oli-obkMatthias Krüger-2/+5
Handle error body in generator layout Fixes #111468 I feel like making this query return `Option<GeneratorLayout>` might be better but had some issues with that approach
2023-05-16Fix dependency tracking for debugger visualizersMichael Woerister-1/+10
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn KÃ¥re Alsaker-1/+1
2023-05-13Handle error body when in generator layoutclubby789-2/+5
2023-05-13Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillotbors-2/+2
Introduce `DynSend` and `DynSync` auto trait for parallel compiler part of parallel-rustc #101566 This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency. r? `@cjgillot`
2023-05-13Rollup merge of #111494 - compiler-errors:variant-order, r=petrochenkovDylan DPC-1/+2
Encode `VariantIdx` so we can decode ADT variants in the right order As far as I can tell, we don't guarantee anything about the ordering of `DefId`s and module children... The code that motivated this PR (#111483) looks something like: ```rust #[derive(Protocol)] pub enum Data { #[protocol(discriminator(0x00))] Disconnect(Disconnect), EncryptionRequest, /* more variants... */ } ``` The specific macro ([`protocol`](https://github.com/dylanmckay/protocol)) doesn't really matter, but as far as I can tell (from calls to `build_reduced_graph`), the presence of that `#[protocol(..)]` helper attribute causes the def-id of the `Disconnect` enum variant to be collected *after* its siblings, and it shows up after the other variants in `module_children`. When we decode the variants for `Data` in a child crate (an example test, in this case), this means that the `Disconnect` variant is moved to the end of the variants list, and all of the other variants now have incorrect relative discriminant data, causing the ICE. This PR fixes this by sorting manually by variant index after they are decoded. I guess there are alternative ways of fixing this, such as not reusing `module_children_non_reexports` to encode the order-sensitive ADT variants, or to do some sorting in `rustc_resolve`... but none of those seemed particularly satisfying either. ~I really struggled to create a reproduction here -- it required at least 3 crates, one of which is a proc macro, and then some code to actually compute discriminants in the child crate... Needless to say, I failed to repro this in a test, but I can confirm that it fixes the regression in #111483.~ Test exists now. r? `@petrochenkov` but feel free to reassign. ~Again, sorry for no test, but I hope the explanation at least suggests why a fix like this is likely necessary.~ Feedback is welcome.
2023-05-13Encode VariantIdx so we can decode variants in the right orderMichael Goulet-1/+2
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-3/+4
2023-05-09Keep encoding attributes for closuresOli Scherer-1/+5
2023-05-06introduce `DynSend` and `DynSync` auto traitSparrowLii-2/+2
2023-05-05Rollup merge of #111173 - nnethercote:still-more-Encoder-cleanups, r=cjgillotYuki Okushi-4/+0
Still more encoder cleanups r? ``@cjgillot``
2023-05-04Rollup merge of #111039 - compiler-errors:foreign-span-rpitit, r=tmiaskoMatthias Krüger-1/+2
Encode def span for foreign return-position `impl Trait` in trait Fixes #111031, yet another def-span encoding issue :/ Includes a smaller repro than the issue, but I can confirm it ICEs: ``` query stack during panic: #0 [def_span] looking up span for `rpitit::Foo::bar::{opaque#0}` #1 [object_safety_violations] determining object safety of trait `rpitit::Foo` #2 [check_is_object_safe] checking if trait `rpitit::Foo` is object safe #3 [typeck] type-checking `main` #4 [used_trait_imports] finding used_trait_imports `main` #5 [analysis] running analysis passes on this crate ``` Luckily since this only affects nightly, this desn't need to be backported.
2023-05-04Remove unneeded encode/decode methods.Nicholas Nethercote-4/+0
In #110927 the encode/decode methods for `i8`, `char`, `bool`, and `str` were made inherent. This commit removes some unnecessary implementations of these methods that were missed in that PR.
2023-05-02resolve: One more attempt to simplify `module_children`Vadim Petrochenkov-7/+9
2023-04-30Encode def span for foreign RPITITsMichael Goulet-1/+2
2023-04-25Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, ↵Matthias Krüger-1/+1
r=compiler-errors Switch to `EarlyBinder` for `explicit_item_bounds` Part of the work to finish https://github.com/rust-lang/rust/issues/105779. This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`. r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 :smiley:)
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-0/+1
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-1/+0
Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
2023-04-22Encode lifetime param spans tooMichael Goulet-4/+2
2023-04-21rustc_metadata: Split `children` into multiple tablesVadim Petrochenkov-4/+8
instead of merging everything into a single bag. If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-20add EarlyBinder to output of explicit_item_bounds; replace ↵Kyle Matsuda-1/+1
bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query
2023-04-20Remove WithOptconstParam.Camille GILLOT-2/+1
2023-04-18Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillotbors-2/+2
Encode hashes as bytes, not varint In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash. Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true` Before: ``` ( 1) 373418203 (53.7%, 53.7%): 1 ( 2) 196240113 (28.2%, 81.9%): 3 ( 3) 108157958 (15.6%, 97.5%): 2 ( 4) 17213120 ( 2.5%, 99.9%): 4 ( 5) 223614 ( 0.0%,100.0%): 9 ( 6) 216262 ( 0.0%,100.0%): 10 ( 7) 15447 ( 0.0%,100.0%): 5 ( 8) 3633 ( 0.0%,100.0%): 19 ( 9) 3030 ( 0.0%,100.0%): 8 ( 10) 1167 ( 0.0%,100.0%): 18 ( 11) 1032 ( 0.0%,100.0%): 7 ( 12) 1003 ( 0.0%,100.0%): 6 ( 13) 10 ( 0.0%,100.0%): 16 ( 14) 10 ( 0.0%,100.0%): 17 ( 15) 5 ( 0.0%,100.0%): 12 ( 16) 4 ( 0.0%,100.0%): 14 ``` After: ``` ( 1) 372939136 (53.7%, 53.7%): 1 ( 2) 196240140 (28.3%, 82.0%): 3 ( 3) 108014969 (15.6%, 97.5%): 2 ( 4) 17192375 ( 2.5%,100.0%): 4 ( 5) 435 ( 0.0%,100.0%): 5 ( 6) 83 ( 0.0%,100.0%): 18 ( 7) 79 ( 0.0%,100.0%): 10 ( 8) 50 ( 0.0%,100.0%): 9 ( 9) 6 ( 0.0%,100.0%): 19 ``` The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-2/+2
2023-04-18rustc_metadata: Remove `Span` from `ModChild`Vadim Petrochenkov-3/+3
It can be decoded on demand from regular `def_span` tables. Partially mitigates perf regressions from #109500.
2023-04-18Rollup merge of #110461 - WaffleLapkin:expect_, r=NilstriebMatthias Krüger-2/+2
Use `Item::expect_*` and `ImplItem::expect_*` more r? ``@Nilstrieb``
2023-04-17Use `Item::expect_*` and `ImplItem::expect_*` moreMaybe Waffle-2/+2
2023-04-17Encode def span for ConstParamMichael Goulet-2/+2
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-1/+0
2023-04-12resolve: Pre-compute non-reexport module childrenVadim Petrochenkov-47/+15
Instead of repeating the same logic by walking HIR during metadata encoding. The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list. They can be encoded separately if this need ever arises. `module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-11Split implied and super predicate queriesMichael Goulet-1/+5
2023-04-10rustc_metadata: Filter encoded data more aggressively using `DefKind`Vadim Petrochenkov-10/+127
2023-04-10rustc_metadata: Cleanup `fn encode_info_for_item`Vadim Petrochenkov-62/+33
2023-04-08rustc_middle: Remove `Option` from `module_reexports` queryVadim Petrochenkov-2/+2
2023-04-06Rollup merge of #109984 - scottmcm:less-float, r=NilstriebMatthias Krüger-2/+0
Remove f32 & f64 from MemDecoder/MemEncoder r? ```@Nilstrieb``` since they said (maybe joked) on discord that it's a bug if the compiler uses f32 anywhere 🙃
2023-04-06Remove f32 & f64 from MemDecoder/MemEncoderScott McMurray-2/+0
2023-04-04Remove a lock in favor of an AppendOnlyVecOli Scherer-2/+1
2023-03-23Don't split up TreatProjections and TreatParams anymoreMichael Goulet-2/+1
2023-03-22Rollup merge of #109358 - petrochenkov:nosess, r=cjgillotMatthias Krüger-12/+10
rustc: Remove unused `Session` argument from some attribute functions (One auxiliary test file containing one of these functions was unused, so I removed it instead of updating.)
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-12/+10
2023-03-21RPITITs are DefKind::Opaque with new lowering strategyMichael Goulet-1/+12
2023-03-21Always encode RPITITsSantiago Pastorino-1/+7
2023-03-21LocalCrate keyMichael Goulet-2/+3
2023-03-21Use local key in providersMichael Goulet-8/+4