about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-04-02Invalidate all dereferences for non-local assignmentsdianqk-8/+32
2025-04-02`next_opaque` is no longer an `Option`dianqk-37/+32
2025-04-02Do not use `for_each_assignment_mut` to iterate over assignment statementsdianqk-78/+37
`for_each_assignment_mut` can skip assignment statements with side effects, which can result in some assignment statements retrieving outdated value. For example, it may skip a dereference assignment statement.
2025-04-02Auto merge of #139018 - oli-obk:incremental-trait-impls, r=compiler-errorsbors-86/+91
Various local trait item iteration cleanups Adding a trait impl for `Foo` unconditionally affected all queries that are interested in a completely independent trait `Bar`. Perf has no effect on this. We probably don't have a good perf test for this tho. r? `@compiler-errors` I am unsure about https://github.com/rust-lang/rust/pull/139018/commits/9d05efb66f7b599eeacb5d2456f844fe4768e865 as it doesn't improve anything wrt incremental, because we still do all the checks for valid `Drop` impls, which subsequently will still invoke many queries and basically keep the depgraph the same. I want to do https://github.com/rust-lang/rust/blob/9549077a47099dc826039c051b528d1013740e6f/compiler/rustc_middle/src/ty/trait_def.rs#L141 but would leave that to a follow-up PR, this one changes enough things as it is
2025-04-02Only walk local items instead of filtering for them laterOli Scherer-23/+19
2025-04-02Remove a function that has no necessary callersOli Scherer-15/+0
2025-04-02Remove a `hir_*` helper that was just forwarding to a queryOli Scherer-6/+2
2025-04-02Directly fetch the impl self typeOli Scherer-2/+2
2025-04-02Fetch the destructor constness lazilyOli Scherer-8/+6
2025-04-02Only look at trait impls in the current crate when looking for `Drop` implsOli Scherer-18/+30
2025-04-02Add a dep kind for use of the anon node with zero dependenciesJohn Kåre Alsaker-5/+21
2025-04-02Reduce scope of `AstValidator::with_*` calls.Nicholas Nethercote-91/+88
`AstValidator` has several `with_*` methods, each one setting a field that adjust how checking takes place for items within certain other items. E.g. `with_in_trait_impl` is used to adjust the checking done on items inside an `impl` item. Weirdly, the scopes used for most of the `with_*` calls are very broad, and include things that aren't "inside" the item, such as visibility, unsafety, and constness. This commit minimizes the scope of these `with_*` calls so they only apply to the things inside the item.
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-7/+8
2025-04-02cache_on_disk_if false is a noopMichael Goulet-2/+0
2025-04-02Auto merge of #139229 - Zalathar:rollup-5cs3f4d, r=Zalatharbors-189/+155
Rollup of 14 pull requests Successful merges: - #135295 (Check empty SIMD vector in inline asm) - #138003 (Add the new `amx` target features and the `movrs` target feature) - #138823 (rustc_target: RISC-V: add base `I`-related important extensions) - #138913 (Remove even more instances of `@ts-expect-error` from search.js) - #138941 (Do not mix normalized and unnormalized caller bounds when constructing param-env for `receiver_is_dispatchable`) - #139060 (replace commit placeholder in vendor status with actual commit) - #139102 (coverage: Avoid splitting spans during span extraction/refinement) - #139191 (small opaque type/borrowck cleanup) - #139200 (Skip suggest impl or dyn when poly trait is not a real trait) - #139208 (fix dead link netbsd.md) - #139210 (chore: remove redundant backtick) - #139212 (Update mdbook to 0.4.48) - #139214 (Tell rustfmt to use the 2024 edition in ./x.py fmt) - #139225 (move autodiff from EnzymeAD/Enzyme to our rust-lang/Enzyme soft-fork) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-02Rename span-related names in `AstValidator`.Nicholas Nethercote-36/+43
A bunch of span-related names in `AstValidator` don't end in `span`, which goes against the usual naming conventions and makes the code surprisingly hard to read. E.g. a name like `body` doesn't sound like it's a span. This commit adds `_span` suffixes.
2025-04-02Rollup merge of #139214 - bjorn3:edition_2024_rustfmt, r=compiler-errorsStuart Cook-8/+12
Tell rustfmt to use the 2024 edition in ./x.py fmt Most crates in this repo have been moved to the 2024 edition already. This also allows removing a rustfmt exclusion for a cg_clif test.
2025-04-02Rollup merge of #139200 - xizheyin:issue-139174, r=compiler-errorsStuart Cook-0/+1
Skip suggest impl or dyn when poly trait is not a real trait Fixes #139174 When `poly_trait_ref` is not a real trait, we should stop suggesting `impl` and `dyn` to avoid false positives. 3 cases were added to the ui test. https://github.com/rust-lang/rust/blob/0b45675cfcec57f30a3794e1a1e18423aa9cf200/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs#L88-L93 In the first commit, I submitted the test and passed it. In the second commit, I modified the code and we can see the changes in the test. r? compiler
2025-04-02Rollup merge of #139191 - lcnr:interner-opaques, r=compiler-errorsStuart Cook-61/+35
small opaque type/borrowck cleanup pulled out of #138785
2025-04-02Rollup merge of #139102 - Zalathar:no-split, r=oli-obkStuart Cook-89/+39
coverage: Avoid splitting spans during span extraction/refinement This PR removes or simplifies some of the steps involved in extracting coverage-relevant spans from MIR, and preparing them for use in coverage instrumentation metadata. A common theme is that we now try harder to avoid modifying or combining spans in non-trivial ways, because those modifications present the most risk for weird behaviour or ICEs. The main changes are: - When extracting spans from MIR call terminators, try to restrict them to just the function name. - Instead of splitting spans around “holes”, just discard any span that overlaps with a hole. - Instead of splitting macro-invocation spans into two parts, truncate them to just the macro name and subsequent `!`. --- This results in a lot of tiny changes to the spans that end up in coverage metadata, and a few changes to coverage reports. Judging by test snapshots, these changes appear to be quite minor in practice.
2025-04-02Rollup merge of #138941 - compiler-errors:receiver-is-dispatchable-bounds, ↵Stuart Cook-13/+22
r=BoxyUwU Do not mix normalized and unnormalized caller bounds when constructing param-env for `receiver_is_dispatchable` See comments in code and in test I added. r? `@BoxyUwU` since you reviewed the last PR, or reassign Fixes #138937
2025-04-02Rollup merge of #138823 - a4lg:riscv-feature-addition-base-i, r=AmanieuStuart Cook-18/+23
rustc_target: RISC-V: add base `I`-related important extensions Of ratified RISC-V features defined, this commit adds extensions satisfying following criteria: * Formerly a part of the `I` extension and splitted thereafter (now ratified as `I` + `Zifencei` + `Zicsr` + `Zicntr` + `Zihpm`) or * Dicoverable from newer versions of the Linux kernel and implemented as a part of `std_detect`'s feature (`Zihintpause`) and * Available on LLVM 18. This is based on [the latest ratified ISA Manuals (version 20240411)](https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications). LLVM Definitions: * [`Zifencei`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L133-L137) * [`Zicsr`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L116-L120) * [`Zicntr`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L122-L124) * [`Zihpm`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L153-L155) * [`Zihintpause`](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L139-L144) Additional (1): One of those, `Zicsr`, is a dependency of many other ISA extensions and this commit adds correct dependencies to `Zicsr`. Additional (2): In RISC-V, `G` is an abbreviation of following extensions: * `I` * `M` * `A` * `F` * `D` * `Zicsr` (although implied by `F`) * `Zifencei` and all RISC-V targets with the `G` abbreviation and targets for Android / VxWorks are updated accordingly. Note: Android will require RVA22 (likely RVA22U64) and some more extensions, which is a superset of RV64GC. For VxWorks, all BSPs currently distributed by Wind River are for boards with RV64GC (this commit also updates `riscv32-wrs-vxworks` though). -------- This is the version 4. `Ztso` in the original proposal is removed on the PR version 2 due to the minimum LLVM version (non-experimental `Ztso` requires LLVM 19 while minimum LLVM version of Rust is 18). This is not back in PR version 3 and 4 after noticing adding `Ztso` is possible by checking host LLVM version because PR version 3 introduces compiler target changes (and adding more extensions would complicate the problems; sorry `Zihintpause`). Version 4: * Fixed some commit messages, * Added Android / VxWorks targets to imply `G` and * Added an implication from `Zve32x` to `Zicsr` (which makes all vector extension subsets to imply `Zicsr`) since #138742 is now merged. Related: * #44839 (`riscv_target_feature`) * #114544 (This PR can be a prerequisite of resolving a part of that tracking issue) * #138742 (Touches the same place and vector extensions depend on `Zicsr`) NOT Related but linked: * #132618 (This PR won't be blocked by this issue since none of those extensions do not change the ABI) `@rustbot` r? `@Amanieu` `@rustbot` label +T-compiler +O-riscv +A-target-feature
2025-04-02Rollup merge of #138003 - sayantn:new-amx, r=AmanieuStuart Cook-0/+15
Add the new `amx` target features and the `movrs` target feature Adds 5 new `amx` target features included in LLVM20. These are guarded under `x86_amx_intrinsics` (#126622) - `amx-avx512` - `amx-fp8` - `amx-movrs` - `amx-tf32` - `amx-transpose` Adds the `movrs` target feature (from #137976). `@rustbot` label O-x86_64 O-x86_32 T-compiler A-target-feature r? `@Amanieu`
2025-04-02Rollup merge of #135295 - eyraudh:master, r=compiler-errorsStuart Cook-0/+8
Check empty SIMD vector in inline asm fixes [#134334](https://github.com/rust-lang/rust/issues/134334)
2025-04-02rustc_target: RISC-V: add base "I"-related important extensionsTsukasa OI-18/+23
Of ratified RISC-V features defined, this commit adds extensions satisfying following criteria: * Formerly a part of the "I" extension and splitted thereafter (now ratified as "I" + "Zifencei" + "Zicsr" + "Zicntr" + "Zihpm") or * Dicoverable from newer versions of the Linux kernel and implemented as a part of std_detect's feature ("Zihintpause"). This is based on the latest ratified ISA Manuals (version 20240411). Additional (1): One of those, "Zicsr", is a dependency of many other ISA extensions and this commit adds correct dependencies to "Zicsr". Additional (2): In RISC-V, "G" is an abbreviation of following extensions: * "I" * "M" * "A" * "F" * "D" * "Zicsr" (although implied by "F") * "Zifencei" and all RISC-V targets with the "G" abbreviation and targets for Android / VxWorks are updated accordingly. Note: Android will require RVA22 (likely RVA22U64) and some more extensions, which is a superset of RV64GC. For VxWorks, all BSPs currently distributed by Wind River are for boards with RV64GC (this commit also updates riscv32-wrs-vxworks though).
2025-04-02Auto merge of #138478 - nnethercote:rm-NtExpr-NtLiteral, r=petrochenkovbors-224/+361
Remove `NtExpr` and `NtLiteral` The next part of #124141. r? `@petrochenkov`
2025-04-02Move methods from `Map` to `TyCtxt`, part 5.Nicholas Nethercote-176/+149
This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.
2025-04-02Factor some code out of `AstValidator::visit_items`.Nicholas Nethercote-19/+20
Currently it uses `walk_item` on some item kinds. For other item kinds it visits the fields individually. For the latter group, this commit adds `visit_attrs_vis` and `visit_attrs_vis_ident` which bundle up visits to the fields that don't need special handling. This makes it clearer that they haven't been forgotten about. Also, it's better to do the attribute visits at the start because attributes precede the items in the source code. Because of this, a couple of tests have their output improved: errors appear in an order that matches the source code order.
2025-04-01simplify Interner opaque types APIlcnr-47/+26
2025-04-01call `mir_promoted` inside of `do_mir_borrowck`lcnr-14/+9
2025-04-02Simplify control flow in `AstValidator::visit_item`.Nicholas Nethercote-12/+8
Currently some code paths return early, while others fall through to the `visit::walk_item` call, which is easy to overlook (I did, at first), even with the explanatory comments. This commit removes the early returns and moves the `visit::walk_item` calls up where necessary. This makes the function easier to read and slightly shorter.
2025-04-02Fix problem causing `rusqlite` compilation to OOM.Nicholas Nethercote-1/+3
This makes the expression re-parsing more like how it's originally done in `parse_nonterminal`.
2025-04-02Fix a problem with metavars and inner attributes.Nicholas Nethercote-22/+39
2025-04-02Remove `Token::uninterpolated_span`.Nicholas Nethercote-44/+48
In favour of the similar method on `Parser`, which works on things other than identifiers and lifetimes.
2025-04-02Remove `NtExpr` and `NtLiteral`.Nicholas Nethercote-163/+277
Notes about tests: - tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs: some messages are now duplicated due to repeated parsing. - tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs: ditto. - `tests/ui/proc-macro/macro-rules-derive-cfg.rs`: the diff looks large but the only difference is the insertion of a single invisible-delimited group around a metavar. - `tests/ui/attributes/nonterminal-expansion.rs`: a slight span degradation, somehow related to the recent massive attr parsing rewrite (#135726). I couldn't work out exactly what is going wrong, but I don't think it's worth holding things up for a single slightly suboptimal error message.
2025-04-01replace extra_filename with strict version hash in metrics file namesJane Losare-Lusby-8/+10
2025-04-01Rollup merge of #139202 - bjorn3:improve_comment, r=jieyouxuMatthias Krüger-1/+1
Improve docs of ValTreeKind
2025-04-01Rollup merge of #139193 - compiler-errors:inline-synthetic, r=eholkMatthias Krüger-0/+2
Feed HIR for by-move coroutine body def, since the inliner tries to read its attrs See the comments in the test. I'm surprised that nobody found this[^1] (edit: nvm haha), but you have to go out of your way to construct the by-move body and then inline it w/ a poll call, so I guess the inliner just never really gets into this situation before. Fixes #134335 r? oli-obk [^1]: Well, ````@eholk```` found this when working on the `iter! {}` macro, since it more dramatically affects those.
2025-04-01Rollup merge of #139188 - durin42:llvm-21-LintPass, r=dianqkMatthias Krüger-4/+9
PassWrapper: adapt for llvm/llvm-project@94122d58fc77079a291a3d008914… …006cb509d9db We also have to remove the LLVM argument in cast-target-abi.rs for LLVM 21. I'm not really sure what the best approach here is since that test already uses revisions. We could also fork the test into a copy for LLVM 19-20 and another for LLVM 21, but what I did for now was drop the lint-abort-on-error flag to LLVM figuring that some coverage was better than none, but I'm happy to change this if that was a bad direction. r? dianqk ````@rustbot```` label llvm-main
2025-04-01Rollup merge of #139022 - lcnr:incr-obligation-depth, r=oli-obkMatthias Krüger-38/+38
increment depth of nested obligations properly fixes the root cause of #109268. While we didn't get hangs here before, I ended up encountering its root cause again with #138785. r? types
2025-04-01Rollup merge of #138790 - xizheyin:issue-138626, r=compiler-errorsMatthias Krüger-12/+12
Note potential but private items in show_candidates Closes #138626 . We should add potential private items to give ample hints. And for the other seemingly false positive ` pub use crate::one::Foo;` should be kept because we don't know if the user wants to import other module's items or not, and therefore should be given the full option to do so. r? compiler
2025-04-01Add unstable `--print=crate-root-lint-levels`Urgau-0/+31
2025-04-01Allow formatting example/gen_block_iterate.rsbjorn3-8/+12
2025-04-01Auto merge of #138492 - lcnr:rm-inline_const_pat, r=oli-obkbors-29/+14
remove `feature(inline_const_pat)` Summarizing https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/remove.20feature.28inline_const_pat.29.20and.20shared.20borrowck. With https://github.com/rust-lang/types-team/issues/129 we will start to borrowck items together with their typeck parent. This is necessary to correctly support opaque types, blocking the new solver and TAIT/ATPIT stabilization with the old one. This means that we cannot really support `inline_const_pat` as they are implemented right now: - we want to typeck inline consts together with their parent body to allow inference to flow both ways and to allow the const to refer to local regions of its parent.This means we also need to borrowck the inline const together with its parent as that's necessary to properly support opaque types - we want the inline const pattern to participate in exhaustiveness checking - to participate in exhaustiveness checking we need to evaluate it, which requires borrowck, which now relies on borrowck of the typeck root, which ends up checking exhaustiveness again. **This is a query cycle**. There are 4 possible ways to handle this: - stop typechecking inline const patterns together with their parent - causes inline const patterns to be different than inline const exprs - prevents bidirectional inference, we need to either fail to compile `if let const { 1 } = 1u32` or `if let const { 1u32 } = 1` - region inference for inline consts will be harder, it feels non-trivial to support inline consts referencing local regions from the parent fn - inline consts no longer participate in exhaustiveness checking. Treat them like `pat if pat == const { .. }` instead. We then only evaluate them after borrowck - difference between `const { 1 }` and `const FOO: usize = 1; match x { FOO => () }`. This is confusing - do they carry their weight if they are now just equivalent to using an if-guard - delay exhaustiveness checking until after borrowck - should be possible in theory, but is a quite involved change and may have some unexpected challenges - remove this feature for now I believe we should either delay exhaustiveness checking or remove the feature entirely. As moving exhaustiveness checking to after borrow checking is quite complex I think the right course of action is to fully remove the feature for now and to add it again once/if we've got that implementation figured out. `const { .. }`-expressions remain stable. These seem to have been the main motivation for https://github.com/rust-lang/rfcs/issues/2920. r? types cc `@rust-lang/types` `@rust-lang/lang` #76001
2025-04-01interpret: add a version of run_for_validation for &selfRalf Jung-12/+33
2025-04-01Auto merge of #137535 - Kobzol:split-metadata, r=petrochenkovbors-58/+156
Introduce `-Zembed-metadata` to allow omitting full metadata from rlibs and dylibs This is a continuation of https://github.com/rust-lang/rust/pull/120855 (I was mentored by `@bjorn3` to move it forward). Most of the original code was written by bjorn3, I tried to clean it up a bit and add some documentation and tests. This PR introduces a new unstable compiler flag called `-Zembed-metadata=[no|yes]`, with the default being `yes` (see https://github.com/rust-lang/rust/issues/57076 for context). When set to `no`, rustc will only store a small metadata stub inside rlibs/dylibs instead of the full metadata, to keep their size smaller. It should be used in combination with `--emit=metadata`, so that the users of such a compiled library can still read the metadata from the corresponding `.rmeta` file. [This comment](https://github.com/rust-lang/rust/pull/120855#issuecomment-1937018169) shows an example of binary/artifact size wins that can be achieved using this approach. Contrary to https://github.com/rust-lang/rust/pull/120855, this PR only introduces the new flag, along with a couple of run-make tests and documentation, but does not yet use it in bootstrap to actually compile rustc. I plan to do that as a follow-up step (along with integration in Cargo, which should ideally just always pass this flag to reduce the size of target directories). Fixes https://github.com/rust-lang/rust/issues/23366 Closes https://github.com/rust-lang/rust/issues/29511 Fixes https://github.com/rust-lang/rust/issues/57076 Another attempt of https://github.com/rust-lang/rust/pull/93945 and https://github.com/rust-lang/rust/pull/120855. r? `@petrochenkov`
2025-04-01Ensure `calculcate_dtor` is only ever called on local typesOli Scherer-4/+4
2025-04-01Store adt_async_destructor in metadataOli Scherer-4/+7
2025-04-01Store adt_destructor in metadataOli Scherer-4/+7