Skip to content

Rollup of 5 pull requests#154159

Closed
JonathanBrouwer wants to merge 14 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-vy1lvtP
Closed

Rollup of 5 pull requests#154159
JonathanBrouwer wants to merge 14 commits intorust-lang:mainfrom
JonathanBrouwer:rollup-vy1lvtP

Conversation

@JonathanBrouwer
Copy link
Contributor

Successful merges:

r? @ghost

Create a similar rollup

Jules-Bertholet and others added 14 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

cc 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`
```
…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 b07997c has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 20, 2026
@JonathanBrouwer
Copy link
Contributor Author

Trying commonly failed jobs
@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 20, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

⌛ Trying commit b07997c with merge 7856567

To cancel the try build, run the command @bors try cancel.

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

rust-bors bot pushed a commit that referenced this pull request Mar 20, 2026
Rollup of 5 pull requests


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 20, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 20, 2026

This pull request was unapproved due to being closed.

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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

7 participants