Commit Graph

54205 Commits

Author SHA1 Message Date
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
Jacob Pratt efae53bc9e Rollup merge of #153094 - cuviper:AppendOnlyVec-iters, r=Kivooeo
Simplify `AppendOnlyVec` iterators

This isn't a big deal, but I noticed that these iterators were more complicated than they need to be.
2026-02-25 21:42:59 -05:00
Jacob Pratt 236327e901 Rollup merge of #153092 - mu001999-contrib:cleanup/redundant-self, r=JonathanBrouwer
Remove redundant self usages

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

r? petrochenkov
2026-02-25 21:42:58 -05:00
Jacob Pratt 80fc788f3f Rollup merge of #153063 - samueltardieu:features/remove-span-parameter, r=petrochenkov
`is_ty_must_use`: do not require a `span` argument

All callers of `is_ty_must_use()`, recursive or not, pass `span` as equal to `expr.span` alongside `expr`. The `span` parameter can be safely removed.
2026-02-25 21:42:57 -05:00
Jacob Pratt f8f444757d Rollup merge of #153029 - nnethercote:disallowed-pass-by-ref, r=Urgau
Rename `rustc::pass_by_value` lint as `rustc::disallowed_pass_by_ref`.

The name `pass_by_value` is completely wrong. The lint actually checks for the use of pass by reference for types marked with `rustc_pass_by_value`.

The hardest part of this was choosing the new name. The `disallowed_` part of the name closely matches the following clippy lints:
- `disallowed_macros`
- `disallowed_methods`
- `disallowed_names`
- `disallowed_script_idents`
- `disallowed_types`

The `pass_by_value` part of the name aligns with the following clippy lints:
- `needless_pass_by_value`
- `needless_pass_by_ref_mut`
- `trivially_copy_pass_by_ref`
- `large_types_passed_by_value` (less so)

r? @Urgau
2026-02-25 21:42:57 -05:00
Jacob Pratt 7a883469fd Rollup merge of #149978 - cyrgani:no-eq-assert-receiver-method, r=madsmtm
deprecate `Eq::assert_receiver_is_total_eq` and emit FCW on manual impls

The `Eq::assert_receiver_is_total_eq` method is purely meant as an implementation detail by `#[derive(Eq)]` to add checks that all fields of the type the derive is applied to also implement `Eq`.
The method is already `#[doc(hidden)]` and has a comment saying `// This should never be implemented by hand.`.
Unfortunately, it has been stable since 1.0 and there are some cases on GitHub (https://github.com/search?q=assert_receiver_is_total_eq&type=code) where people have implemented this method manually, sometimes even with actual code in the method body (example: https://github.com/Shresht7/codecrafters-redis-rust/blob/31f0ec453c504b4ab053a7b1c3ff548ff36a9db5/src/parser/resp/types.rs#L255).
To prevent further confusion from this, this PR is deprecating the method and adds a FCW when it is manually implemented (this is necessary as the deprecation warning is not emitted when the method is implemented, only when it is called).
This is similar to what was previously done with the `soft_unstable` lint (https://github.com/rust-lang/rust/issues/64266).

See also https://github.com/rust-lang/libs-team/issues/704.
2026-02-25 21:42:56 -05:00
Jacob Pratt ec78ad8d4b Rollup merge of #153089 - RalfJung:no-dummys, r=Kivooeo
interpret: avoid dummy spans in the stacktrace

This should fix https://github.com/rust-lang/miri/issues/4871
2026-02-25 21:42:55 -05:00
Jacob Pratt 49a98857e1 Rollup merge of #153078 - nnethercote:rm-QuerySystemFns, r=petrochenkov
Remove `QuerySystemFns`

Two small query-related cleanups.

r? petrochenkov
2026-02-25 21:42:54 -05:00
Jacob Pratt cd09c56e45 Rollup merge of #153075 - reddevilmidzy:mgca-neg, r=BoxyUwU
mGCA: Lower negated literals directly and reject non-integer negations

follow up rust-lang/rust#152001
resolve: rust-lang/rust#152246

r? BoxyUwU
2026-02-25 21:42:54 -05:00
Jacob Pratt d1083552b7 Rollup merge of #153035 - Gelbpunkt:ppc64-callconv-llvm-abiname, r=RalfJung
rustc_target: callconv: powerpc64: Use llvm_abiname rather than target_abi for ABI determination

Currently on PowerPC64 targets, `llvm_abiname` and `target_abi` will be the same unless we're on AIX. Since `llvm_abiname` is what we pass on to LLVM, it is preferable to use the value of that to determine the calling convention rather than `target_abi`.

All PowerPC64 targets set both `llvm_abiname` and `target_abi` to the respective ELF ABIs, with the exception of AIX. This is a non-functional change.

Noticed this in the follow-up discussion from rust-lang/rust#150468 and also requested by @RalfJung [here](https://github.com/rust-lang/rust/pull/150468#discussion_r2842291237).

r? @RalfJung
2026-02-25 21:42:53 -05:00