summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder
AgeCommit message (Collapse)AuthorLines
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-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
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-4/+3
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-07-01Rename all_crate_nums query to crates and remove useless wrapperbjorn3-1/+1
2021-06-20Implement the query in cstore_impl.Camille GILLOT-5/+1
2021-06-10Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011bors-5/+1
Drop metadata_encoding_version. Part of #85153 r? `@Aaron1011`
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-3/+4
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-04Rollup merge of #85889 - denismerigoux:master, r=petrochenkovYuki Okushi-0/+7
Restoring the `num_def_ids` function in the CStore API ## The context I am the maintainer of https://github.com/hacspec/hacspec, an embedded Rust DSL aimed at cryptographic specifications. As it is normal for an embedded DSL, Hacspec's compiler relies on being plugged to the internal API of the Rust compiler, which is unstable and subject to changes. ## The problem The Hacspec compiler features its own typechecker, that performs an additional, more restrictive typechecking pass over the Rust code of a crate. To complete this typechecking, the Hacspec compiler needs to retrieve the signature of functions defined in non-local imported crates. Rather than retrieving these signatures on-demand, the Hacspec compiler pre-populates its typechecking context with all the Hacspec-compatible symbols defined in non-local crates first. This requires having a way to iterate over all the definitions in a non-local crate. I used to do this with `CrateMetadata::all_def_path_hashes_and_def_ids`, but this function was deleted in 908bf5a310b7265a3e. Then, I fellback on `CStore::num_def_ids`, exploiting the fact that all the `DefIds` for a crate have the same `krate_num` and range from `0` to `num_def_ids(krate_num)`. But `num_def_ids` was deleted in b6120bfb354c1c1c9fdf. I looked to the `Cstore::item_children_untracked` function to replicate the feature of traversing through all the `DefId` for a crate, using `CRATE_DEF_INDEX` as the root, but this does not work as recursive `Cstore::item_children_untracked` calls do not reach all the symbols I was able to reach using the two previous methods. ## Description of this PR This PR simply restores in the public API of `CStore` the `num_def_ids` function, giving the size of the definition table for a given crate.
2021-06-03Restore the num_def_ids_untracked public function giving the total number of ↵Denis Merigoux-0/+7
exported symbols for each crate Restored underlying num_def_ids_method Update compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Changed name to fit with naming convention Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com> Update compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Replace regular doc with Rustdoc comment Co-authored-by: Joshua Nelson <jyn514@gmail.com> Clarifies third-party use of num_def_ids_untracked
2021-06-02Restrict access to crate_name.Camille GILLOT-2/+1
Also remove original_crate_name, which had the exact same implementation
2021-06-01Drop metadata_encoding_version.Camille GILLOT-5/+1
2021-06-01Make is_private_dep a query.Camille GILLOT-4/+5
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-3/+11
2021-05-30Drop metadata_encoding_version.Camille GILLOT-5/+1
2021-05-30Make is_private_dep a query.Camille GILLOT-4/+1
2021-05-30Restrict access to crate_name.Camille GILLOT-2/+1
Also remove original_crate_name, which had the exact same implementation
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-4/+3