summary refs log tree commit diff
path: root/compiler/rustc_metadata
AgeCommit message (Collapse)AuthorLines
2021-03-19Rollup merge of #83236 - cjgillot:memmap, r=joshtriplettDylan DPC-3/+3
Upgrade memmap to memmap2 memmap is no longer maintained. memmap2 is a fork that is still maintained. https://rustsec.org/advisories/RUSTSEC-2020-0077.html The remaining use of memmap is through measureme.
2021-03-18Upgrade memmap to memmap2 in other crates.Camille GILLOT-3/+3
2021-03-17Iterate for super_predicates.Camille GILLOT-11/+3
2021-03-16Filter generics.Camille GILLOT-6/+43
2021-03-16Iterate on inferred_outlives.Camille GILLOT-32/+4
2021-03-16Iterate on explicit_predicates.Camille GILLOT-15/+1
2021-03-16Iterate on generics_of.Camille GILLOT-15/+2
2021-03-16Iterate on variances_of.Camille GILLOT-19/+39
2021-03-13Iterate on crate_inherent_impls for metadata.Camille GILLOT-14/+11
2021-03-09Remove hir::Item::attrs.Camille GILLOT-2/+5
2021-03-09Remove hir::Crate::attrs.Camille GILLOT-1/+1
2021-03-07Auto merge of #81635 - michaelwoerister:structured_def_path_hash, r=pnkfelixbors-3/+43
Let a portion of DefPathHash uniquely identify the DefPath's crate. This allows to directly map from a `DefPathHash` to the crate it originates from, without constructing side tables to do that mapping -- something that is useful for incremental compilation where we deal with `DefPathHash` instead of `DefId` a lot. It also allows to reliably and cheaply check for `DefPathHash` collisions which allows the compiler to gracefully abort compilation instead of running into a subsequent ICE at some random place in the code. The following new piece of documentation describes the most interesting aspects of the changes: ```rust /// A `DefPathHash` is a fixed-size representation of a `DefPath` that is /// stable across crate and compilation session boundaries. It consists of two /// separate 64-bit hashes. The first uniquely identifies the crate this /// `DefPathHash` originates from (see [StableCrateId]), and the second /// uniquely identifies the corresponding `DefPath` within that crate. Together /// they form a unique identifier within an entire crate graph. /// /// There is a very small chance of hash collisions, which would mean that two /// different `DefPath`s map to the same `DefPathHash`. Proceeding compilation /// with such a hash collision would very probably lead to an ICE and, in the /// worst case, to a silent mis-compilation. The compiler therefore actively /// and exhaustively checks for such hash collisions and aborts compilation if /// it finds one. /// /// `DefPathHash` uses 64-bit hashes for both the crate-id part and the /// crate-internal part, even though it is likely that there are many more /// `LocalDefId`s in a single crate than there are individual crates in a crate /// graph. Since we use the same number of bits in both cases, the collision /// probability for the crate-local part will be quite a bit higher (though /// still very small). /// /// This imbalance is not by accident: A hash collision in the /// crate-local part of a `DefPathHash` will be detected and reported while /// compiling the crate in question. Such a collision does not depend on /// outside factors and can be easily fixed by the crate maintainer (e.g. by /// renaming the item in question or by bumping the crate version in a harmless /// way). /// /// A collision between crate-id hashes on the other hand is harder to fix /// because it depends on the set of crates in the entire crate graph of a /// compilation session. Again, using the same crate with a different version /// number would fix the issue with a high probability -- but that might be /// easier said then done if the crates in questions are dependencies of /// third-party crates. /// /// That being said, given a high quality hash function, the collision /// probabilities in question are very small. For example, for a big crate like /// `rustc_middle` (with ~50000 `LocalDefId`s as of the time of writing) there /// is a probability of roughly 1 in 14,750,000,000 of a crate-internal /// collision occurring. For a big crate graph with 1000 crates in it, there is /// a probability of 1 in 36,890,000,000,000 of a `StableCrateId` collision. ``` Given the probabilities involved I hope that no one will ever actually see the error messages. Nonetheless, I'd be glad about some feedback on how to improve them. Should we create a GH issue describing the problem and possible solutions to point to? Or a page in the rustc book? r? `@pnkfelix` (feel free to re-assign)
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-0/+4
2021-02-18Print -Ztime-passes (and misc stats/logs) on stderr, not stdout.Eduard-Mihai Burtescu-17/+17
2021-02-16Auto merge of #81611 - cjgillot:meowner, r=estebankbors-33/+25
Only store a LocalDefId in some HIR nodes Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef. As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`. This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16avoid full-slicing slicesMatthias Krüger-1/+1
If we already have a slice, there is no need to get another full-range slice from that, just use the original. clippy::redundant_slicing
2021-02-15Only store a LocalDefId in hir::MacroDef.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::ForeignItem.Camille GILLOT-10/+6
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-22/+18
Items are guaranteed to be HIR owner.
2021-02-14bumped smallvec depsklensy-1/+1
2021-02-08Rollup merge of #81861 - tmiasko:mir-bytes, r=wesleywiserMara Bos-1/+6
Show MIR bytes separately in -Zmeta-stats output The size of serialized MIR is substantial enough to deserve its own category.
2021-02-07Add `--extern-loc` to augment unused crate dependency diagnosticsJeremy Fitzhardinge-4/+23
This allows a build system to indicate a location in its own dependency specification files (eg Cargo's `Cargo.toml`) which can be reported along side any unused crate dependency. This supports several types of location: - 'json' - provide some json-structured data, which is included in the json diagnostics in a `tool_metadata` field - 'raw' - emit the provided string into the output. This also appears as a json string in `tool_metadata`. If no `--extern-location` is explicitly provided then a default json entry of the form `"tool_metadata":{"name":<cratename>,"path":<cratepath>}` is emitted.
2021-02-07Show MIR bytes separately in -Zmeta-stats outputTomasz Miąsko-1/+6
2021-02-05Auto merge of #81215 - cjgillot:defkey-mir, r=oli-obkbors-215/+103
Encode MIR metadata by iterating on DefId instead of traversing the HIR tree Split out of https://github.com/rust-lang/rust/pull/80347. This part only traverses `mir_keys` and encodes MIR according to the def kind. r? `@oli-obk`
2021-02-04Encode less consts.Camille GILLOT-7/+16
2021-02-03Address review.Camille GILLOT-6/+2
2021-02-02Let a portion of DefPathHash uniquely identify the DefPath's crate.Michael Woerister-3/+43
This allows to directly map from a DefPathHash to the crate it originates from, without constructing side tables to do that mapping. It also allows to reliably and cheaply check for DefPathHash collisions.
2021-01-29Pre-canoncalize ExternLocation::ExactPathsRyan Levick-13/+21
2021-01-26Check for rmeta crates when getting existing crates from cacheRyan Levick-2/+3
2021-01-24Sort mir_keys to ensure consistent diagnostic order.Camille GILLOT-5/+18
2021-01-24Review comment.Camille GILLOT-0/+5
2021-01-24Refactor MIR metadata emission.Camille GILLOT-215/+43
2021-01-24Introduce should_encode_mir.Camille GILLOT-0/+37
2021-01-23Fix proc macro crate encoding.Camille GILLOT-2/+9
2021-01-23Filter stability.Camille GILLOT-3/+40
2021-01-23Iterate on deprecation.Camille GILLOT-10/+1
2021-01-23Iterate on const_stability.Camille GILLOT-4/+1
2021-01-23Iterate on stability.Camille GILLOT-14/+2
2021-01-23Iterate DefId to encode expn_that_defined.Camille GILLOT-4/+1
2021-01-23Iterate DefId to encode attributes.Camille GILLOT-17/+4
2021-01-23Iterate DefId to encode visibility.Camille GILLOT-10/+38
2021-01-23Iterate to encode def_kind.Camille GILLOT-60/+28
2021-01-23Iterate DefId to encode spans.Camille GILLOT-13/+15
2021-01-23Encode DefKind directly.Camille GILLOT-142/+160
2021-01-17Impl EncodableWithShorthand for PredicateKindJack Huey-0/+6
2021-01-16Can't use EncodableWithShorthand for PredicateJack Huey-6/+0
2021-01-15Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, ↵bors-38/+9
r=michaelwoerister Remove DepKind::CrateMetadata and pre-allocation of DepNodes Remove much of the special-case handling around crate metadata dependency tracking by replacing `DepKind::CrateMetadata` and the pre-allocation of corresponding `DepNodes` with on-demand invocation of the `crate_hash` query.
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-2/+2
2021-01-14Encode optimized MIR of generators when emitting metadataTomasz Miąsko-1/+4
2021-01-13Auto merge of #77524 - Patryk27:fixes/66228, r=estebankbors-5/+12
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924) This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.