about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
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
2025-04-03Auto merge of #139234 - compiler-errors:query-tweak, r=oli-obkbors-6/+3
Misc query tweaks Remove some redundant work around `cache_on_disk` and `ensure_ok`, since `Result<(), ErrorGuaranteed>` queries don't need to cache or recompute their "value" if they are only used for their result.
2025-04-03hygiene: Avoid recursion in syntax context decodingVadim Petrochenkov-1/+2
2025-04-02Rollup merge of #139232 - nnethercote:remove-Map-5, r=ZalatharTakayuki Maeda-2/+2
Move methods from `Map` to `TyCtxt`, part 5. This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR. A follow-up to #137504. r? `@Zalathar`
2025-04-02ensure_ok().query doesn't need cache_on_diskMichael Goulet-2/+0
2025-04-02Use return_result_from_ensure_ok a bit moreMichael Goulet-2/+3
2025-04-02cache_on_disk_if false is a noopMichael Goulet-2/+0
2025-04-02Move methods from `Map` to `TyCtxt`, part 5.Nicholas Nethercote-2/+2
This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.
2025-04-01Decouple trait impls of different traits wrt incrementalOli Scherer-0/+5
2025-03-30Revert "Auto merge of #129827 - bvanjoi:less-decoding, r=petrochenkov"Jakub Beránek-5/+5
Reverting because of a performance regression. This reverts commit d4812c8638173ec163825d56a72a33589483ec4c, reversing changes made to 5cc60728e7ee10eb2ae5f61f7d412d9805b22f0c.
2025-03-29less decoding if it has the same syntax contextbohan-5/+5
2025-03-27Rollup merge of #138672 - Zoxc:deferred-queries-in-deadlock-handler, r=oli-obkStuart Cook-2/+4
Avoiding calling queries when collecting active queries This PR changes active query collection to no longer call queries. Instead the fields needing queries have their computation delayed to when an cycle error is emitted or when printing the query backtrace in a panic. This is done by splitting the fields in `QueryStackFrame` needing queries into a new `QueryStackFrameExtra` type. When collecting queries `QueryStackFrame` will contain a closure that can create `QueryStackFrameExtra`, which does make use of queries. Calling `lift` on a `QueryStackFrame` or `CycleError` will convert it to a variant containing `QueryStackFrameExtra` using those closures. This also only calls queries needed to collect information on a cycle errors, instead of information on all active queries. Calling queries when collecting active queries is a bit odd. Calling queries should not be done in the deadlock handler at all. This avoids the out of memory scenario in https://github.com/rust-lang/rust/issues/124901.
2025-03-26Add `TyCtx::env_var_os`Mads Marquart-0/+35
Along with `TyCtx::env_var` helper. These can be used to track environment variable accesses in the query system. Since `TyCtx::env_var_os` uses `OsStr`, this commit also adds the necessary trait implementations for that to work.
2025-03-26Avoiding calling queries when collecting active queriesJohn Kåre Alsaker-2/+4
2025-03-20Rollup merge of #138685 - ↵Matthias Krüger-1/+1
nnethercote:use-Option-Ident-for-lowered-param-names, r=compiler-errors Use `Option<Ident>` for lowered param names. Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`. - If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type. - If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs. This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases. Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing. r? ``@compiler-errors``
2025-03-19Auto merge of #122156 - Zoxc:side-effect-dep-node, r=oli-obkbors-31/+15
Represent diagnostic side effects as dep nodes This changes diagnostic to be tracked as a special dep node (`SideEffect`) instead of having a list of side effects associated with each dep node. `SideEffect` is always red and when forced, it emits the diagnostic and marks itself green. Each emitted diagnostic generates a new `SideEffect` with an unique dep node index. Some implications of this: - Diagnostic may now be emitted more than once as they can be emitted once when the `SideEffect` gets marked green and again if the task it depends on needs to be re-executed due to another node being red. It relies on deduplicating of diagnostics to avoid that. - Anon tasks which emits diagnostics will no longer *incorrectly* be merged with other anon tasks. - Reusing a CGU will now emit diagnostics from the task generating it.
2025-03-19Use `Option<Ident>` for lowered param names.Nicholas Nethercote-1/+1
Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`. - If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type. - If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs. This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases. Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing.
2025-03-15Move codec module back into middleMichael Goulet-4/+2
2025-03-14Rename `QuerySideEffects` to `QuerySideEffect`John Kåre Alsaker-15/+15
2025-03-14Represent diagnostic side effects as dep nodesJohn Kåre Alsaker-18/+2
2025-03-13Rollup merge of #138109 - Kohei316:feat/rust-doc-precise-capturing-arg, ↵Matthias Krüger-2/+2
r=aDotInTheVoid,compiler-errors make precise capturing args in rustdoc Json typed close #137616 This PR includes below changes. - Add `rustc_hir::PreciseCapturingArgKind` which allows the query system to return a arg's data. - Add `rustdoc::clean::types::PreciseCapturingArg` and change to use it. - Add `rustdoc-json-types::PreciseCapturingArg` and change to use it. - Update `tests/rustdoc-json/impl-trait-precise-capturing.rs`. - Bump `rustdoc_json_types::FORMAT_VERSION`.
2025-03-12Rename `hir_attrs` query as `hir_attr_map`.Nicholas Nethercote-1/+1
To make room for the moving of `Map::attrs` to `TyCtxt::hir_attrs` in the next commit. (It makes sense to rename the query, because it has many fewer uses than the method.)
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+2
2025-03-10make precise capturing args in rustdoc Json typedmorine0122-2/+2
2025-03-09Auto merge of #137695 - nnethercote:always-inline-query_get_at, r=saethlinbors-1/+1
Always inline `query_get_at`. r? `@saethlin`
2025-03-09Rollup merge of #138160 - jdonszelmann:move-find-attr2, r=oli-obkMatthias Krüger-8/+8
depend more on attr_data_structures and move find_attr! there r? ``@oli-obk`` This should be an easy one. It just moves some imports around. This is necessary for other changes that I'm working on not to have import cycles. However, it's an easy one to just merge on its own.
2025-03-09Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, ↵Matthias Krüger-3/+3
r=compiler-errors compiler: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. Apply this change across the compiler. These functions were added to all preludes in Rust 1.80. r? ``@compiler-errors``
2025-03-09Rollup merge of #136968 - oli-obk:bye-bye, r=compiler-errorsMatthias Krüger-6/+0
Turn order dependent trait objects future incompat warning into a hard error fixes #56484 r? ``@ghost`` will FCP when we have a crater result
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-3/+3
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-07Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakisMatthias Krüger-0/+5
Ergonomic ref counting This is an experimental first version of ergonomic ref counting. This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations. RFC: https://github.com/rust-lang/rfcs/pull/3680 Tracking issue: https://github.com/rust-lang/rust/issues/132290 Project goal: https://github.com/rust-lang/rust-project-goals/issues/107 r? ```@nikomatsakis```
2025-03-07depend more on attr_data_structures and move find_attr! thereJana Dönszelmann-8/+8
2025-03-06Account for UseCloned on expr_use_visitorSantiago Pastorino-0/+5
2025-03-04Only use implied bounds hack if bevy, and use deeply normalize in implied ↵Michael Goulet-11/+10
bounds hack
2025-03-01Update `const_conditions` and `explicit_implied_const_bounds` docsDeadbeef-0/+14
Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`.
2025-02-28Rollup merge of #137780 - samueltardieu:push-kxorztnkqnsz, r=lcnr许杰友 Jieyou Xu (Joe)-1/+1
Fix typo in query expansion documentation
2025-02-28Fix typo in query expansion documentationSamuel Tardieu-1/+1
2025-02-27Fix method name in `TyCtxt::hir_crate()` documentationSamuel Tardieu-3/+3
2025-02-27Always inline `query_get_at`.Nicholas Nethercote-1/+1