about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
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-99/+70
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-99/+70
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-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-7/+8
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18Rollup merge of #91926 - ↵Matthias Krüger-13/+12
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-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-6/+6
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-1/+2
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14Remove `in_band_lifetimes` from `rustc_metadata`Sylvan Bowdler-13/+12
2021-12-14extend `simplify_type`lcnr-3/+8
2021-12-12Auto merge of #90716 - euclio:libloading, r=cjgillotbors-227/+7
replace dynamic library module with libloading This PR deletes the `rustc_metadata::dynamic_lib` module in favor of the popular and better tested [`libloading` crate](https://github.com/nagisa/rust_libloading/). We don't benefit from `libloading`'s symbol lifetimes since we end up leaking the loaded library in all cases, but the call-sites look much nicer by improving error handling and abstracting away some transmutes. We also can remove `rustc_metadata`'s direct dependencies on `libc` and `winapi`. This PR also adds an exception for `libloading` (and its license) to tidy, so this will need sign-off from the compiler team.
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-2/+2
2021-12-06replace dynamic library module with libloadingAndy Russell-227/+7
2021-12-01Improve suggestion for extern crate self error messageMichael-27/+15
2021-12-01Stop treating extern crate loading failures as fatal errorsMichael-23/+37
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-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-3/+9
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-08Record more artifact sizes during self-profiling.Michael Woerister-0/+3
2021-11-07Auto merge of #88368 - jyn514:metadata-error, r=petrochenkovbors-15/+75
Improve error when an .rlib can't be parsed This usually describes either an error in the compiler itself or some sort of IO error. Either way, we should report it to the user rather than just saying "crate not found". This only gives an error if the crate couldn't be loaded at all - if the compiler finds another .rlib or .rmeta file which was valid, it will continue to compile the crate. Example output: ``` error[E0785]: found invalid metadata files for crate `foo` --> bar.rs:3:24 | 3 | println!("{}", foo::FOO_11_49[0]); | ^^^ | = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset ``` cc `@ehuss`
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-1/+1
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-1/+1
2021-11-07Improve error when an .rlib can't be parsedJoshua Nelson-15/+75
This usually describes either an error in the compiler itself or some sort of IO error. Either way, we should report it to the user rather than just saying "crate not found". This only gives an error if the crate couldn't be loaded at all - if the compiler finds another .rlib or .rmeta file which was valid, it will continue to compile the crate. Example output: ``` error[E0785]: found invalid metadata files for crate `foo` --> bar.rs:3:24 | 3 | println!("{}", foo::FOO_11_49[0]); | ^^^ | = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset ```
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-0/+1
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07Give inline const separate DefKindGary Guo-3/+9
2021-11-03Demote metadata load warning to "info".Eric Huss-2/+2
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`