about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta
AgeCommit message (Collapse)AuthorLines
2022-01-07Deserialization less in associated_item_def_idsMatthew Jasper-6/+11
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-29/+24
2022-01-06rustc_metadata: Make `opt_item_ident` in decoder faster and stricterVadim Petrochenkov-36/+25
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-17/+17
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-06rustc_middle: Add a method for getting a `SimplifiedType` definition/IDVadim Petrochenkov-6/+7
Import `SimplifiedType` more
2022-01-02Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, ↵bors-1/+1
r=wesleywiser Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0 This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. This does not change the default symbol-mangling-version. See https://github.com/rust-lang/rust/pull/89917 for a pull request changing the default. Rationale, from #89917: Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain . characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters A-Z, a-z, 0-9, and _. Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers). This pull request allows enabling the new v0 symbol-mangling-version. See #89917 for references to the implementation of v0, and for references to the tool changes to decode Rust symbols.
2022-01-02Auto merge of #92034 - petrochenkov:nolinknores, r=joshtriplettbors-9/+1
Remove effect of `#[no_link]` attribute on name resolution Previously it hid all non-macro names from other crates. This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors. I can kind of understand the possible reasoning behind the current behavior - if you can use names from a `no_link` crates then you can use, for example, functions too, but whether it will actually work or produce link-time errors will depend on random factors like inliner behavior. (^^^ This is not the actual reason why the current behavior exist, I've looked through git history and it's mostly accidental.) I think this risk is ok for such an obscure attribute, and we don't need to specifically prevent use of non-macro items from such crates. (I'm not actually sure why would anyone use `#[no_link]` on a crate, even if it's macro only, if you aware of any use cases, please share. IIRC, at some point it was used for crates implementing custom derives - the now removed legacy ones, not the current proc macros.) Extracted from https://github.com/rust-lang/rust/pull/91795.
2022-01-01Stabilize -Z symbol-mangling-version as -C symbol-mangling-versionJosh Triplett-1/+1
This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options. Continue supporting -Z symbol-mangling-version for compatibility for now, but show a deprecation warning for it.
2022-01-01rustc_metadata: Use a query for collecting all traits in encoderVadim Petrochenkov-48/+63
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-29Auto merge of #92244 - petrochenkov:alltraits, r=cjgillotbors-22/+68
rustc_metadata: Encode list of all crate's traits into metadata While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree. This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-28Auto merge of #92153 - petrochenkov:foreignchild, r=cjgillotbors-44/+20
rustc_metadata: Merge items from `extern` blocks into their parent modules during metadata encoding rather than during metadata decoding
2021-12-28rustc_metadata: Encode list of all crate's traits into metadataVadim Petrochenkov-22/+68
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-28rustc_metadata: Merge items from `extern` blocks into their parent modulesVadim Petrochenkov-44/+20
during metadata encoding rather than during metadata decoding
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-24Auto merge of #92156 - petrochenkov:ctorkind, r=davidtwcobors-24/+20
rustc_metadata: Merge `get_ctor_def_id` and `get_ctor_kind` Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag. A small optimization and cleanup extracted from https://github.com/rust-lang/rust/pull/89059.
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-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+1
Implement `Ord`, `PartialOrd` for SpanData
2021-12-22rustc_metadata: Merge `get_ctor_def_id` and `get_ctor_kind`Vadim Petrochenkov-24/+20
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-18Rollup merge of #91926 - ↵Matthias Krüger-8/+8
SylvanB:remove_in_band_lifetimes_from_rustc_metadata, r=nagisa Remove `in_band_lifetimes` from `rustc_metadata` Another for #91867
2021-12-17Remove effect of `#[no_link]` attribute on name resolutionVadim Petrochenkov-9/+1
Previously it hid all non-macro names from other crates. This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors
2021-12-16Rollup merge of #92001 - fee1-dead:dmbic-xcrate-fix, r=oli-obkMatthias Krüger-2/+3
Fix default_method_body_is_const when used across crates r? `@oli-obk` unblocks #91439.
2021-12-16Fix default_method_body_is_const when used across cratesDeadbeef-2/+3
2021-12-14Remove `in_band_lifetimes` from `rustc_metadata`Sylvan Bowdler-8/+8
2021-12-14extend `simplify_type`lcnr-3/+8
2021-12-11Auto merge of #91715 - the8472:bump-rmeta-fromat-version, r=Mark-Simulacrumbors-1/+1
Bump rmeta version to fix rustc_serialize ICE #91407 changed the serialization format which leads to ICEs for nightly users such as #91663 and linked issues. The issue can be solved by running `cargo clean`. But bumping the metadata version should lead to the cached files being discarded, avoiding the issue entirely.
2021-12-09Bump rmeta version to fix rustc_serialize ICEThe 8472-1/+1
#91407 changed the serialization format which leads to ICEs for nightly users such as #91663 and linked issue. Bumping the metadata version should lead to the cached files being discarded instead.
2021-12-09Remove redundant [..]sest31-1/+1
2021-11-30Auto merge of #91330 - cjgillot:no-ee-features, r=Aaron1011bors-1/+1
Remove eval_always for lib_features. r? `@Aaron1011`
2021-11-28Remove eval_always for lib_features.Camille GILLOT-1/+1
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-4/+2
2021-11-09Add `ty::Visibility::is_public()`inquisitivecrystal-2/+2
2021-11-09Rollup merge of #90701 - michaelwoerister:more-artifact-sizes, r=davidtwcoMatthias Krüger-0/+3
Record more artifact sizes during self-profiling. This PR adds artifact size recording for - "linked artifacts" (executables, RLIBs, dylibs, static libs) - object files - dwo files - assembly files - crate metadata - LLVM bitcode files - LLVM IR files - codegen unit size estimates Currently the identifiers emitted for these are hard-coded as string literals. Is it worth adding constants to https://github.com/rust-lang/measureme/blob/master/measureme/src/rustc.rs instead? We don't do that for query names and the like -- but artifact kinds might be more stable than query names.
2021-11-08Record more artifact sizes during self-profiling.Michael Woerister-0/+3
2021-11-07Give inline const separate DefKindGary Guo-3/+9
2021-10-30Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkovGuillaume Gomez-16/+11
Improve and test cross-crate hygiene - Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck - Avoid suggesting importing names with def-site hygiene, since it's often not useful - Add more tests r? `@petrochenkov`
2021-10-28Remove `ModData` from rustc_metadataMatthew Jasper-11/+4
This avoids having to decode 2 `Lazy`s when decoding a modules exports.
2021-10-25Avoid a branch on key being local for queries that use the same local and ↵bjorn3-3/+3
extern providers
2021-10-21Handle cross-crate module `ExpnId`s consistentlyMatthew Jasper-6/+8
- Always use the ExpnId serialized to `tables` - Use the Id for traits and enums from other crates in resolution.
2021-10-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-3/+1
Adopt let_else across the compiler This performs a substitution of code following the pattern: ``` let <id> = if let <pat> = ... { identity } else { ... : ! }; ``` To simplify it to: ``` let <pat> = ... { identity } else { ... : ! }; ``` By adopting the `let_else` feature (cc #87335). The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet. Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-17Auto merge of #89514 - davidtwco:polymorphize-shims-and-predicates, r=lcnrbors-1/+9
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-16Adopt let_else across the compilerest31-3/+1
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-07Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkovJubilee-6/+10
Correct decoding of foreign expansions during incr. comp. Fixes https://github.com/rust-lang/rust/issues/74946 The original issue was due to a wrong assertion in `expn_hash_to_expn_id`. The secondary issue was due to a mismatch between the encoding and decoding paths for expansions that are created after the TyCtxt is created.
2021-10-06Do not ICE if some foreign expansions were not encoded.Camille GILLOT-2/+0
The metadata encoder does not necessarily encode all expansions, only those which are referenced in other metadata fields.