about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2021-10-08Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514Guillaume Gomez-1/+1
clippy::complexity fixes
2021-10-08clippy::complexity fixesMatthias Krüger-1/+1
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-07Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoeristerJubilee-1/+7
Implement `#[link_ordinal(n)]` Allows the use of `#[link_ordinal(n)]` with `#[link(kind = "raw-dylib")]`, allowing Rust to link against DLLs that export symbols by ordinal rather than by name. As long as the ordinal matches, the name of the function in Rust is not required to match the name of the corresponding function in the exporting DLL. Part of #58713.
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.
2021-10-06Access Session while decoding expn_id.Camille GILLOT-4/+10
2021-10-06Introduce get_diagnostic_nameCameron Steffen-5/+13
2021-10-05Rollup merge of #89546 - joshtriplett:grow-metadata-faster, r=petrochenkovManish Goregaokar-1/+3
Make an initial guess for metadata size to reduce buffer resizes When reading metadata, the compiler starts with a `Vec::new()`, which will need to grow repeatedly as the metadata gets decompressed into it. Reduce the number of resizes by starting out at the size of the compressed data.
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-13/+13
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-04Make an initial guess for metadata size to reduce buffer resizesJosh Triplett-1/+3
2021-10-04Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebankJubilee-3/+3
Practice diagnostic message convention Detected by #89455. r? ```@estebank```
2021-10-04Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwcoJubilee-1/+2
Recommend running `cargo clean` in E0514 output This suggestion has worked for me before. Seems to me it could help others.
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-13/+13
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-3/+3
2021-10-01Auto merge of #88880 - cjgillot:no-krate, r=oli-obkbors-6/+5
Rework HIR API to make invocations of the hir_crate query harder. `hir_crate` forces the recomputation of queries that depend on it. This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
2021-09-30Recommend running `cargo clean` in E0514 outputpierwill-1/+2
2021-09-30Move EncodedMetadata to rustc_metadata.Camille GILLOT-4/+20
2021-09-30Move encode_metadata out of CrateStore.Camille GILLOT-7/+6
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-6/+5
2021-09-23Auto merge of #89016 - lcnr:non_blanket_impls, r=nikomatsakis,michaelwoeristerbors-43/+29
fix non_blanket_impls iteration order We sometimes iterate over all `non_blanket_impls`, not sure if this is observable outside of error messages (i.e. as incremental bugs). This should fix the underlying issue of #86986. second attempt of #88718 r? `@nikomatsakis`
2021-09-21Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebankbors-22/+22
Migrate in-tree crates to 2021 This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074. It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there. I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first. Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately. It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-21`crates` is already deterministiclcnr-43/+29
2021-09-20Adjust documentation for compatibility with 2021Mark Rousskov-22/+22
This also adjusts the lint docs generation to accept (and ignore) an allow attribute, rather than expecting the documentation to be immediately followed by the lint name.
2021-09-20Implement #[link_ordinal] attribute in the context of #[link(kind = ↵Richard Cobbe-1/+7
"raw-dylib")].
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-2/+2
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-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.