Rollup of 6 pull requests#154160
Open
JonathanBrouwer wants to merge 18 commits intorust-lang:mainfrom
Open
Conversation
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
Contributor
Author
|
@bors r+ rollup=never p=5 |
Contributor
This comment has been minimized.
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)
Contributor
|
💔 Test for 31a2ed3 failed: CI. Failed job:
|
Member
|
seemingly spurious @bors retry |
Contributor
|
⌛ 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
=->:typos in bindings #154154 (Emit fewer errors for incorrect rtn and=->:typos in bindings)exprmetavariable ascfgpredicate #146961 (Allow passingexprmetavariable ascfgpredicate)DecorateDiagCompat::Builtinitems toDecorateDiagCompat::Dynamic#154120 (Start migratingDecorateDiagCompat::Builtinitems toDecorateDiagCompat::Dynamic)r? @ghost
Create a similar rollup