summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2025-06-18Rollup merge of #142619 - klensy:or_fun_call, r=nnethercoteJakub Beránek-1/+1
apply clippy::or_fun_call Applies https://rust-lang.github.io/rust-clippy/master/index.html?groups=nursery#or_fun_call to reduce needless allocs.
2025-06-17Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obkbors-5/+14
Sized Hierarchy: Part I This patch implements the non-const parts of rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`. See the RFC for the rationale behind these traits and to discuss whether this change makes sense in the abstract. These traits are unstable (as is their constness), so users cannot refer to them without opting-in to `feature(sized_hierarchy)`. These traits are not behind `cfg`s as this would make implementation unfeasible, there would simply be too many `cfg`s required to add the necessary bounds everywhere. So, like `Sized`, these traits are automatically implemented by the compiler. RFC 3729 describes changes which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows: - `?Sized` is rewritten as `MetaSized` - `MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already. There are no edition migrations implemented in this, as these are primarily required for the constness parts of the RFC and prior to stabilisation of this (and so will come in follow-up PRs alongside the const parts). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `MetaSized`) unless the `sized_hierarchy` feature is enabled. Due to the use of unstable extern types in the standard library and rustc, some bounds in both projects have had to be relaxed already - this is unfortunate but unavoidable so that these extern types can continue to be used where they were before. Performing these relaxations in the standard library and rustc are desirable longer-term anyway, but some bounds are not as relaxed as they ideally would be due to the inability to relax `Deref::Target` (this will be investigated separately). It is hoped that this is implemented such that it could be merged and these traits could exist "under the hood" without that being observable to the user (other than in any performance impact this has on the compiler, etc). Some details might leak through due to the standard library relaxations, but this has not been observed in test output. **Notes:** - Any commits starting with "upstream:" can be ignored, as these correspond to other upstream PRs that this is based on which have yet to be merged. - This best reviewed commit-by-commit. I've attempted to make the implementation easy to follow and keep similar changes and test output updates together. - Each commit has a short description describing its purpose. - This patch is large but it's primarily in the test suite. - I've worked on the performance of this patch and a few optimisations are implemented so that the performance impact is neutral-to-minor. - `PointeeSized` is a different name from the RFC just to make it more obvious that it is different from `std::ptr::Pointee` but all the names are yet to be bikeshed anyway. - `@nikomatsakis` has confirmed [that this can proceed as an experiment from the t-lang side](https://rust-lang.zulipchat.com/#narrow/channel/435869-project-goals/topic/SVE.20and.20SME.20on.20AArch64.20.28goals.23270.29/near/506196491) - FCP in https://github.com/rust-lang/rust/pull/137944#issuecomment-2912207485 Fixes rust-lang/rust#79409. r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
2025-06-17apply clippy::or_fun_callklensy-1/+1
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `?Sized` typesDavid Wood-5/+14
Expand the automatic implementation of `MetaSized` and `PointeeSized` so that it is also implemented on non-`Sized` types, just not `ty::Foreign` (extern type).
2025-06-16Add documentation on top of `rustc_middle/src/query/mod.rs`xizheyin-4/+60
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-12introduce new lint infraJana Dönszelmann-0/+8
lint on duplicates during attribute parsing To do this we stuff them in the diagnostic context to be emitted after hir is constructed
2025-06-11Rollup merge of #142306 - compiler-errors:nit-reveal-param-env-query, r=lcnrMatthias Krüger-1/+2
Dont unwrap and re-wrap typing envs Just a tiny tweak to make the query less awkward. r? lcnr
2025-06-10Dont unwrap and re-wrap typing envsMichael Goulet-1/+2
2025-06-10Remove check_mod_loops query and run the checks per-body insteadOli Scherer-5/+0
2025-06-06Auto merge of #141774 - oli-obk:naked-fn-queries, r=petrochenkovbors-4/+0
Change per-module naked fn checks to happen during typeck instead cc `@Lokathor` `@Amanieu` `@folkertdev` just seems nicer this way
2025-06-03Run wfcheck in one big loop instead of per moduleOli Scherer-2/+2
2025-06-01Optionally don't steal the THIRNadrieril-1/+2
2025-05-30Change a per-module query to just run on the items it internally filters forOli Scherer-4/+0
2025-05-27Refactor the two-phase check for impls and impl itemsMu001999-1/+1
2025-05-23Auto merge of #140553 - BoxyUwU:defer_type_system_ctfe, r=compiler-errorsbors-0/+6
Defer evaluating type system constants when they use infers or params Split out of #137972, the parts necessary for associated const equality and min generic const args to make progress and have correct semantics around when CTFE is invoked. According to a [previous perf run](https://perf.rust-lang.org/compare.html?start=93257e2d20809d82d1bc0fcc1942480d1a66d7cd&end=01b4cbf0f47c3f782330db88fa5ba199bba1f8a2&stat=instructions:u) of adding the new `const_arg_kind` query we should expect minor regressions here. I think this is acceptable as we should be able to remove this query relatively soon once mgca is more complete as we'll then be able to implement GCE in terms of mgca and rip out `GCEConst` at which point it's trivial to determine what kind of anon const we're dealing with (either it has generics and is a repeat expr hack, or it doesnt and is a normal anon const). This should only affect unstable code as we handle repeat exprs specially and those are the only kinds of type system consts that are allowed to make use of generic parameters. Fixes #133066 Fixes #133199 Fixes #136894 Fixes #137813 r? compiler-errors
2025-05-22Review CommentsBoxy-1/+0
2025-05-21Introduce `tcx.anon_const_kind` queryBoxy-0/+7
2025-05-20Querify coroutine_hidden_typesMichael Goulet-1/+12
2025-05-07Auto merge of #140590 - lcnr:closure-in-dead-code, r=compiler-errorsbors-1/+1
borrowck nested items in dead code fixes https://github.com/rust-lang/rust/issues/140583 r? `@compiler-errors`
2025-05-06Auto merge of #131160 - ↵bors-3/+3
ismailarilik:handle-potential-query-instability-lint-for-rustc-middle, r=oli-obk Handle `rustc_middle` cases of `rustc::potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_middle/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L29) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447 r? `@compiler-errors`
2025-05-05Handle rustc_middle cases of rustc::potential_query_instability lintismailarilik-3/+3
2025-05-05Rename Instance::new to Instance::new_raw and add a note that it is rawMichael Goulet-1/+1
2025-05-04Initial support for dynamically linked cratesBryanskiy-0/+10
2025-05-02borrowck nested items in dead codelcnr-1/+1
2025-04-29Reformat parameters to macros used by with-all-queriesZalathar-2/+5
2025-04-29Rename `rustc_query_append!` to `rustc_with_all_queries!`Zalathar-1/+1
2025-04-28Auto merge of #140388 - GuillaumeGomez:rollup-aj9o3ch, r=GuillaumeGomezbors-3/+3
Rollup of 7 pull requests Successful merges: - #140056 (Fix a wrong error message in 2024 edition) - #140220 (Fix detection of main function if there are expressions around it) - #140249 (Remove `weak` alias terminology) - #140316 (Introduce `BoxMarker` to improve pretty-printing correctness) - #140347 (ci: clean more disk space in codebuild) - #140349 (ci: use aws codebuild for the `dist-x86_64-linux` job) - #140379 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-1/+17
async_drop_in_place::{closure}, scoped async drop added.
2025-04-24Remove `weak` alias terminologyBoxy-3/+3
2025-04-23MoreMichael Goulet-3/+3
2025-04-22Properly drain pending obligations for coroutinesMichael Goulet-2/+11
2025-04-15Rollup merge of #139772 - nnethercote:rm-hir-Map, r=ZalatharStuart Cook-8/+8
Remove `hir::Map` A follow-up to https://github.com/rust-lang/rust/pull/139232. r? `@Zalathar`
2025-04-14Documentation fixes.Nicholas Nethercote-8/+8
Remove old references to the HIR map.
2025-04-12don't store opaque info during encodingbohan-3/+2
2025-04-11Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-deadStuart Cook-6/+6
Allow drivers to supply a list of extra symbols to intern Allows adding new symbols as `const`s in external drivers, desirable in Clippy so we can use them in patterns to replace code like https://github.com/rust-lang/rust/blob/75530e9f72a1990ed2305e16fd51d02f47048f12/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs#L66 The Clippy change adds a couple symbols as a demo, the exact `clippy_utils` API and replacing other usages can be done on the Clippy side to minimise sync conflicts --- try-job: aarch64-gnu
2025-04-10Rollup merge of #139510 - nnethercote:name-to-ident, r=fee1-deadMatthias Krüger-2/+2
Rename some `name` variables as `ident`. It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk. r? `@fee1-dead`
2025-04-10Rollup merge of #139502 - yaahc:still-mutable-ice, r=bjorn3Matthias Krüger-0/+5
fix "still mutable" ice while metrics are enabled Resolves "still mutable" ICE discovered by `@matthiaskrgr` here: [#t-docs-rs > metrics intitiative @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/356853-t-docs-rs/topic/metrics.20intitiative/near/510490790) This was caused by invoking `crate_hash` before the `definitions` struct was frozen here: https://github.com/rust-lang/rust/blob/e643f59f6da3a84f43e75dea99afaa5b041ea6bf/compiler/rustc_interface/src/passes.rs#L951 resolved by moving metrics dumping to occur after `analysis` freezes the definitions I'm guessing we didn't discover this in CI because the problem only occurs when you try to calculate the crash hash with incremental compilation enabled when it tries to freeze the definitions here: https://github.com/rust-lang/rust/blob/e643f59f6da3a84f43e75dea99afaa5b041ea6bf/compiler/rustc_middle/src/hir/map.rs#L1172 my understanding is that this causes us to freeze the definitions too early in compilation, then we subsequently try to mutate them, likely during `analysis`, and this causes the ICE. r? `@bjorn3`
2025-04-10Allow drivers to supply a list of extra symbols to internAlex Macleod-6/+6
2025-04-10Auto merge of #139000 - compiler-errors:rigid-missing-item, r=lcnrbors-0/+7
Rigidly project missing item due to guaranteed impossible sized predicate This is a somewhat involved change, but it amounts to treating missing impl items due to guaranteed impossible where clauses (dyn/str/slice sized, cc #135480) as *rigid projections* rather than projecting to an error term, since that was preventing either reporting a proper error (in an empty param env) *or* successfully type checking the code (in the presence of trivially false where clauses). Fixes https://github.com/rust-lang/rust/issues/138970 r? `@lcnr` `@oli-obk`
2025-04-10Address review comments.Nicholas Nethercote-1/+1
2025-04-10Rename some `name` variables as `ident`.Nicholas Nethercote-2/+2
It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.
2025-04-09Use a query rather than recomputing the tail repeatedlyMichael Goulet-0/+7
2025-04-09update cfgsBoxy-2/+2
2025-04-08fix "still mutable" ice while metrics are enabledJane Losare-Lusby-0/+5
2025-04-08Auto merge of #138499 - lcnr:borrowck-typeck_root, r=oli-obkbors-4/+3
borrowck typeck children together with their root This introduces new cycle errors, even with `feature(inline_const_pat)` removed, see the `non-structural-match-types-cycle-err.rs` test. The new cycle error happens as the layout of `async`-blocks relies on their `optimized_mir`. As that now depends on `mir_borrowck` of its typeck parent, computing the layout of an `async`-block during MIR building, e.g. when evaluating a named `const` pattern. I think there's currently no way to have a named const pattern whose type references an async block while being allowed? cc `@oli-obk` `@RalfJung` I cannot think of other cases where we currently rely on the MIR of a typeck children while borrowchecking their parent. The crater run came back without any breakage. My work here will prevent any future features which rely on this as we'll get locked into borrowchecking them together as I continue to work on https://github.com/rust-lang/types-team/issues/129, cc `@rust-lang/types.` r? compiler-errors
2025-04-08borrowck typeck children together with their parentlcnr-4/+3
2025-04-07Auto merge of #133781 - cjgillot:shallow-allowed-lints, r=petrochenkovbors-1/+1
Do not visit whole crate to compute `lints_that_dont_need_to_run`. This allows to reuse the computed lint levels instead of re-visiting the whole crate.
2025-04-05Auto merge of #139281 - petrochenkov:ctxtdecod6, r=wesleywiserbors-1/+2
hygiene: Avoid recursion in syntax context decoding #139241 has two components - Avoiding recursion during syntax context decoding - Encoding/decoding only the non-redundant data, and recalculating the redundant data again during decoding Both of these parts may influence compilation times, possibly in opposite directions. So this PR contains only the first part to evaluate its effect in isolation.
2025-04-04Do not visit whole crate to compute `lints_that_dont_need_to_run`.Camille GILLOT-1/+1
2025-04-03add `TypingMode::Borrowck`lcnr-0/+8