Commit Graph

321483 Commits

Author SHA1 Message Date
Zalathar e19ad08c6d Use enums to clarify DepNodeColorMap color marking
When a function's documentation has to explain the meaning of nested results
and options, then it is often a good candidate for using a custom result enum
instead.

This commit also renames `DepNodeColorMap::try_mark` to `try_set_color`, to
make it more distinct from the similarly-named `DepGraph::try_mark_green`.

The difference is that `try_mark_green` is a higher-level operation that tries
to determine whether a node _can_ be marked green, whereas `try_set_color` is a
lower-level operation that actually records a color for the node.
2026-03-22 15:22:03 +11:00
bors 562dee4820 Auto merge of #154122 - Zalathar:no-anon, r=nnethercote
Remove the `anon` query modifier



Prior experiments:
- https://github.com/rust-lang/rust/pull/152268
- https://github.com/rust-lang/rust/pull/153996

[Zulip thread: *Removing the `anon` query modifier*](https://rust-lang.zulipchat.com/#narrow/channel/582699-t-compiler.2Fquery-system/topic/Removing.20the.20.60anon.60.20query.20modifier/with/580760962)

---

There are currently three queries that use the `anon` modifier:
- `check_representability`
- `check_representability_adt_ty`
- `erase_and_anonymize_regions_ty`

It seems that none of them are using `anon` in an essential way.

According to comments and tests, the *representability* queries mainly care about not being eligible for forcing (despite having a recoverable key type), so that if a cycle does occur then the entire cycle will be on the query stack. Replacing `anon` with a new `no_force` modifier gives a modest perf improvement.

The `erase_and_anonymize_regions_ty` query appears to be using `anon` to reduce the dep-graph overhead of a query that is expected to not call any other queries (and thus have no dependencies). Replacing `anon` with either `no_hash` or nothing appears to give only a very small perf hit on `cargo` benchmarks, which is justified by the fact that it lets us remove a lot of machinery for anonymous queries.

We still need to retain some of the machinery for anonymous *tasks*, because the non-query task `DepKind::TraitSelect` still uses it.

---

I have some ideas for a follow-up that will reduce dep-graph overhead by replacing *all* zero-dependency nodes with a singleton node, but I want to keep that separate in case it causes unexpected issues and needs to be bisected or reverted.
2026-03-21 21:53:47 +00:00
bors 20f19f4615 Auto merge of #154176 - flip1995:clippy-subtree-update, r=matthiaskrgr
Clippy subtree update

r? Manishearth 

2 days late as I didn't get to it during the week.
2026-03-21 13:42:07 +00:00
Philipp Krones 36e06ebb21 Merge commit '256c21c543ca422b3ab8810a0d081d722408e896' into clippy-subtree-update 2026-03-21 14:13:09 +01:00
Philipp Krones 256c21c543 Rustup (#16740)
r? @ghost

changelog: none
2026-03-21 12:45:54 +00:00
Philipp Krones e191c9429e Bump nightly version -> 2026-03-21 2026-03-21 13:40:35 +01:00
Philipp Krones 1e283ba0ce Merge remote-tracking branch 'upstream/master' into rustup 2026-03-21 13:40:20 +01:00
bors 7218b7fa17 Auto merge of #153768 - zetanumbers:consistent-par-slice, r=JohnTitor,Zoxc
Make `par_slice` consistent with single-threaded execution



rust-lang/rust#152375 removed this consistency by switching from order preserving join to scope, which does not preserve order as stated in `par_fns` as well. This also makes `par_slice` behavior consistent with `par_fns`.
2026-03-21 10:31:17 +00:00
bors e52f547ed4 Auto merge of #154160 - JonathanBrouwer:rollup-4jbkEbt, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - rust-lang/rust#154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - rust-lang/rust#146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - rust-lang/rust#154118 (don't suggest non-deriveable traits for unions)
 - rust-lang/rust#154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - rust-lang/rust#154156 (Moving issue-52049 to borrowck)
2026-03-21 07:20:47 +00:00
Daria Sukhonina 50c564e679 Make par_slice consistent with single-threaded execution 2026-03-21 08:23:42 +03:00
bors 44e662074f Auto merge of #154148 - weihanglo:update-cargo, r=weihanglo
Update cargo submodule

14 commits in cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3..e84cb639edfea2c42efd563b72a9be0cc5de6523
2026-03-13 14:34:16 +0000 to 2026-03-21 01:27:07 +0000
- Fix symlink_and_directory when running in a long target dir name (rust-lang/cargo#16775)
- cargo clean: Validate that target_dir is not a file  (rust-lang/cargo#16765)
- fix: fetching non-standard git refspecs on non-github repos (rust-lang/cargo#16768)
- Update tar to 0.4.45 (rust-lang/cargo#16771)
- chore: Remove edition_lint_opts from Lint (rust-lang/cargo#16762)
- refactor: split out several smaller changes to prepare for async http (rust-lang/cargo#16763)
- fix(compile): Make build.warnings ignore non-local deps (rust-lang/cargo#16760)
- fix: detect circular publish dependency cycle in workspace publish (rust-lang/cargo#16722)
- refactor(shell): Pull out term integration into `anstyle-progress` (rust-lang/cargo#16757)
- test: reproduce rustfix panic on overlapping suggestions (rust-lang/cargo#16705)
- fix: Avoid panic for package specs with an empty fragment (rust-lang/cargo#16754)
- refactor(registry): avoid dynamic dispatch for Registry trait (rust-lang/cargo#16752)
- refactor(shell): Pull out hyperlink logic into anstyle-hyperlink (rust-lang/cargo#16749)
- refactor(install): Remove dead code (rust-lang/cargo#16718)
2026-03-21 04:11:42 +00:00
Zalathar 3a62e89822 Remove the anon query modifier
We still have some anon-task machinery for `DepKind::TraitSelect` tasks, but
there are no longer any queries that use the `anon` modifier.
2026-03-21 14:22:10 +11:00
Zalathar 0dfce4d268 Don't use anon for query erase_and_anonymize_regions_ty
According to its comment, this query was only using `anon` to save a little bit
of work for a dep graph node that is expected to have no dependencies.

Benchmarks indicate that the perf loss, if any, is small enough to be justified
by the fact that we can now remove support for `anon` queries.

Adding `no_hash` appears to give marginally better perf results.
2026-03-21 14:22:10 +11:00
Zalathar 70f3e09225 Always call check_representability with tcx.ensure_ok()
This was previously not possible because `check_representability` was `anon`.
2026-03-21 14:22:10 +11:00
Zalathar dbdbf09586 Use a new no_force query modifier for check_representability
These queries appear to have been using `anon` for its side-effect of making
them ineligible for forcing.

According to their comments and also `tests/incremental/issue-61323.rs`, these
queries want to avoid forcing so that if a cycle does occur, the whole cycle
will be on the query stack for the cycle handler to find.
2026-03-21 14:22:10 +11:00
Zalathar 193309e1c3 Sort query modifier names in doc_link! 2026-03-21 14:11:24 +11:00
Weihang Lo 01ea06bfd3 Update cargo submodule 2026-03-20 23:05:00 -04:00
Jonathan Brouwer 6d2a545c09 Rollup merge of #154156 - aryannrd:move-issue-52049-to-borrowck, r=Kivooeo
Moving issue-52049 to borrowck
2026-03-21 00:42:49 +01:00
Jonathan Brouwer 84cb74ad9a Rollup merge of #154120 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`

Part of https://github.com/rust-lang/rust/issues/153099.

End goal being to completely remove the two steps currently required by `DecorateDiagCompat::Builtin` and remove duplicated types.

r? @JonathanBrouwer
2026-03-21 00:42:48 +01:00
Jonathan Brouwer 70d1c586ce Rollup merge of #154118 - malezjaa:dont-suggest-some-traits-for-unions, r=JonathanBrouwer
don't suggest non-deriveable traits for unions

Fixes rust-lang/rust#137587

Before, the compiler suggested adding `#[derive(Debug)]` (other traits too) for unions,
which is misleading because some traits can't be automatically derived.

Only traits that are still suggested are Copy and Clone.

I noticed the error label changed after removing the suggestion. I hope this isn't a big deal, but let me know if that's an issue.

original example:
```rs
union Union {
    member: usize,
}

impl PartialEq<u8> for Union {
    fn eq(&self, rhs: &u8) -> bool {
        unsafe { self.member == (*rhs).into() }
    }
}

fn main() {
    assert_eq!(Union { member: 0 }, 0);
}
```

before:
```
error[E0277]: `Union` doesn't implement `Debug`
  --> src\main.rs:13:5
   |
13 |     assert_eq!(Union { member: 0 }, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Union`
   |
   = note: add `#[derive(Debug)]` to `Union` or manually `impl Debug for Union`
   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `Union` with `#[derive(Debug)]`
   |
 2 + #[derive(Debug)]
 3 | union Union {
   |
```

after (the message doesn't suggest adding #[derive(Debug)] to unions)
```
error[E0277]: `Union` doesn't implement `Debug`
  --> src\main.rs:13:5
   |
13 |     assert_eq!(Union { member: 0 }, 0);
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Debug` is not implemented for `Union`
  --> src\main.rs:2:1
   |
 2 | union Union {
   | ^^^^^^^^^^^
   = note: manually `impl Debug for Union`
```
2026-03-21 00:42:48 +01:00
Jonathan Brouwer b9f8e25f6e Rollup merge of #146961 - Jules-Bertholet:expr-cfg, r=JonathanBrouwer
Allow passing `expr` metavariable as `cfg` predicate

This PR allows expanding `expr` metavariables inside the configuration predicates of `cfg` and `cfg_attr` invocations.
For example, the following code will now compile:

```rust
macro_rules! mac {
    ($e:expr) => {
        #[cfg_attr($e, inline)]
        #[cfg($e)]
        fn func() {}

        #[cfg(not($e))]
        fn func() {
            panic!()
        }
    }
}

mac!(any(unix, feature = "foo"));
```

There is currently no `macro_rules` fragment specifier that can represent all valid `cfg` predicates. `meta` comes closest, but excludes `true` and `false`. By fixing that, this change makes it easier to write declarative macros that parse `cfg` or `cfg_attr` invocations, for example https://github.com/rust-lang/rust/pull/146281/.

@rustbot label T-lang needs-fcp A-attributes A-cfg A-macros
2026-03-21 00:42:47 +01:00
Jonathan Brouwer 6a7aaf97b5 Rollup merge of #154155 - Enselic:async-test, r=mati865
tests/ui/async-await/drop-option-future.rs: New regression test

The test began compiling with `nightly-2022-11-25`. I bisected it further, and the commit that made it compile was 9f36f988ad (rust-lang/rust#104321). The test fails to compile with `nightly-2022-11-24`:

    $ rustc +nightly-2022-11-24 --edition 2018 tests/ui/async-await/drop-option-future.rs
    error[E0597]: `value` does not live long enough
      --> tests/ui/async-await/drop-option-future.rs:12:22
       |
    12 |     f = Some(async { value });
       |                    --^^^^^--
       |                    | |
       |                    | borrowed value does not live long enough
       |                    value captured here by generator
    13 |     core::mem::drop(f);
    14 | }
       | -
       | |
       | `value` dropped here while still borrowed
       | borrow might be used here, when `f` is dropped and runs the destructor for type `Option<impl Future<Output = i32>>`

The fix 9f36f988ad does not appear to affect or include a regression test for the rust-lang/rust#98077 case, so let's add that test.

Closes rust-lang/rust#98077 since we add the test from that issue.
2026-03-21 00:42:47 +01:00
Jonathan Brouwer edf808b524 Rollup merge of #154154 - estebank:issue-134087, r=mati865
Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings

Make all existing `:` -> `=` typo suggestions verbose and tweak the suggested code.

Stash parse errors when pasing rtn that doesn't use `(..)`.

Emit single error on `Foo::bar(qux)` that looks like rtn in incorrect position and suggest `Foo::bar(..)`.
```
error: return type notation not allowed in this position yet
  --> $DIR/let-binding-init-expr-as-ty.rs:18:10
   |
LL | struct K(S::new(()));
   |          ^^^^^^^^^^
   |
help: furthermore, argument types not allowed with return type notation
   |
LL - struct K(S::new(()));
LL + struct K(S::new(..));
   |
```
On incorrect rtn in let binding type for an existing inherent associated function, suggest `:` -> `=` to turn the "type" into a call expression. (Fix rust-lang/rust#134087)
```
error: expected type, found associated function call
  --> $DIR/let-binding-init-expr-as-ty.rs:29:12
   |
LL |     let x: S::new(());
   |            ^^^^^^^^^^
   |
help: use `=` if you meant to assign
   |
LL -     let x: S::new(());
LL +     let x = S::new(());
   |
```
2026-03-21 00:42:46 +01:00
Jules Bertholet ab36d506d2 Address review comments 2026-03-20 18:48:38 -04:00
malezjaa 27212bb09d Don't suggest non-deriveable traits for unions.
Don't suggest non-deriveable traits for unions. This also adds enum, struct and union markers to rustc_on_unimplemented
2026-03-20 23:39:28 +01:00
bors 9e0a42c7ab Auto merge of #154151 - JonathanBrouwer:rollup-qLQ5uET, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#153828 (Guard patterns: lowering to THIR)
 - rust-lang/rust#154015 (refactor - moving `check_stability` check to `parse_stability`)
 - rust-lang/rust#154119 (llvm: Update `reliable_f128` configuration for LLVM22 on Sparc)
 - rust-lang/rust#154138 (vec::Drain::fill: avoid reference to uninitialized memory)
 - rust-lang/rust#154143 (test copy_specializes_from_vecdeque: reduce iteration count for Miri)
2026-03-20 21:32:02 +00:00
Aryan Dubey 1eeba934ae Added the issue link and a test description for non-promotable-static-ref.rs 2026-03-20 16:55:28 -04:00
Aryan Dubey a3409fecfa Move issue-52049 to tests/ui/borrowck 2026-03-20 16:49:33 -04:00
Martin Nordholts e897b4ea51 tests/ui/async-await/drop-option-future.rs: New regression test
The test began compiling with `nightly-2022-11-25`, and more
specifically 9f36f988ad. The test fails to compile with
`nightly-2022-11-24`:

    $ rustc +nightly-2022-11-24 --edition 2018 tests/ui/async-await/drop-option-future.rs
    error[E0597]: `value` does not live long enough
      --> tests/ui/async-await/drop-option-future.rs:12:22
       |
    12 |     f = Some(async { value });
       |                    --^^^^^--
       |                    | |
       |                    | borrowed value does not live long enough
       |                    value captured here by generator
    13 |     core::mem::drop(f);
    14 | }
       | -
       | |
       | `value` dropped here while still borrowed
       | borrow might be used here, when `f` is dropped and runs the destructor for type `Option<impl Future<Output = i32>>`

The fix 9f36f988ad does not appear to affect or include a
regression test for our issue, so let's add that test.
2026-03-20 21:09:32 +01:00
Esteban Küber 3b27a36601 Suggest appropriate spaces around = in let binding parse error 2026-03-20 19:45:29 +00:00
Esteban Küber d48e699b6c Emit fewer errors for incorrect rtn and = -> : typos in bindings
Stash parse errors when pasing rtn that doesn't use `(..)`.
Emit single error on `Foo::bar(qux)` that looks like rtn in incorrect position and suggest `Foo::bar(..)`.
```
error: return type notation not allowed in this position yet
  --> $DIR/let-binding-init-expr-as-ty.rs:18:10
   |
LL | struct K(S::new(()));
   |          ^^^^^^^^^^
   |
help: furthermore, argument types not allowed with return type notation
   |
LL - struct K(S::new(()));
LL + struct K(S::new(..));
   |
```
On incorrect rtn in let binding type for an existing inherent associated function, suggest `:` -> `=` to turn the "type" into a call expression.
```
error: expected type, found associated function call
  --> $DIR/let-binding-init-expr-as-ty.rs:29:12
   |
LL |     let x: S::new(());
   |            ^^^^^^^^^^
   |
help: use `=` if you meant to assign
   |
LL -     let x: S::new(());
LL +     let x = S::new(());
   |
```
2026-03-20 19:33:05 +00:00
Esteban Küber 244322f0be Make : -> = typo suggestion verbose 2026-03-20 19:07:28 +00:00
Jonathan Brouwer 80faf6f746 Rollup merge of #154143 - RalfJung:miri-test, r=joboet
test copy_specializes_from_vecdeque: reduce iteration count for Miri

This test currently takes >20s and that doesn't really seem worth it.
2026-03-20 19:36:22 +01:00
Jonathan Brouwer c745d58502 Rollup merge of #154138 - RalfJung:vec-slice-uninit, r=joboet
vec::Drain::fill: avoid reference to uninitialized memory

`range_slice` points to memory that is not initialized (e.g. it might be dropped `Box`/`String`). Let's avoid that and instead use an index-based loop.
2026-03-20 19:36:22 +01:00
Jonathan Brouwer 8f79cbc307 Rollup merge of #154119 - tgross35:f128-sparc, r=cuviper
llvm: Update `reliable_f128` configuration for LLVM22 on Sparc

LLVM22 should have resolved issues with the `f128` ABI, meaning we can now set `cfg(target_has_reliable_f128)` on the platform.

Link: https://github.com/llvm/llvm-project/commit/3e16aef2a650a8c2da4ebd5c58c6a9e261361828
2026-03-20 19:36:21 +01:00
Jonathan Brouwer 7ba136f71b Rollup merge of #154015 - josetorrs:refactor-parse-stability, r=JonathanBrouwer
refactor - moving `check_stability` check to `parse_stability`

This PR is part of issue https://github.com/rust-lang/rust/issues/153101 and by extension this https://github.com/rust-lang/rust/issues/131229 as well

r? @JonathanBrouwer
2026-03-20 19:36:21 +01:00
Jonathan Brouwer d8b5b46b3f Rollup merge of #153828 - Human9000-bit:guard-patterns-thir, r=Nadrieril
Guard patterns: lowering to THIR

This pr implements lowering of guard patterns to THIR

r? @Nadrieril

cc @max-niederman

Tracking issue: rust-lang/rust#129967
2026-03-20 19:36:20 +01:00
bors ac7f9ec7da Auto merge of #151746 - jdonszelmann:eagerly-normalize-in-generalize, r=lcnr
Eagerly normalize in generalize

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/151746)*

r? @lcnr 

cc: https://github.com/rust-lang/trait-system-refactor-initiative/issues/262
2026-03-20 18:22:43 +00:00
Jose Torres 3ea7d1ece7 fixing seperate empty arm and doc comment 2026-03-20 14:03:14 -04:00
Jose 4e446d55a4 restore code comment 2026-03-20 14:03:14 -04:00
Jose c614e3d216 linting, moving error to session diagnostics 2026-03-20 14:03:12 -04:00
Jose ed6a6fddb4 refactoring stability check 2026-03-20 14:01:13 -04:00
Philipp Krones b98de10e9c Update bytes dependency in clippy_test_deps to avoid CVE warning (#16667)
Pull-requests get a warning because of

[RUSTSEC-2026-0007](https://rustsec.org/advisories/RUSTSEC-2026-0007.html).
Bumping `bytes` will silence the warning.

changelog: none

r? flip1995
2026-03-20 17:32:03 +00:00
Guillaume Gomez 0e3e647e2e Remove BuiltinDiag usage in rustc_parse 2026-03-20 17:43:18 +01:00
Guillaume Gomez bb689c41aa Create new ParseSess::dyn_buffer_lint method 2026-03-20 17:25:50 +01:00
Guillaume Gomez 9c591c6508 Start migrating DecorateDiagCompat::Builtin items to DecorateDiagCompat::Dynamic 2026-03-20 17:25:12 +01:00
Ralf Jung 9dfdb6b4bc test copy_specializes_from_vecdeque: reduce iteration count for Miri 2026-03-20 15:55:56 +01:00
bors bfc05d6b07 Auto merge of #154137 - JonathanBrouwer:rollup-hTMxxjl, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#154103 (coretests: Expand ieee754 parsing and printing tests to f16)
 - rust-lang/rust#152669 (rustc_public: add `vtable_entries()` to `TraitRef`)
 - rust-lang/rust#153776 (Remove redundant `is_dyn_thread_safe` checks)
 - rust-lang/rust#154121 (Fix typos and markdown errors)
 - rust-lang/rust#154126 (refactor(attribute parser): move check_custom_mir to attribute parser)
2026-03-20 14:18:58 +00:00
Jana Dönszelmann d665c0b371 address review 2026-03-20 14:02:24 +01:00
Jonathan Brouwer e106b584bd Rollup merge of #154126 - JayanAXHF:refactor/custom_mir_parser, r=JonathanBrouwer
refactor(attribute parser): move check_custom_mir to attribute parser

Part of rust-lang/rust#153101

r? @JonathanBrouwer
2026-03-20 13:24:27 +01:00