about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2021-07-06Correct comments about untracked accesses.Camille GILLOT-3/+3
2021-07-06Make resolutions a query.Camille GILLOT-0/+6
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-29/+16
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-07-05Remove LibSourcebjorn3-3/+13
The information is stored in used_crate_source too anyway
2021-07-01Auto merge of #86749 - bjorn3:link_info_refactor_part1, r=petrochenkovbors-7/+7
Rename all_crate_nums query to crates and remove useless wrapper Split out of https://github.com/rust-lang/rust/pull/86105 r? `@petrochenkov`
2021-07-01Rename all_crate_nums query to crates and remove useless wrapperbjorn3-7/+7
2021-06-30use is_const_fn_raw when encoding constnessDeadbeef-1/+6
this properly encodes cross-crate constness data.
2021-06-28Auto merge of #85909 - cjgillot:alloc-kind-query, r=Aaron1011bors-5/+1
Make allocator_kind a query. Part of #85153 r? `@Aaron1011`
2021-06-24Use `#[non_exhaustive]` where appropriateJacob Pratt-4/+3
Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`.
2021-06-21Print more crate details in -ZlsJeremy Fitzhardinge-2/+15
Useful for debugging crate hash and resolution issues.
2021-06-20Implement the query in cstore_impl.Camille GILLOT-5/+1
2021-06-18Auto merge of #85284 - eggyal:custom-profiler-runtime, r=jackh726bors-19/+25
Provide option for specifying the profiler runtime Currently, if `-Zinstrument-coverage` is enabled, the target is linked against the `library/profiler_builtins` crate (which pulls in LLVM's compiler-rt runtime). This option enables backends to specify an alternative runtime crate for handling injected instrumentation calls.
2021-06-17Early return from `inject_profiler_runtime`Alan Egerton-23/+23
2021-06-17Auto merge of #85834 - cjgillot:save-sbi, r=michaelwoeristerbors-4/+4
Encode CrateNum using the StableCrateId for incr. comp.
2021-06-11Auto merge of #85885 - bjorn3:remove_box_region, r=cjgillotbors-3/+3
Don't use a generator for BoxedResolver The generator is non-trivial and requires unsafe code anyway. Using regular unsafe code without a generator is much easier to follow. Based on #85810 as it touches rustc_interface too.
2021-06-10Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011bors-6/+4
Drop metadata_encoding_version. Part of #85153 r? `@Aaron1011`
2021-06-09Encode CrateNum using the StableCrateId for incr. comp.Camille GILLOT-4/+4
2021-06-08Store boxed metadata loader in CrateLoaderbjorn3-3/+3
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-16/+29
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-06Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkovbors-11/+61
Partial support for raw-dylib linkage First cut of functionality for issue #58713: add support for `#[link(kind = "raw-dylib")]` on `extern` blocks in lib crates compiled to .rlib files. Does not yet support `#[link_name]` attributes on functions, or the `#[link_ordinal]` attribute, or `#[link(kind = "raw-dylib")]` on `extern` blocks in bin crates; I intend to publish subsequent PRs to fill those gaps. It's also not yet clear whether this works for functions in `extern "stdcall"` blocks; I also intend to investigate that shortly and make any necessary changes as a follow-on PR. This implementation calls out to an LLVM function to construct the actual `.idata` sections as temporary `.lib` files on disk and then links those into the generated .rlib.
2021-06-05Auto merge of #86002 - cjgillot:expn_that_defined, r=petrochenkovbors-1/+1
Always go through the expn_that_defined query.
2021-06-04Add first cut of functionality for #58713: support for #[link(kind = ↵Richard Cobbe-11/+61
"raw-dylib")]. This does not yet support #[link_name] attributes on functions, the #[link_ordinal] attribute, #[link(kind = "raw-dylib")] on extern blocks in bin crates, or stdcall functions on 32-bit x86.
2021-06-04Always go through the expn_that_defined query.Camille GILLOT-1/+1
2021-06-04Rollup merge of #85889 - denismerigoux:master, r=petrochenkovYuki Okushi-0/+11
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-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-2/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-03Restore the num_def_ids_untracked public function giving the total number of ↵Denis Merigoux-0/+11
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-3/+2
Also remove original_crate_name, which had the exact same implementation
2021-06-02Update compiler/rustc_metadata/src/rmeta/mod.rsCamille Gillot-1/+1
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-06-02Auto merge of #85908 - cjgillot:private-dep-query, r=Aaron1011bors-4/+5
Make is_private_dep a query. Part of #85153 r? `@Aaron1011`
2021-06-01Auto merge of #85829 - bjorn3:simplify_crate_num, r=jackh726bors-1/+1
Remove CrateNum::ReservedForIncrCompCache It's only use is easily replaceable with `Option<CrateNum>`.
2021-06-01Drop metadata_encoding_version.Camille GILLOT-6/+4
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-16/+16
2021-05-31Remove unused feature gatesbjorn3-2/+0
2021-05-30Drop metadata_encoding_version.Camille GILLOT-6/+4
2021-05-30Correct comments about untracked accesses.Camille GILLOT-3/+3
2021-05-30Make is_private_dep a query.Camille GILLOT-4/+1
2021-05-30Restrict access to crate_name.Camille GILLOT-3/+2
Also remove original_crate_name, which had the exact same implementation
2021-05-30Make resolutions a query.Camille GILLOT-0/+6
2021-05-30Remove CrateNum::ReservedForIncrCompCachebjorn3-1/+1
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-29/+16
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-17Provide option for specifying the profiler runtimeAlan Egerton-18/+24
Currently, if `-Zinstrument-coverage` is enabled, the target is linked against the `library/profiler_builtins` crate (which pulls in LLVM's compiler-rt runtime). This option enables backends to specify an alternative runtime crate for handling injected instrumentation calls.
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-32/+12
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-16Reuse variableAndy Wang-3/+1
2021-05-16Remap after prepending cwdAndy Wang-5/+16
2021-05-14Auto merge of #85211 - Aaron1011:metadata-invalid-span, r=michaelwoeristerbors-45/+45
Preserve `SyntaxContext` for invalid/dummy spans in crate metadata Fixes #85197 We already preserved the `SyntaxContext` for invalid/dummy spans in the incremental cache, but we weren't doing the same for crate metadata. If an invalid (lo/hi from different files) span is written to the incremental cache, we will decode it with a 'dummy' location, but keep the original `SyntaxContext`. Since the crate metadata encoder was only checking for `DUMMY_SP` (dummy location + root `SyntaxContext`), the metadata encoder would treat it as a normal span, encoding the `SyntaxContext`. As a result, the final span encoded to the metadata would change across sessions, even if the crate itself was unchanged. This could lead to an 'unstable fingerprint' ICE under the following conditions: 1. We compile a crate with an invalid span using incremental compilation. The metadata encoder discards the `SyntaxContext` since the span is invalid, while the incremental cache encoder preserves the `SyntaxContext` 2. From another crate, we execute a foreign query, decoding the invalid span from the metadata as `DUMMY_SP` (e.g. with `SyntaxContext::root()`). This span gets hashed into the query fingerprint. So far, this has always happened through the `optimized_mir` query. 3. We recompile the first crate using our populated incremental cache, without changing anything. We load the (previously) invalid span from our incremental cache - it gets converted to a span with a dummy (but valid) location, along with the original `SyntaxContext`. This span gets written out to the crate metadata - since it now has a valid location, we preserve its `SyntaxContext`. 4. We recompile the second crate, again using a populated incremental cache. We now re-run the foreign query `optimized_mir` - the foreign crate hash is unchanged, but we end up decoding a different span (it now ha a non-root `SyntaxContext`). This results in the fingerprint changing, resulting in an ICE. This PR updates our encoding of spans in the crate metadata to mirror the encoding of spans into the incremental cache. We now always encode a `SyntaxContext`, and encode location information for spans with a non-dummy location.
2021-05-13Rollup merge of #85068 - luqmana:78708-xcrate-diag, r=estebankGuillaume Gomez-3/+28
Fix diagnostic for cross crate private tuple struct constructors Fixes #78708. There was already some limited support for certain cross-crate scenarios but that didn't handle a tuple struct rexported from an inner module for example (e.g. the NonZero* types as seen in #85049). ```Rust ➜ cat bug.rs fn main() { let _x = std::num::NonZeroU32(12); let n = std::num::NonZeroU32::new(1).unwrap(); match n { std::num::NonZeroU32(i) => {}, } } ``` **Before:** <details> ```Rust ➜ rustc +nightly bug.rs error[E0423]: expected function, tuple struct or tuple variant, found struct `std::num::NonZeroU32` --> bug.rs:2:14 | 2 | let _x = std::num::NonZeroU32(12); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `std::num::NonZeroU32 { 0: val }` | ::: /home/luqman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:148:1 [snip] error[E0532]: expected tuple struct or tuple variant, found struct `std::num::NonZeroU32` --> bug.rs:5:9 | 5 | std::num::NonZeroU32(i) => {}, | ^^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `std::num::NonZeroU32 { 0 }` | ::: /home/luqman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:148:1 [snip] error: aborting due to 2 previous errors Some errors have detailed explanations: E0423, E0532. For more information about an error, try `rustc --explain E0423`. ``` </details> **After:** <details> ```Rust ➜ /rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc bug.rs error[E0423]: cannot initialize a tuple struct which contains private fields --> bug.rs:2:14 | 2 | let _x = std::num::NonZeroU32(12); | ^^^^^^^^^^^^^^^^^^^^ | note: constructor is not visible here due to private fields --> /rust/library/core/src/num/nonzero.rs:148:1 [snip] error[E0532]: cannot match against a tuple struct which contains private fields --> bug.rs:5:9 | 5 | std::num::NonZeroU32(i) => {}, | ^^^^^^^^^^^^^^^^^^^^ | note: constructor is not visible here due to private fields --> bug.rs:5:30 | 5 | std::num::NonZeroU32(i) => {}, | ^ private field error: aborting due to 2 previous errors Some errors have detailed explanations: E0423, E0532. For more information about an error, try `rustc --explain E0423`. ``` </details> One question is if we should only collect the needed info for the cross-crate case after encountering an error instead of always doing it. Perf run perhaps to gauge the impact.
2021-05-12Preserve `SyntaxContext` for invalid/dummy spans in crate metadataAaron Hill-45/+45
Fixes #85197 We already preserved the `SyntaxContext` for invalid/dummy spans in the incremental cache, but we weren't doing the same for crate metadata. If an invalid (lo/hi from different files) span is written to the incremental cache, we will decode it with a 'dummy' location, but keep the original `SyntaxContext`. Since the crate metadata encoder was only checking for `DUMMY_SP` (dummy location + root `SyntaxContext`), the metadata encoder would treat it as a normal span, encoding the `SyntaxContext`. As a result, the final span encoded to the metadata would change across sessions, even if the crate itself was unchanged. This PR updates our encoding of spans in the crate metadata to mirror the encoding of spans into the incremental cache. We now always encode a `SyntaxContext`, and encode location information for spans with a non-dummy location.
2021-05-12Use () for analysis.Camille GILLOT-3/+3