about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2023-07-19Encode shorthands for spans in metadata.Camille GILLOT-13/+48
2023-07-17Do not fetch HIR in native_libs.Camille GILLOT-55/+40
2023-07-17Simplify foreign_modules.Camille GILLOT-6/+16
2023-07-17Auto merge of #113562 - saethlin:larger-incr-comp-offset, r=nnethercotebors-2/+2
Use u64 for incr comp allocation offsets Fixes https://github.com/rust-lang/rust/issues/76037 Fixes https://github.com/rust-lang/rust/issues/95780 Fixes https://github.com/rust-lang/rust/issues/111613 These issues are all reporting ICEs caused by using `u32` to store offsets to allocations in the incremental compilation cache. This PR aims to lift that limitation by changing the offset type in question to `u64`. There are two perf runs in this PR. The first reports a regression, and the second does not. The changes are the same in both. I rebased the PR then did the second perf run because I noticed that the primary regression in it was very commonly seen in spurious regression reports. I do not know what the perf run will report when this is merged. I would not be surprised to see regression or neutral, but the cachegrind diffs for the regression point at `try_mark_previous_green` which is a common source of inexplicable regressions and I don't think should be perturbed by this PR. I'm not opposed to adding a regression test such as ```rust fn main() { println!("{}", [37; 1 << 30].len()); } ``` But that program takes 1 minute to compile and consumes 4.6 GB of memory then writes that much to disk. Is that a concerning amount of resource use for a test? r? `@nnethercote`
2023-07-14Use u64 for incr comp allocation offsetsBen Kimock-2/+2
2023-07-14Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorinoMatthias Krüger-1/+1
Make it clearer that we're just checking for an RPITIT Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`. r? `@spastorino`
2023-07-14Make it clearer that we're just checking for an RPITITMichael Goulet-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-2/+2
2023-07-14Micro-optimizeBen Kimock-4/+14
2023-07-13Adapt table sizes to the contentsBen Kimock-45/+102
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-17/+37
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-31/+1
2023-07-04Auto merge of #113215 - compiler-errors:rpitit-predicates-tweaks, r=spastorinobors-4/+4
Make RPITITs assume/require their parent method's predicates Removes a FIXME from the `param_env` query where we were manually adding the parent function's predicates to the RPITIT's assumptions. r? `@spastorino`
2023-07-04Suggest `x build library` for a custom toolchain that fails to load `core`Mu001999-4/+14
2023-07-03Revert "Suggest `x build library` for a custom toolchain that fails to load ↵Nilstrieb-10/+4
`core`" This reverts commit b913f5593d2e2698d18034b56dd538ee745f1adc. CI builds with profile=nightly, causing different test output. Making the output depend on the release channel was not a great idea.
2023-07-02Suggest `x build library` for a custom toolchain that fails to load `core`Mu001999-4/+10
2023-06-30reflow comment, not a FIXME i thinkMichael Goulet-4/+4
2023-06-29Encode item bounds for DefKind::ImplTraitPlaceholderMichael Goulet-0/+3
2023-06-28Auto merge of #98867 - cjgillot:metaloop, r=oli-obkbors-284/+197
Refactor metadata emission to avoid visiting HIR This PR refactors metadata emission to be based on tables and iteration over definitions. In a first part, this PR moves information from the `EntryKind` enum to tables, until removing the `EntryKind` enum. In a second part, the iteration scheme is refactored to avoid fetching HIR unless strictly necessary. r? `@ghost`
2023-06-27Encode impls in encode_impls.Camille GILLOT-46/+31
2023-06-27Use instrument macro.Camille GILLOT-13/+10
2023-06-27Retire encode_info_for_items.Camille GILLOT-83/+33
2023-06-27Encode Impl separately.Camille GILLOT-24/+31
2023-06-27Encode Trait info in def-id loop.Camille GILLOT-10/+8
2023-06-27Merge assoc_item functions.Camille GILLOT-50/+30
2023-06-27Encode fn_sig separately.Camille GILLOT-38/+91
Closures do not have a `fn_sig`, so no reason to encode one.
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-6/+0
2023-06-26Use constness query to encode constness.Camille GILLOT-7/+1
2023-06-26Encode info for Fn/AssocFn in a single place.Camille GILLOT-67/+16
2023-06-23Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, ↵bors-2/+2
r=compiler-errors Various impl trait in assoc tys cleanups r? `@compiler-errors` All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature. best reviewed commit by commit
2023-06-22migrate inferred_outlives_of to ClauseMichael Goulet-1/+1
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-3/+9
2023-06-22Move `opaque_type_origin_unchecked` onto `TyCtxt` and re-use it where it was ↵Oli Scherer-2/+2
open coded
2023-06-21Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnrNilstrieb-1/+1
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that... r? ``@lcnr`` or ``@oli-obk`` [^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-19Make closure_saved_names_of_captured_variables a query.Camille GILLOT-1/+5
2023-06-19s/Clause/ClauseKindMichael Goulet-1/+1
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-2/+2
2023-06-09Auto merge of #111626 - pjhades:output, r=b-naberbors-10/+44
Write to stdout if `-` is given as output file With this PR, if `-o -` or `--emit KIND=-` is provided, output will be written to stdout instead. Binary output (those of type `obj`, `llvm-bc`, `link` and `metadata`) being written this way will result in an error unless stdout is not a tty. Multiple output types going to stdout will trigger an error too, as they will all be mixded together. This implements https://github.com/rust-lang/compiler-team/issues/431 The idea behind the changes is to introduce an `OutFileName` enum that represents the output - be it a real path or stdout - and to use this enum along the code paths that handle different output types.
2023-06-07Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkovbors-0/+25
Remember names of `cfg`-ed out items to mention them in diagnostics # Examples ## `serde::Deserialize` without the `derive` feature (a classic beginner mistake) I had to slightly modify serde so that it uses explicit re-exports instead of a glob re-export. (Update: a serde PR was merged that adds the manual re-exports) ``` error[E0433]: failed to resolve: could not find `Serialize` in `serde` --> src/main.rs:1:17 | 1 | #[derive(serde::Serialize)] | ^^^^^^^^^ could not find `Serialize` in `serde` | note: crate `serde` has an item named `Serialize` but it is inactive because its cfg predicate evaluated to false --> /home/gh-Nilstrieb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/src/lib.rs:343:1 | 343 | #[cfg(feature = "serde_derive")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 344 | pub use serde_derive::{Deserialize, Serialize}; | ^^^^^^^^^ = note: the item is gated behind the `serde_derive` feature = note: see https://doc.rust-lang.org/cargo/reference/features.html for how to activate a crate's feature ``` (the suggestion is not ideal but that's serde's fault) I already tested the metadata size impact locally by compiling the `windows` crate without any features. `800k` -> `809k` r? `@ghost`
2023-06-06fixJing Peng-15/+1
- remove useless commands from test Makefile - do not unnecessarily remove metadata temporary files because they'll be managed by MaybeTempDir - remove unused FailedRemove error introduced by this PR
2023-06-06Write to stdout if `-` is given as output fileJing Peng-10/+58
If `-o -` or `--emit KIND=-` is provided, output will be written to stdout instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`) being written this way will result in an error unless stdout is not a tty. Multiple output types going to stdout will trigger an error too, as they will all be mixded together.
2023-06-02Separate AnonConst from ConstBlock in HIR.Camille GILLOT-2/+1
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-0/+25
`#[cfg]`s are frequently used to gate crate content behind cargo features. This can lead to very confusing errors when features are missing. For example, `serde` doesn't have the `derive` feature by default. Therefore, `serde::Serialize` fails to resolve with a generic error, even though the macro is present in the docs. This commit adds a list of all stripped item names to metadata. This is filled during macro expansion and then, through a fed query, persisted in metadata. The downstream resolver can then access the metadata to look at possible candidates for mentioning in the errors. This slightly increases metadata (800k->809k for the feature-heavy windows crate), but not enough to really matter.
2023-06-01Rename `impl_defaultness` to `defaultness`Deadbeef-7/+7
2023-05-31Auto merge of #111913 - oli-obk:valtrees2, r=lcnrbors-1/+1
Only rewrite valtree-constants to patterns and keep other constants opaque Now that we can reliably fall back to comparing constants with `PartialEq::eq` to the match scrutinee, we can 1. eagerly try to convert constants to valtrees 2. then deeply convert the valtree to a pattern 3. if the to-valtree conversion failed, create an "opaque constant" pattern. This PR specifically avoids any behavioral changes or major cleanups. What we can now do as follow ups is * move the two remaining call sites to `destructure_mir_constant` off that query * make valtree to pattern conversion infallible * this needs to be done after careful analysis of the effects. There may be user visible changes from that. based on https://github.com/rust-lang/rust/pull/111768
2023-05-31Auto merge of #111076 - ↵bors-13/+38
notriddle:notriddle/silence-private-dep-trait-impl-suggestions, r=cjgillot diagnostics: exclude indirect private deps from trait impl suggest Fixes #88696
2023-05-30Lower the tracing level of some very verbose messagesOli Scherer-1/+1
2023-05-30Rollup merge of #112060 - lcnr:early-binder, r=jackh726Nilstrieb-2/+2
`EarlyBinder::new` -> `EarlyBinder::bind` for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR. r? `@jackh726` `@kylematsuda`
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-2/+2
2023-05-29Auto merge of #111329 - jyn514:metadata-ice, r=bjorn3bors-33/+63
Load only the crate header for `locator::crate_matches` Previously, we used the following info to determine whether to load the crate: 1. The METADATA_HEADER, which includes a METADATA_VERSION constant 2. The embedded rustc version 3. Various metadata in the `CrateRoot`, including the SVH This worked ok most of the time. Unfortunately, when building locally the rustc version is always the same because `omit-git-hash` is on by default. That meant that we depended only on 1 and 3, and we are not very good about bumping METADATA_VERSION (it's currently at 7) so in practice we were only depending on 3. `CrateRoot` is a very large struct and changes somewhat regularly, so this led to a steady stream of crashes from trying to load it. Change the logic to add an intermediate step between 2 and 3: introduce a new `CrateHeader` struct that contains only the minimum info needed to decide whether the crate should be loaded or not. That avoids having to load all of `CrateRoot`, which in practice means we should crash much less often. Note that this works because the SVH should be different between any two dependencies, even if the compiler has changed, because we use `-Zbinary-dep-depinfo` in bootstrap. See https://github.com/rust-lang/rust/pull/111329#issuecomment-1538303474 for more details about how the original crash happened.