about summary refs log tree commit diff
path: root/compiler/rustc_metadata
AgeCommit message (Collapse)AuthorLines
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-2/+2
2021-09-17Update odht to 0.2.1Michael Woerister-1/+1
2021-09-14rustc_metadata: Remove Metadata::raw_bytes() and use Metadata::blob() ↵Michael Woerister-7/+4
directly instead.
2021-09-14Rename DefPathHashMap in rustc_metadata so its name does not clash with ↵Michael Woerister-21/+19
DefPathHashMap in rustc_hir.
2021-09-14Make DefPathHash->DefId panic for if the mapping fails.Michael Woerister-7/+6
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-66/+104
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-14Use on-disk-hash-table format for DefPathHashMap in hir::definitions.Michael Woerister-0/+1
2021-09-14Allow taking an OwningRef of the crate metadata blob.Michael Woerister-18/+62
2021-09-12Auto merge of #88759 - Amanieu:panic_in_drop, r=nagisa,eddybbors-9/+26
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-9/+13
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-12Rollup merge of #88677 - petrochenkov:exportid, r=davidtwcoManish Goregaokar-36/+20
rustc: Remove local variable IDs from `Export`s Local variables can never be exported.
2021-09-11Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkovbors-1/+2
Encode spans relative to the enclosing item The aim of this PR is to avoid recomputing queries when code is moved without modification. MCP at https://github.com/rust-lang/compiler-team/issues/443 This is achieved by : 1. storing the HIR owner LocalDefId information inside the span; 2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache; 3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation. Since all client code uses `Span`, step 3 ensures that all manipulations of span byte positions actually create the dependency edge between the caller and the `source_span(LocalDefId)`. This query return the actual absolute span of the parent item. As a consequence, any source code motion that changes the absolute byte position of a node will either: - modify the distance to the parent's beginning, so change the relative span's hash; - dirty `source_span`, and trigger the incremental recomputation of all code that depends on the span's absolute byte position. With this scheme, I believe the dependency tracking to be accurate. For the moment, the spans are marked during lowering. I'd rather do this during def-collection, but the AST MutVisitor is not practical enough just yet. The only difference is that we attach macro-expanded spans to their expansion point instead of the macro itself.
2021-09-11Ensure that crates are linked with compatible panic-in-drop settingsAmanieu d'Antras-9/+26
2021-09-10rustc: Remove local variable IDs from `Export`sVadim Petrochenkov-36/+20
Local variables can never be exported.
2021-09-10Add help for E0463Guillaume Gomez-0/+5
2021-09-10Keep a parent LocalDefId in SpanData.Camille GILLOT-1/+2
2021-09-09add test for builtin types N + N unifying with fn callEllen-1/+1
2021-09-09rename mir -> thir around abstract constsEllen-9/+13
2021-09-04Auto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkovbors-94/+77
CrateLocator refactorings This makes the `CrateLocator` a lot cleaner IMHO and much more self-contained. The last commit removes `extra_filename` from the crate metadata. This is an **insta-stable** change as it allows a crate like `libfoo-abc.rlib` to be used as dependency and then be renamed as `libfoo-bcd.rlib` while still being found as indirect dependency. This may reduce performance when there are a lot of versions of the same crate available as the extra filename won't be used to do an early rejection of crates before trying to load metadata, but it makes the logic to find the right filename a lot cleaner.
2021-09-02Remove unused argument from resolve_cratebjorn3-9/+6
2021-09-02Introduce CrateRejections structbjorn3-40/+36
2021-09-02Remove root field from CrateLocatorbjorn3-9/+4
2021-09-02Remove host_hash from CrateLocatorbjorn3-7/+3
2021-09-02Refactor CrateLocator.is_proc_macrobjorn3-18/+13
This also fixes a (theoretical) bug where a proc-macro may be loaded as plugin if it exports a symbol with the right name.
2021-09-02Don't store Session in CrateLocatorbjorn3-11/+15
2021-09-01Compute proc_macros in resolutions.Camille GILLOT-9/+11
2021-08-28Treat macros as HIR itemsinquisitivecrystal-14/+11
2021-08-25Auto merge of #85344 - cbeuw:remap-across-cwd, r=michaelwoeristerbors-5/+14
Correctly handle remapping from path containing the current directory with trailing paths If we have a `auxiliary/lib.rs`, and we generate the metadata with `--remap-path-prefix $PWD/auxiliary=xyz`, the path to `$PWD/auxiliary/lib.rs` won't be correctly remapped in the metadata. This is because internally, path to the working directory itself and relative paths to files under the working directory are remapped separately (hence neither are affected since neither has `$PWD/auxiliary` as prefix), but the concatenation between the working directory and the relative path is not remapped. This PR fixes that.
2021-08-24Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiserbors-2/+1
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor` Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-22Fix typos “an”→“a” and a few different ones that appeared in the ↵Frank Steffahn-1/+1
same search
2021-08-22Revert a change of “an --extern” (can be read with “dash dash”)Frank Steffahn-1/+1
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-2/+1
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-15Include (potentially remapped) working dir in crate hashAaron Hill-1/+4
Fixes #85019 A `SourceFile` created during compilation may have a relative path (e.g. if rustc itself is invoked with a relative path). When we write out crate metadata, we convert all relative paths to absolute paths using the current working direction. However, the working directory is not included in the crate hash. This means that the crate metadata can change while the crate hash remains the same. Among other problems, this can cause a fingerprint mismatch ICE, since incremental compilation uses the crate metadata hash to determine if a foreign query is green. This commit moves the field holding the working directory from `Session` to `Options`, including it as part of the crate hash.
2021-08-12Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkovbors-4/+4
Plugin interface cleanup The first commit performs two uncontroversial cleanups. The second commit removes `#[plugin_registrar]` and instead requires you to export a `__rustc_plugin_registrar` function, this will require a change to servo's script_plugins (cc `@jdm)`
2021-08-10Replace #[plugin_registrar] with exporting __rustc_plugin_registrarbjorn3-4/+4
2021-08-09Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkovbors-11/+9
Fix feature gate checking of static-nobundle and native_link_modifiers Feature native_link_modifiers_bundle don't need feature static-nobundle to work. Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate. ``` > touch lib.rs > rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib > rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static > rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib error[E0658]: kind="static-nobundle" is unstable | = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information = help: add `#![feature(static_nobundle)]` to the crate attributes to enable error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. ``` First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655
2021-08-08 Fix feature gate checking of static-nobundle and native_link_modifiers12101111-11/+9
2021-08-06encode `generics_of` of fields and ty paramsEllen-2/+2
2021-08-04Add back -Zno-profiler-runtimeAmanieu d'Antras-8/+6
This was removed by #85284 in favor of -Zprofiler-runtime=<name>. However the suggested -Zprofiler-runtime=None doesn't work because "None" is treated as a crate name.
2021-07-29rfc3052: Remove authors field from Cargo manifestsJade-1/+0
Since RFC 3052 soft deprecated the authors field anyway, hiding it from crates.io, docs.rs, and making Cargo not add it by default, and it is not generally up to date/useful information, we should remove it from crates in this repo.
2021-07-25Auto merge of #83723 - cjgillot:ownernode, r=petrochenkovbors-2/+2
Store all HIR owners in the same container This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem. This should allow for a more compact storage. Based on https://github.com/rust-lang/rust/pull/83114
2021-07-25Introduce OwnerNode::Crate.Camille GILLOT-1/+1
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-1/+1
2021-07-24Remove detection of rustup and cargo in 'missing extern crate' diagnosticsJoshua Nelson-2/+5
Previously, this would change the test output when RUSTUP_HOME was set: ``` ---- [ui] ui/issues/issue-49851/compiler-builtins-error.rs stdout ---- diff of stderr: 1 error[E0463]: can't find crate for `core` 2 | 3 = note: the `thumbv7em-none-eabihf` target may not be installed + = help: consider downloading the target with `rustup target add thumbv7em-none-eabihf` 4 5 error: aborting due to previous error 6 ``` Originally, I fixed it by explicitly unsetting RUSTUP_HOME in compiletest. Then I realized that almost no one has RUSTUP_HOME set, since rustup doesn't set it itself; although it does set RUST_RECURSION_COUNT whenever it launches a proxy. Then it was pointed out that this runtime check doesn't really make sense and it's fine to make it unconditional.
2021-07-18Auto merge of #86698 - cjgillot:modc, r=estebankbors-1/+4
Move OnDiskCache to rustc_query_impl. This should be the last remnant of the query implementation that was still in rustc_middle.
2021-07-18Move OnDiskCache to rustc_query_impl.Camille GILLOT-1/+4
2021-07-18Rollup merge of #87092 - ricobbe:fix-raw-dylib-multiple-definitions, ↵Yuki Okushi-1/+1
r=petrochenkov Remove nondeterminism in multiple-definitions test Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function. Restore the multiple-definitions test. Resolves #87084.
2021-07-17Drop ExpnData::krate.Camille GILLOT-1/+1
2021-07-17Drop orig_id.Camille GILLOT-1/+1