Skip to content

Rollup of 6 pull requests#154160

Open
JonathanBrouwer wants to merge 18 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-4jbkEbt
Open

Rollup of 6 pull requests#154160
JonathanBrouwer wants to merge 18 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-4jbkEbt

Conversation

@JonathanBrouwer
Copy link
Contributor

Successful merges:

r? @ghost

Create a similar rollup

Jules-Bertholet and others added 18 commits March 15, 2026 13:44
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(());
   |
```
The test began compiling with `nightly-2022-11-25`, and more
specifically 9f36f98. 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 9f36f98 does not appear to affect or include a
regression test for our issue, so let's add that test.
Don't suggest non-deriveable traits for unions. This also adds enum, struct and union markers to rustc_on_unimplemented
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#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(());
   |
```
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 9f36f98 (rust-lang#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 9f36f98 does not appear to affect or include a regression test for the rust-lang#98077 case, so let's add that test.

Closes rust-lang#98077 since we add the test from that issue.
…anBrouwer

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 rust-lang#146281.

@rustbot label T-lang needs-fcp A-attributes A-cfg A-macros
…for-unions, r=JonathanBrouwer

don't suggest non-deriveable traits for unions

Fixes rust-lang#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`
```
…athanBrouwer

Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`

Part of rust-lang#153099.

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

r? @JonathanBrouwer
…wck, r=Kivooeo

Moving issue-52049 to borrowck
@rust-bors rust-bors bot added the rollup A PR which is a rollup label Mar 20, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 20, 2026
@JonathanBrouwer
Copy link
Contributor Author

@bors r+ rollup=never p=5

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

📌 Commit 6d2a545 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2026
@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Mar 21, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - #154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - #146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - #154118 (don't suggest non-deriveable traits for unions)
 - #154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - #154156 (Moving issue-52049 to borrowck)
@rust-bors rust-bors bot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 21, 2026
@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 21, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 21, 2026

💔 Test for 31a2ed3 failed: CI. Failed job:

@jhpratt
Copy link
Member

jhpratt commented Mar 21, 2026

seemingly spurious

@bors retry

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 21, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 21, 2026

⌛ Testing commit 6d2a545 with merge e52f547...

Workflow: https://github.com/rust-lang/rust/actions/runs/23374697808

rust-bors bot pushed a commit that referenced this pull request Mar 21, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154154 (Emit fewer errors for incorrect rtn and `=` -> `:` typos in bindings)
 - #154155 (tests/ui/async-await/drop-option-future.rs: New regression test)
 - #146961 (Allow passing `expr` metavariable as `cfg` predicate)
 - #154118 (don't suggest non-deriveable traits for unions)
 - #154120 (Start migrating `DecorateDiagCompat::Builtin` items to `DecorateDiagCompat::Dynamic`)
 - #154156 (Moving issue-52049 to borrowck)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants