54214 Commits

Author SHA1 Message Date
Rémy Rakic 524789f8ab Revert "Rollup merge of #149904 - ShoyuVanilla:ns-remove-sg-hack, r=lcnr"
This reverts commit c108ad5617, reversing
changes made to 485f76b835.

(cherry picked from commit 22faa52629)
2026-04-09 08:36:12 -07:00
Oli Scherer 2c2e33ac59 Revert performing basic const checks in typeck on stable 2026-04-09 08:34:04 -07:00
Josh Stone d0b5e61fe7 Revert "Stabilize assert_matches"
This reverts commit 2f3b952349.
2026-04-08 14:10:50 -07:00
Josh Stone bca08d8c93 Revert "update diagnostic for variables moved by dbg!"
This reverts commit 1374038f80.
2026-04-08 09:45:54 -07:00
Wesley Wiser 5dacf5d54d Revert "Fix: On wasm targets, call panic_in_cleanup if panic occurs in cleanup"
This reverts commit acbfd79acf.

(cherry picked from commit c9d3a00cd1)
2026-04-02 11:39:06 -07:00
mu001999 195f9764c0 Init self_decl with a correct vis
(cherry picked from commit 01795c3eab)
2026-04-02 11:07:33 -07:00
dianne 1374038f80 update diagnostic for variables moved by dbg!
(cherry picked from commit 7d1b41cbb3)
2026-04-02 11:05:25 -07:00
bors 8ebd005178 Auto merge of #154307 - ShoyuVanilla:beta-fix, r=jieyouxu
[beta] Revert #151380 in beta

cc https://rust-lang.zulipchat.com/#narrow/channel/474880-t-compiler.2Fbackports/topic/.23153869.3A.20beta-nominated/with/581306395

r? ghost
2026-04-01 20:23:34 +00:00
Jonathan Brouwer 470cb0754e Rollup merge of #153763 - nikic:target-cpu-native-fix, r=lqd
Don't add empty target features for target-cpu=native on macOS

LLVM does not support host feature detection (only host cpu detection) on apple platforms. As such, the returned feature string will be empty. Adding this empty string to the target-features attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features. The reason why this was not caught by the target-cpu-native test is that it requires a function that adds *some* target features, otherwise the attribute is omitted entirely. We achieve this with a somewhat peculiar construction that enables `neon` if it's already enabled. (This is to avoid enabling it on softfloat targets.)

Fixes https://github.com/rust-lang/rust/issues/153397.
2026-03-24 18:16:01 -07:00
Shoyu Vanilla 63cd511300 Revert "Auto merge of #151380 - ShoyuVanilla:shallow-resolve-to-root-var, r=lcnr"
This reverts commit 75b9d89c68, reversing
changes made to 7bee525095.
2026-03-24 20:57:08 +09:00
León Orell Valerian Liehr bdc1b3ffa8 [beta] Don't look for non-type-level assoc consts when checking trait object types 2026-03-17 01:54:26 +01:00
Josh Stone bad24ccbec Replace version placeholders with 1.95.0 2026-03-02 15:00:53 -08:00
Jonathan Brouwer 70da804451 Rollup merge of #153159 - Zalathar:emit-workaround, r=nnethercote
Work around a false `err.emit();` type error in rust-analyzer

For whatever reason, rust-analyzer doesn't see that these calls to `err.emit();` are diverging, so the trailing semicolon makes r-a complain about a type mismatch between `()` and some other type.

Removing the trailing semicolon makes no functional difference (because the emit still unwinds the stack), but seems to be enough to allow rust-analyzer to see that emitting an error returns `!` in these cases, which silences the false error.
2026-02-27 14:05:38 +01:00
Jonathan Brouwer f433c13b48 Rollup merge of #153138 - mu001999-contrib:print-path-root, r=petrochenkov
Print path root when printing path

Extracted from https://github.com/rust-lang/rust/pull/152996.

r? petrochenkov
2026-02-27 14:05:37 +01:00
Jonathan Brouwer b2099acea5 Rollup merge of #152674 - makai410:rpub/sus-trait, r=celinval
rustc_public: remove the `CrateDefItems` trait

This trait feels sus since its documentation says it's for 'retrieving all items from a definition' however it only provides an `associated_items` method (??), which I believe should only be valid for `impl`s and `trait`s.
2026-02-27 14:05:34 +01:00
Jonathan Brouwer 3186ae21a1 Rollup merge of #152673 - makai410:rpub/bridge-impl, r=celinval
rustc_public: rewrite `bridge_impl` to reduce boilerplate

It looks better.
2026-02-27 14:05:33 +01:00
Jonathan Brouwer e95cbb6da6 Rollup merge of #153175 - Zalathar:load-green, r=petrochenkov
Clarify a confusing green-path function

The current name of this function, `try_load_from_disk_and_cache_in_memory`, is confusing on a number of levels:

- Trying to mark the node green is load-bearing even for queries that never cache to disk.
- It will only return None if it fails to mark the query green; the subsequent parts always return Some.
- If it cannot load a value from disk, it will obtain a value by invoking the query provider.
- It is not actually responsible for storing values in the in-memory cache; that is handled by an outer layer.

This PR therefore:
- Hoists the try-mark-green out of that function, making the function always return a value.
- Renames the function to `load_from_disk_or_invoke_provider_green `.
- Renames a few other local variables in passing.

There should be no change to compiler behaviour.
2026-02-27 14:05:32 +01:00
Jonathan Brouwer 383ef53b9a Rollup merge of #153012 - Zalathar:lexical, r=petrochenkov
Stop using `LinkedGraph` in `lexical_region_resolve`

There are only two users of the older `LinkedGraph` data structure, and this is one.

It turns out that this diagnostic-related code doesn't need any non-trivial graph operations (since it does its own graph traversal); it just needs the ability to get a list of in-edges or out-edges (constraints) for any particular node. That's easy enough to do with a simple custom data structure.

Inspired by https://github.com/rust-lang/rust/pull/152621, which wants to make changes to `LinkedGraph` that wouldn't make sense for this use-site.
2026-02-27 14:05:31 +01:00
Jonathan Brouwer 1b897d4f18 Rollup merge of #151143 - folkertdev:tail-call-indirect, r=WaffleLapkin
explicit tail calls: support indirect arguments

tracking issue: https://github.com/rust-lang/rust/issues/112788

After discussion in https://github.com/rust-lang/rust/issues/144855, I was wrong and it is actually possible to support tail calls with `PassMode::Indirect { on_stack: false, .. }` arguments.

Normally an indirect argument with `on_stack: false` would be passed as a pointer into the caller's stack frame. For tail calls, that would be unsound, because the caller's stack frame is overwritten by the callee's stack frame.

Therefore we store the argument for the callee in the corresponding caller's slot. Because guaranteed tail calls demand that the caller's signature matches the callee's, the corresponding slot has the correct type.

To handle cases like the one below, the tail call arguments must first be copied to a temporary, and can only then be copied to the caller's argument slots.

```rust
// A struct big enough that it is not passed via registers.
pub struct Big([u64; 4]);

fn swapper(a: Big, b: Big) -> (Big, Big) {
    become swapper_helper(b, a);
}
```

---

I'm not really familiar with MIR and what tricks/helpers we have, so I'm just cobbling this together. Hopefully we can arrive at something more elegant.
2026-02-27 14:05:30 +01:00
Zalathar c6d028c30a Clarify a confusing green-path function 2026-02-27 22:53:26 +11:00
Folkert de Vries e6cf5a22e7 test u128 passing on linux and windows 2026-02-27 10:51:55 +01:00
Folkert de Vries 31ae3d2be8 guaranteed tail calls: support indirect arguments 2026-02-27 10:24:39 +01:00
bors 6f54d591c3 Auto merge of #151247 - chenyukang:yukang-fix-const-recover-151149, r=estebank
Try to recover from over-parsing in const item with missing semicolon

Fixes rust-lang/rust#151149

r? @estebank
2026-02-27 09:09:21 +00:00
Zalathar 882ae150e9 Work around a false err.emit(); type error in rust-analyzer 2026-02-27 13:06:14 +11:00
bors 25396cf549 Auto merge of #153139 - JonathanBrouwer:rollup-QZ4yuaa, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#153055 ( Revert "Also duplicate `#[expect]` attribute in `#[derive]`-ed code")
 - rust-lang/rust#153095 (Revert "rustc_expand: improve diagnostics for non-repeatable metavars")
2026-02-26 16:39:20 +00:00
Jonathan Brouwer 3e1566da05 Rollup merge of #153095 - JonathanBrouwer:revert, r=lqd
Revert "rustc_expand: improve diagnostics for non-repeatable metavars"

Revert because of a perf regression in https://github.com/rust-lang/rust/pull/152679
Clean revert

r? @ghost
2026-02-26 16:44:42 +01:00
Jonathan Brouwer fd2950b691 Rollup merge of #153055 - Urgau:revert-152289, r=jdonszelmann
Revert "Also duplicate `#[expect]` attribute in `#[derive]`-ed code"

Turns out rust-lang/rust#152289 doesn't work, not because cloning an attribute doesn't keep the same attribute id, but because `#[cfg]` and `#[cfg_attr]` [re-parse items from scratch](https://github.com/rust-lang/rust/blob/859951e3c7c9d0322c39bad49221937455bdffcd/compiler/rustc_builtin_macros/src/cfg_eval.rs#L100-L109) bypassing any cloning on AST and forcing the creation of new attribute IDs. 😕

Fixes rust-lang/rust#153036
Fixes rust-lang/rust#152401
Reopens rust-lang/rust#150553
2026-02-26 16:44:42 +01:00
mu001999 dfd18b7e89 Print path root when printing path 2026-02-26 23:34:41 +08:00
Jonathan Brouwer 3eafea8d3a Rollup merge of #153120 - Zalathar:execute, r=nnethercote
Clean up some code related to `QueryVTable::execute_query_fn`

This PR is an assortment of small cleanups to code that interacts with `execute_query_fn` in the query vtable.

I also experimented with trying to replace the macro-generated `__rust_end_short_backtrace` functions with a single shared generic function, but I couldn't manage to avoid breaking short backtraces, so I left a note behind to document my attempt.

r? nnethercote (or compiler)
2026-02-26 09:57:06 +01:00
Jonathan Brouwer 8386f94903 Rollup merge of #153112 - nnethercote:query-key-stuff, r=nnethercote
Query key cleanups

The first three commits are simple. The last two are a bit more opinionated, see what you think.

r? @Zalathar
2026-02-26 09:57:05 +01:00
Jonathan Brouwer c902bc1c7c Rollup merge of #153091 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Migration of `LintDiagnostic` - part 4

Follow-up of:
* https://github.com/rust-lang/rust/pull/152933
* https://github.com/rust-lang/rust/pull/153016
* rust-lang/rust#153051

More `LintDiagnostic` items being migrated to `Diagnostic`. Since there is no remaining `emit_node_span_lint` calls, I replaced the method with the code of `emit_diag_node_span_lint`.

r? @JonathanBrouwer
2026-02-26 09:57:04 +01:00
Jonathan Brouwer 51492d0d59 Rollup merge of #152978 - JonathanBrouwer:autodiff_attrs, r=jdonszelmann
Port `#[rustc_autodiff]` to the attribute parser infrastructure

For https://github.com/rust-lang/rust/issues/131229

r? @jdonszelmann
cc @ZuseZ4

`autodiff_forward` and `autodiff_reverse` can be ported in a seperate PR, but these are expanded in the AST and don't exist anymore in the HIR so this is a bit more of a challenge.
2026-02-26 09:57:04 +01:00
Jonathan Brouwer 81aa532b7f Rollup merge of #152651 - TaKO8Ki:fix-143872-compare-impl-item-diag-args, r=jdonszelmann
Avoid duplicate `requirement` diag args in `RegionOriginNote`

Fixes rust-lang/rust#143872

`RegionOriginNote::WithRequirement` can be emitted multiple times for one
  diagnostic. I fixed the ICE by scoping per note fluent args in `RegionOriginNote::WithRequirement` with `store_args` and `restore_args`.
2026-02-26 09:57:03 +01:00
Jonathan Brouwer d5b6474607 Remove attributes from check_attr that were already parsed 2026-02-26 09:50:36 +01:00
Jonathan Brouwer 5cd5b90a38 Port rustc_autodiff to the attribute parsers 2026-02-26 09:50:36 +01:00
Guillaume Gomez f9b70f0ef2 Migrate rustc_lint::EqInternalMethodImplemented to Diagnostic 2026-02-26 09:47:06 +01:00
Jonathan Brouwer 90c93ab7c1 Move rustc_ast::AutoDiffAttrs to rustc_hir::RustcAutodiff 2026-02-26 09:41:21 +01:00
Guillaume Gomez b409cb16ae Replace emit_span_lint with emit_span_diag_lint in rustc_lint 2026-02-26 09:33:27 +01:00
Guillaume Gomez bca1cb4c2f Replace emit_span_lint with emit_span_diag_lint in rustc_lint 2026-02-26 09:32:23 +01:00
Guillaume Gomez 3f71fd001a Add new LintContext::opt_span_diag_lint and LintContext::emit_diag_lint methods 2026-02-26 09:31:30 +01:00
Guillaume Gomez 4803bb96c1 Replace TyCtxt::node_span_lint with emit_node_span_lint in rustc_borrowck 2026-02-26 09:31:29 +01:00
Guillaume Gomez 5edbf6a9f9 Remove unused TyCtxt::emit_node_lint method 2026-02-26 09:31:29 +01:00
Nicholas Nethercote 9ba101f44a Rename Storage as Cache.
Because `Storage` is a vague name that I've never liked.
2026-02-26 19:18:51 +11:00
Nicholas Nethercote 44994072d3 Merge trait QueryCacheKey into trait QueryKey.
We have two traits governing query keys, for no particular reason.
This commit combines them.
2026-02-26 19:18:51 +11:00
Nicholas Nethercote b284b04cc3 Remove unnecessary Clone bounds. 2026-02-26 19:18:51 +11:00
Nicholas Nethercote fbea6ddcd2 Rename trait Key as trait QueryKey`
Because `Key` is extremely generic and hard to search for.

Also rename `LocalKey` and `AsLocalKey` similarly, for consistency.
2026-02-26 19:18:48 +11:00
Nicholas Nethercote 6ba5b1ad9c Move trait DepNodeKey.
It's currently in `dep_node.rs`, along with a blanket impl. Specific
impls are in `dep_node_key.rs`. This commit moves the trait and the
blanket impl into `dep_node_key.rs`, so everything is in one place.
2026-02-26 19:09:46 +11:00
Zalathar fb42537104 Rename some query plumbing to match QueryVTable::execute_query_fn 2026-02-26 18:53:50 +11:00
Zalathar cd7bbac7c6 Add some docs for QueryVTable::execute_query_fn
This function is tricky to document, and there's more that could be said here,
but I don't want to take up too much vertical space, or add too much risk of
details becoming inaccurate over time.
2026-02-26 18:53:50 +11:00
Zalathar 508801c95d Pass the QueryVTable to functions that were taking execute_query_fn
All three of these functions were previously taking `cache` and
`execute_query_fn` as separate arguments, but after some other recent
simplifications we can just pass `&'tcx QueryVTable<'tcx, C>` instead.

This makes it easier to see where `execute_query_fn` is actually called.
2026-02-26 17:39:31 +11:00