summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder
AgeCommit message (Collapse)AuthorLines
2022-02-18rustdoc: Collect traits in scope for lang itemsVadim Petrochenkov-1/+6
2022-02-15Overhaul `Const`.Nicholas Nethercote-1/+1
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-13/+8
2022-02-04rustdoc: Collect traits in scope for foreign inherent implsVadim Petrochenkov-0/+10
2022-01-25rustdoc: Pre-calculate traits that are in scope for doc linksVadim Petrochenkov-1/+1
This eliminates one more late use of resolver
2022-01-16rustc_metadata: Switch all decoder methods from vectors to iteratorsVadim Petrochenkov-10/+23
Also remove unnecessary `is_proc_macro_crate` checks from decoder
2022-01-12Auto merge of #92169 - In-line:no-cache-selector-lrc, r=Mark-Simulacrumbors-1/+1
Remove ArenaCacheSelector for visible_parent_map query ( + LRC)
2022-01-09Auto merge of #92690 - matthiaskrgr:rollup-rw0oz05, r=matthiaskrgrbors-2/+12
Rollup of 8 pull requests Successful merges: - #92055 (Add release notes for 1.58) - #92490 (Move crate drop-down to search results page) - #92510 (Don't resolve blocks in foreign functions) - #92573 (expand: Refactor InvocationCollector visitor for better code reuse) - #92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes) - #92657 (Implemented const casts of raw pointers) - #92671 (Make `Atomic*::from_mut` return `&mut Atomic*`) - #92673 (Remove useless collapse toggle on "all items" page) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-09Rollup merge of #92608 - petrochenkov:doctrscope3, r=CraftSpiderMatthias Krüger-2/+12
rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes The refactoring parts of https://github.com/rust-lang/rust/pull/88679, shouldn't cause any slowdowns. r? `@jyn514`
2022-01-09rustc_middle: Rename `Export` to `ModChild` and add some commentsVadim Petrochenkov-3/+3
Also rename `module_exports`/`export_map` to `module_reexports`/`reexport_map` for clarity.
2022-01-09rustc_metadata: Rename `item_children(_untracked)` to ↵Vadim Petrochenkov-5/+5
`module_children(_untracked)` And `each_child_of_item` to `for_each_module_child`
2022-01-09rustc_metadata: Optimize and document module children decodingVadim Petrochenkov-9/+14
2022-01-07Deserialization less in associated_item_def_idsMatthew Jasper-6/+1
2022-01-07rustdoc: Introduce a resolver cache for sharing data between early doc link ↵Vadim Petrochenkov-2/+12
resolution and later passes
2022-01-06rustc_metadata: Split `fn get_implementations_for_trait` into two functionsVadim Petrochenkov-7/+2
2022-01-06rustc_metadata: Make `opt_item_ident` in decoder faster and stricterVadim Petrochenkov-3/+1
By avoiding formatting and allocations in the no-ident case, and by making the span mandatory if the ident exists. Use the optimized `opt_item_ident` to cleanup `fn each_child_of_item`
2022-01-06rustc_metadata: Make attribute decoding slightly faster and stricterVadim Petrochenkov-4/+2
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-01rustc_metadata: Use a query for collecting all traits in encoderVadim Petrochenkov-25/+1
2021-12-31Auto merge of #92175 - Aaron1011:fix-missing-source-file, r=cjgillotbors-0/+4
Import `SourceFile`s from crate before decoding foreign `Span` Fixes #92163 Fixes #92014 When writing to the incremental cache, we encode all `Span`s we encounter, regardless of whether or not their `SourceFile` comes from the local crate, or from a foreign crate. When we decode a `Span`, we use the `StableSourceFileId` we encoded to locate the matching `SourceFile` in the current session. If this id corresponds to a `SourceFile` from another crate, then we need to have already imported that `SourceFile` into our current session. This usually happens automatically during resolution / macro expansion, when we try to resolve definitions from other crates. In certain cases, however, we may try to load a `Span` from a transitive dependency without having ever imported the `SourceFile`s from that crate, leading to an ICE. This PR fixes the issue by enconding the `SourceFile`'s `CrateNum` when we encode a `Span`. During decoding, we call `imported_source_files()` when we encounter a foreign `CrateNum`, which ensure that all `SourceFile`s from that crate are imported into the current session.
2021-12-28rustc_metadata: Encode list of all crate's traits into metadataVadim Petrochenkov-0/+26
2021-12-28Auto merge of #92159 - petrochenkov:decoditer, r=cjgillotbors-5/+3
rustc_metadata: Switch crate data iteration from a callback to iterator The iteration looks more conventional this way, and some allocations are avoided.
2021-12-27Rollup merge of #92161 - petrochenkov:misclean, r=cjgillotMatthias Krüger-6/+2
resolve: Minor miscellaneous cleanups from #89059 `@bors` rollup=always
2021-12-23Import `SourceFile`s from crate before decoding foreign `Span`Aaron Hill-0/+4
Fixes #92163 Fixes #92014 When writing to the incremental cache, we encode all `Span`s we encounter, regardless of whether or not their `SourceFile` comes from the local crate, or from a foreign crate. When we decode a `Span`, we use the `StableSourceFileId` we encoded to locate the matching `SourceFile` in the current session. If this id corresponds to a `SourceFile` from another crate, then we need to have already imported that `SourceFile` into our current session. This usually happens automatically during resolution / macro expansion, when we try to resolve definitions from other crates. In certain cases, however, we may try to load a `Span` from a transitive dependency without having ever imported the `SourceFile`s from that crate, leading to an ICE. This PR fixes the issue by calling `imported_source_files()` when we encounter a `SourceFile` with a foreign `CrateNum`. This ensures that all `SourceFile`s from that crate are imported into the current session.
2021-12-22rustc_metadata: Merge `get_ctor_def_id` and `get_ctor_kind`Vadim Petrochenkov-5/+3
Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag
2021-12-21Remove ArenaCacheSelector for visible_parent_map query.Alik Aslanyan-1/+1
Optimize visible_parent_map to use LRC to prevent unnecessary cloning
2021-12-21resolve: Minor miscellaneous cleanups from #89059Vadim Petrochenkov-6/+2
2021-12-21rustc_metadata: Switch crate data iteration from a callback to iteratorVadim Petrochenkov-5/+3
The iteration looks more conventional this way, and some allocations are avoided.
2021-12-20Prefer visibility paths where items are not named `_`Michael Goulet-4/+19
2021-12-14Remove `in_band_lifetimes` from `rustc_metadata`Sylvan Bowdler-1/+1
2021-11-09Add `ty::Visibility::is_public()`inquisitivecrystal-1/+1
2021-10-25Avoid a branch on key being local for queries that use the same local and ↵bjorn3-3/+3
extern providers
2021-10-17Auto merge of #89514 - davidtwco:polymorphize-shims-and-predicates, r=lcnrbors-0/+6
polymorphization: shims and predicates Supersedes #75737 and #75414. This pull request includes up some changes to polymorphization which hadn't landed previously and gets stage2 bootstrapping and the test suite passing when polymorphization is enabled. There are still issues with `type_id` and polymorphization to investigate but this should get polymorphization in a reasonable state to work on. - #75737 and #75414 both worked but were blocked on having the rest of the test suite pass (with polymorphization enabled) with and without the PRs. It makes more sense to just land these so that the changes are in. - #75737's changes remove the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. This won't have much of an effect until polymorphization's analysis is more advanced, but it doesn't hurt. - #75414's changes remove all logic which marks parameters as used based on their presence in predicates - given #75675, this will enable more polymorphization and avoid the symbol clashes that predicate logic previously sidestepped. - Polymorphization now explicitly checks (and skips) foreign items, this is necessary for stage2 bootstrapping to work when polymorphization is enabled. - The conditional determining the emission of a note adding context to a post-monomorphization error has been modified. Polymorphization results in `optimized_mir` running for shims during collection where that wouldn't happen previously, some errors are emitted during `optimized_mir` and these were considered post-monomorphization errors with the existing logic (more errors and shims have a `DefId` coming from the std crate, not the local crate), adding a note that resulted in tests failing. It isn't particularly feasible to change where polymorphization runs or prevent it from using `optimized_mir`, so it seemed more reasonable to not change the conditional. - `characteristic_def_id_of_type` was being invoked during partitioning for self types of impl blocks which had projections that depended on the value of unused generic parameters of a function - this caused a ICE in a debuginfo test. If partitioning is enabled and the instance needs substitution then this is skipped. That test still fails for me locally, but not with an ICE, but it fails in a fresh checkout too, so 🤷‍♂️. r? `@lcnr`
2021-10-06Access Session while decoding expn_id.Camille GILLOT-2/+8
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-2/+1
2021-10-01polymorphize: polymorphize shimsDavid Wood-0/+6
This commit removes the restriction of `InstanceDef::Item` on polymorphization, so that shims can now be polymorphized. Signed-off-by: David Wood <david.wood@huawei.com>
2021-09-30Move encode_metadata out of CrateStore.Camille GILLOT-6/+1
2021-09-21`crates` is already deterministiclcnr-34/+20
2021-09-14Make DefPathHash->DefId panic for if the mapping fails.Michael Woerister-4/+3
We only use this mapping for cases where we know that it must succeed. Letting it panic otherwise makes it harder to use the API in unsupported ways.
2021-09-14Store DefPathHash->DefIndex map in on-disk-hash-table format in crate metadata.Michael Woerister-8/+8
This encoding allows for random access without an expensive upfront decoding state which in turn allows simplifying the DefPathIndex lookup logic without regressing performance.
2021-09-12Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddybbors-0/+1
Add -Z panic-in-drop={unwind,abort} command-line option This PR changes `Drop` to abort if an unwinding panic attempts to escape it, making the process abort instead. This has several benefits: - The current behavior when unwinding out of `Drop` is very unintuitive and easy to miss: unwinding continues, but the remaining drops in scope are simply leaked. - A lot of unsafe code doesn't expect drops to unwind, which can lead to unsoundness: - https://github.com/servo/rust-smallvec/issues/14 - https://github.com/bluss/arrayvec/issues/3 - There is a code size and compilation time cost to this: LLVM needs to generate extra landing pads out of all calls in a drop implementation. This can compound when functions are inlined since unwinding will then continue on to process drops in the callee, which can itself unwind, etc. - Initial measurements show a 3% size reduction and up to 10% compilation time reduction on some crates (`syn`). One thing to note about `-Z panic-in-drop=abort` is that *all* crates must be built with this option for it to be sound since it makes the compiler assume that dropping `Box<dyn Any>` will never unwind. cc https://github.com/rust-lang/lang-team/issues/97
2021-09-12Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnrManish Goregaokar-1/+1
generic_const_exprs: use thir for abstract consts instead of mir Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test) r? `@lcnr`
2021-09-11Ensure that crates are linked with compatible panic-in-drop settingsAmanieu d'Antras-0/+1
2021-09-10rustc: Remove local variable IDs from `Export`sVadim Petrochenkov-23/+17
Local variables can never be exported.
2021-09-09rename mir -> thir around abstract constsEllen-1/+1
2021-07-17Encode ExpnId using ExpnHash for incr. comp.Camille GILLOT-18/+5
2021-07-17Make the CrateNum part of the ExpnId.Camille GILLOT-1/+18
2021-07-14Shrink the CrateStore dynamic interface.Camille GILLOT-17/+13
2021-07-13Auto merge of #86857 - fee1-dead:add-attr, r=oli-obkbors-0/+1
Add #[default_method_body_is_const] `@rustbot` label F-const_trait_impl
2021-07-10rustc_expand: Remove redundant field from proc macro expander structuresVadim Petrochenkov-1/+1
This information is already available from `ExpnData`
2021-07-10Add impl_constness queryDeadbeef-0/+1