about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2025-07-18Auto merge of #143845 - cjgillot:stability-query, r=jieyouxubors-6/+13
Split-up stability_index query This PR aims to move deprecation and stability processing away from the monolithic `stability_index` query, and directly implement `lookup_{deprecation,stability,body_stability,const_stability}` queries. The basic idea is to: - move per-attribute sanity checks into `check_attr.rs`; - move attribute compatibility checks into the `MissingStabilityAnnotations` visitor; - progressively dismantle the `Annotator` visitor and the `stability_index` query. The first commit contains functional change, and now warns when `#[automatically_derived]` is applied on a non-trait impl block. The other commits should not change visible behaviour. Perf in https://github.com/rust-lang/rust/pull/143845#issuecomment-3066308630 shows small but consistent improvement, except for unused-warnings case. That case being a stress test, I'm leaning towards accepting the regression. This PR changes `check_attr`, so has a high conflict rate on that file. This should not cause issues for review.
2025-07-18Auto merge of #144109 - matthiaskrgr:rollup-mz0mrww, r=matthiaskrgrbors-0/+9
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142300 (Disable `tests/run-make/mte-ffi` because no CI runners have MTE extensions enabled) - rust-lang/rust#143271 (Store the type of each GVN value) - rust-lang/rust#143293 (fix `-Zsanitizer=kcfi` on `#[naked]` functions) - rust-lang/rust#143719 (Emit warning when there is no space between `-o` and arg) - rust-lang/rust#143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - rust-lang/rust#143891 (Port `#[coverage]` to the new attribute system) - rust-lang/rust#143967 (constify `Option` methods) - rust-lang/rust#144008 (Fix false positive double negations with macro invocation) - rust-lang/rust#144010 (Boostrap: add warning on `optimize = false`) - rust-lang/rust#144049 (rustc-dev-guide subtree update) - rust-lang/rust#144056 (Copy GCC sources into the build directory even outside CI) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-18Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errorsMatthias Krüger-0/+9
fix `-Zsanitizer=kcfi` on `#[naked]` functions fixes https://github.com/rust-lang/rust/issues/143266 With `-Zsanitizer=kcfi`, indirect calls happen via generated intermediate shim that forwards the call. The generated shim preserves the attributes of the original, including `#[unsafe(naked)]`. The shim is not a naked function though, and violates its invariants (like having a body that consists of a single `naked_asm!` call). My fix here is to match on the `InstanceKind`, and only use `codegen_naked_asm` when the instance is not a `ReifyShim`. That does beg the question whether there are other `InstanceKind`s that could come up. As far as I can tell the answer is no: calling via `dyn` seems to work find, and `#[track_caller]` is disallowed in combination with `#[naked]`. r? codegen ````@rustbot```` label +A-naked cc ````@maurer```` ````@rcvalle````
2025-07-17Retire stability_index query.Camille GILLOT-6/+13
2025-07-16use `codegen_instance_attrs` where an instance is (easily) availableFolkert de Vries-0/+9
2025-07-15Deduce outlives obligations from WF of coroutine interior typesMichael Goulet-1/+1
2025-07-15Define datastructures for `#[cfg]` attribute, move StrippedCfgItemJonathan Brouwer-1/+1
2025-07-12Clean up implementation of RPITIT assoc item loweringMichael Goulet-2/+4
2025-07-13query RPITIT in a trait or implbohan-14/+2
2025-07-13compute all rpitit of a traitbohan-0/+6
2025-07-07Add `ty_span` queryOli Scherer-0/+7
2025-07-04Remove names_imported_by_glob_use query.Camille GILLOT-3/+0
2025-07-04Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkovbors-1/+0
Avoid depending on forever-red DepNode when encoding metadata. Split from https://github.com/rust-lang/rust/pull/114669 for perf r? `@petrochenkov`
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-1/+1
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-07-02Auto merge of #143338 - matthiaskrgr:rollup-ykaxh04, r=matthiaskrgrbors-1/+0
Rollup of 11 pull requests Successful merges: - rust-lang/rust#131923 (Derive `Copy` and `Hash` for `IntErrorKind`) - rust-lang/rust#138340 (Remove some unsized tuple impls now that we don't support unsizing tuples anymore) - rust-lang/rust#141219 (Change `{Box,Arc,Rc,Weak}::into_raw` to only work with `A = Global`) - rust-lang/rust#142212 (bootstrap: validate `rust.codegen-backends` & `target.<triple>.codegen-backends`) - rust-lang/rust#142237 (Detect more cases of unused_parens around types) - rust-lang/rust#142964 (Attribute rework: a parser for single attributes without arguments) - rust-lang/rust#143070 (Rewrite `macro_rules!` parser to not use the MBE engine itself) - rust-lang/rust#143235 (Assemble const bounds via normal item bounds in old solver too) - rust-lang/rust#143261 (Feed `explicit_predicates_of` instead of `predicates_of`) - rust-lang/rust#143276 (loop match: handle opaque patterns) - rust-lang/rust#143306 (Add `track_caller` attributes to trace origin of Clippy lints) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various
2025-07-02Rollup merge of #143261 - compiler-errors:explicit-pred, r=oli-obkMatthias Krüger-1/+0
Feed `explicit_predicates_of` instead of `predicates_of` Tiny nitpick, just avoiding needing to mark the `predicates_of` query as feedable since it's derived from `explicit_predicates_of`.
2025-07-02Rollup merge of #143258 - compiler-errors:disambiguator-state, r=oli-obkMatthias Krüger-7/+0
Don't recompute `DisambiguatorState` for every RPITIT in trait definition The `associated_type_for_impl_trait_in_trait` currently needs to rerun the `RPITVisitor` for every RPITIT to compute its disambiguator. Instead of synthesizing all of the RPITITs def ids one at a time in different queries, just synthesize them inside of the `associated_types_for_impl_traits_in_associated_fn` query. There we can just share the same `DisambiguatorState` for all the RPITITs in one function signature. r? ``````@Zoxc`````` or ``````@oli-obk`````` cc rust-lang/rust#140453
2025-07-02Hash resolutions.Camille GILLOT-1/+0
2025-07-01Auto merge of #143013 - bjorn3:split_exported_symbols, r=oli-obkbors-6/+25
Split exported_symbols for generic and non-generic symbols This reduces metadata decoder overhead during the monomorphization collector.
2025-07-01Auto merge of #143267 - matthiaskrgr:rollup-suvzar6, r=matthiaskrgrbors-0/+6
Rollup of 8 pull requests Successful merges: - rust-lang/rust#143125 (Disable f16 on Aarch64 without neon for llvm < 20.1.1) - rust-lang/rust#143156 (inherit `#[align]` from trait method prototypes) - rust-lang/rust#143178 (rustdoc default faviocon) - rust-lang/rust#143234 (Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`) - rust-lang/rust#143245 (mbe: Add tests and restructure metavariable expressions) - rust-lang/rust#143257 (Upgrade dependencies in run-make-support) - rust-lang/rust#143263 (linkify CodeSuggestion in doc comments) - rust-lang/rust#143264 (fix: Emit suggestion filename if primary diagnostic span is dummy) Failed merges: - rust-lang/rust#143251 (bootstrap: add build.tidy-extra-checks option) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-01Rollup merge of #143156 - folkertdev:fn-align-inherit-from-trait, ↵Matthias Krüger-0/+6
r=workingjubilee inherit `#[align]` from trait method prototypes ````@workingjubilee```` this seems straightforward enough. Now that we're planning to make `-Cmin-function-alignment` a target modifier, I don't think there are any cross-crate complications here? ````@Jules-Bertholet```` is this the behavior you had in mind? In particular the inheritance of the attribute of a default impl is maybe a bit unintuitive at first? (but I think it's ok if that behavior is explicitly documented). r? ghost
2025-07-01Feed explicit_predicates_of instead of predicates_ofMichael Goulet-1/+0
2025-06-30Don't recompute DisambiguatorState for every RPITIT in trait definitionMichael Goulet-7/+0
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-51/+78
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-29inherit `#[align]` from trait method prototypesFolkert de Vries-0/+6
2025-06-28Auto merge of #142625 - cjgillot:inline-nocycle, r=oli-obkbors-6/+6
Only compute recursive callees once. Inlining MIR in a cyclic call graph may create query cycles, which are ICEs. The current implementation `mir_callgraph_reachable(inlining_candidate, being_optimized)` checks if calling `inlining_candidate` may cycle back to `being_optimized` that we are currently inlining into. This PR replaces this device with query `mir_callgraph_cyclic(being_optimized)` which searches the call graph for all cycles going back to `being_optimized`, and returns the set of functions involved in those cycles. This is a tradeoff: - in the current implementation, we perform more walks, but shallower; - in this new implementation, we perform fewer walks, but exhaust the graph. I'd have liked to compute this using some kind of SCC, but generic parameters make resolution path-dependent, so usual graph algorithms do not apply.
2025-06-27Rollup merge of #143096 - RalfJung:tag_for_variant, r=compiler-errorsMatthias Krüger-1/+1
tag_for_variant: properly pass TypingEnv Hard-coding `fully_monomorphized` here does not seem right... This came up [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20VariantId.3DDiscriminant.20when.20tag.20is.20niche.20encoded.3F/with/526103956).
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-7/+7
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27tag_for_variant: properly pass TypingEnvRalf Jung-1/+1
2025-06-27Split exported_symbols for generic and non-generic symbolsbjorn3-6/+25
This reduces metadata decoder overhead during the monomorphization collector.
2025-06-26const-eval: allow constants to refer to mutable/external memory, but reject ↵Ralf Jung-4/+3
such constants as patterns
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-7/+7
2025-06-23Only store the LocalDefId instead of the whole instance.Camille GILLOT-1/+1
2025-06-22Cache queries.Camille GILLOT-0/+1
2025-06-22Only compute recursive callees once.Camille GILLOT-6/+5
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