summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2023-08-16Auto merge of #114536 - cjgillot:eval-lint-levels, r=TaKO8Kibors-1/+0
Do not mark shallow_lint_levels_on as eval_always. It does not need it. Removing it allows to skip recomputation.
2023-08-15Rollup merge of #114772 - fee1-dead-contrib:typed-did, r=b-naberGuillaume Gomez-16/+74
Add `{Local}ModDefId` to more strongly type DefIds` Based on #110862 by `@Nilstrieb`
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-16/+74
2023-08-13Remove metadata_loader querybjorn3-6/+0
It is only used by CrateLoader. We can store the metadata loader in CStore instead which CrateLoader has access to.
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-1/+1
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-1/+1
2023-08-06Do not mark shallow_lint_levels_on as eval_always.Camille GILLOT-1/+0
2023-08-05parent_module_from_def_id does not need to be a query.Camille GILLOT-5/+0
2023-08-04Querify clashing_extern_declarations lint.Camille GILLOT-0/+5
2023-08-03Compute variances for lazy type aliasesLeón Orell Valerian Liehr-1/+1
2023-08-01Convert adt_sized_constraint to early-binder, use listMichael Goulet-1/+1
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-1/+1
2023-07-29Implement assumed_wf_types for RPITITs' implementationsMichael Goulet-0/+7
2023-07-24Auto merge of #113956 - fmease:rustdoc-fix-x-crate-rpitits, ↵bors-2/+2
r=GuillaumeGomez,compiler-errors rustdoc: handle cross-crate RPITITs correctly Filter out the internal associated types synthesized during the desugaring of RPITITs, they really shouldn't show up in the docs. This also fixes #113929 since we're no longer invoking `is_impossible_associated_item` (renamed from `is_impossible_method`) which cannot handle them (leading to an ICE). I don't think it makes sense to try to make `is_impossible_associated_item` handle this exotic kind of associated type (CC original author `@compiler-errors).` @ T-rustdoc reviewers, currently I'm throwing out ITIT assoc tys before cleaning assoc tys at each usage-site. I'm thinking about making `clean_middle_assoc_item` return an `Option<_>` instead and doing the check inside of it to prevent any call sites from forgetting the check for ITITs. Since I wasn't sure if you would like that approach, I didn't go through with it. Let me know what you think. <details><summary>Explanation on why <code>is_impossible_associated_item(itit_assoc_ty)</code> leads to an ICE</summary> Given the following code: ```rs pub trait Trait { fn def<T>() -> impl Default {} } impl Trait for () {} ``` The generated associated type looks something like (simplified): ```rs type {opaque#0}<T>: Default = impl Default; // the name is actually `kw::Empty` but this is the `def_path_str` repr ``` The query `is_impossible_associated_item` goes through all predicates of the associated item – in this case `<T as Sized>` – to check if they contain any generic parameters from the (generic) associated type itself. For predicates that don't contain any *own* generics, it does further processing, part of which is instantiating the predicate with the generic arguments of the impl block (which is only correct if they truly don't contain any own generics since they wouldn't get instantiated this way leading to an ICE). It checks if `parent_def_id(T) == assoc_ty_def_id` to get to know if `T` is owned by the assoc ty. Unfortunately this doesn't work for ITIT assoc tys. In this case, the parent of `T` is `Trait::def` (!) which is the associated function (I'm pretty sure this is very intentional) which is of course not equal to the assoc ty `Trait::{opaque#0}`. </details> `@rustbot` label A-cross-crate-reexports
2023-07-22rustdoc: handle cross-crate RPITITs correctlyLeón Orell Valerian Liehr-2/+2
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-23/+0
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Add doc-comments for `NaiveLayout`Moulins-2/+3
2023-07-21add crate-local `-Z reference_niches` unstable flag (does nothing for now)Moulins-0/+6
2023-07-21add `naive_layout_of` queryMoulins-0/+16
2023-07-20Auto merge of #113546 - cjgillot:unused-query, r=compiler-errorsbors-0/+4
Querify unused trait check. This code transitively loads information for all bodies, and from resolutions. As it does not return a value, it should be beneficial to have it as a query.
2023-07-19Rollup merge of #113754 - cjgillot:simplify-foreign, r=petrochenkovDylan DPC-1/+1
Simplify native_libs query Drive-by cleanup I saw while implementing https://github.com/rust-lang/rust/pull/113734
2023-07-17Do not fetch HIR in native_libs.Camille GILLOT-1/+1
2023-07-17Auto merge of #113562 - saethlin:larger-incr-comp-offset, r=nnethercotebors-2/+4
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-17Remove `instance_def_size_estimate` query.Nicholas Nethercote-6/+0
It doesn't seem worthwhile now that `MonoItem::size_estimate` is called much less often.
2023-07-16Querify unused trait check.Camille GILLOT-0/+4
2023-07-14Use u64 for incr comp allocation offsetsBen Kimock-2/+4
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-16/+16
2023-07-06get rid of a bit more calls to poly_selectMichael Goulet-3/+3
2023-07-05Name the destructure_mir_constant query appropriatelyOli Scherer-1/+1
2023-07-05Specialize `try_destructure_mir_constant` for its sole userOli Scherer-2/+13
2023-07-05Don't require associated types with `Self: Sized` bounds in `dyn Trait` objectsOli Scherer-0/+4
2023-07-03Remove chalk from the compilerMichael Goulet-12/+2
2023-07-03use `deeply_normalize` for `assumed_wf_types`lcnr-1/+1
2023-07-01Put `FnAbiError` behind reference to shrink resultNilstrieb-4/+4
The `FnAbi` is just a pointer, so the error type should not be bigger.
2023-07-01Put `LayoutError` behind reference to shrink resultNilstrieb-6/+8
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's shrink that.
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-12/+5
2023-06-22migrate inferred_outlives_of to ClauseMichael Goulet-8/+1
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-2/+9
2023-06-21Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnrNilstrieb-3/+3
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-0/+17
2023-06-19s/Clause/ClauseKindMichael Goulet-3/+3
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-0/+10
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-07Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkovbors-1/+10
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-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-1/+10
`#[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-2/+3
2023-05-31Remove `lit_to_mir_constant` queryOli Scherer-4/+0
2023-05-31Remove `deref_mir_constant`Oli Scherer-8/+0
2023-05-24Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, ↵Matthias Krüger-9/+11
r=compiler-errors Rename `traits_in_crate` query to `traits` > NOTE: Not named just `traits` due to a naming conflict. This can, in fact, be easily avoided.
2023-05-23Rename `traits_in_crate` query to `traits`Maybe Waffle-9/+11
2023-05-21Replace `QueryStruct` with arrays local to `rustc_query_impl`John Kåre Alsaker-13/+3