forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#126571 - nnethercote:less-maybe_whole-expr-2,…
… r=<try> Less `maybe_whole_expr`, take 2 I first tried this in rust-lang#107550. I now think it's worth doing again, as a precursor to #1241414. r? `@petrochenkov`
- Loading branch information
Showing
20 changed files
with
132 additions
and
159 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
error: arbitrary expressions aren't allowed in patterns | ||
--> $DIR/issue-43250.rs:9:8 | ||
error: expected pattern, found expression `y` | ||
--> $DIR/issue-43250.rs:6:17 | ||
| | ||
LL | let $a = 0; | ||
| ^^ expected pattern | ||
... | ||
LL | m!(y); | ||
| ^ | ||
| ----- in this macro invocation | ||
| | ||
= note: the `expr` fragment specifier forces the metavariable's content to be an expression | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: arbitrary expressions aren't allowed in patterns | ||
--> $DIR/issue-43250.rs:11:8 | ||
error: expected pattern, found expression `C` | ||
--> $DIR/issue-43250.rs:6:17 | ||
| | ||
LL | let $a = 0; | ||
| ^^ expected pattern | ||
... | ||
LL | m!(C); | ||
| ^ | ||
| ----- in this macro invocation | ||
| | ||
= note: the `expr` fragment specifier forces the metavariable's content to be an expression | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
macro_rules! foo { | ||
($p:expr) => { | ||
if let $p = Some(42) { | ||
if let $p = Some(42) { //~ ERROR expected pattern, found expression `Some(3)` | ||
return; | ||
} | ||
}; | ||
} | ||
|
||
fn main() { | ||
foo!(Some(3)); //~ ERROR arbitrary expressions aren't allowed in patterns | ||
foo!(Some(3)); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
error: arbitrary expressions aren't allowed in patterns | ||
--> $DIR/expr-in-pat-issue-99380.rs:10:10 | ||
error: expected pattern, found expression `Some(3)` | ||
--> $DIR/expr-in-pat-issue-99380.rs:3:16 | ||
| | ||
LL | if let $p = Some(42) { | ||
| ^^ expected pattern | ||
... | ||
LL | foo!(Some(3)); | ||
| ^^^^^^^ | ||
| ------------- in this macro invocation | ||
| | ||
= note: the `expr` fragment specifier forces the metavariable's content to be an expression | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
error: arbitrary expressions aren't allowed in patterns | ||
error: expected pattern, found expression `< [_] > :: into_vec(#[rustc_box] $crate :: boxed :: Box :: new([43]))` | ||
--> $DIR/vec-macro-in-pattern.rs:7:14 | ||
| | ||
LL | Some(vec![43]) => {} | ||
| ^^^^^^^^ | ||
| | | ||
| expected pattern | ||
| in this macro invocation | ||
| this macro call doesn't expand to a pattern | ||
| | ||
= note: the `expr` fragment specifier forces the metavariable's content to be an expression | ||
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= note: this error originates in the macro `$crate::__rust_force_expr` which comes from the expansion of the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
error[E0425]: cannot find value `a` in this scope | ||
--> $DIR/expr_before_ident_pat.rs:10:12 | ||
error: expected pattern, found expression `a` | ||
--> $DIR/expr_before_ident_pat.rs:4:14 | ||
| | ||
LL | [$a, $b] => {} | ||
| ^^ expected pattern | ||
... | ||
LL | funny!(a, a); | ||
| ^ not found in this scope | ||
|
||
error: arbitrary expressions aren't allowed in patterns | ||
--> $DIR/expr_before_ident_pat.rs:10:12 | ||
| | ||
LL | funny!(a, a); | ||
| ^ | ||
| ------------ in this macro invocation | ||
| | ||
= note: the `expr` fragment specifier forces the metavariable's content to be an expression | ||
= note: this error originates in the macro `funny` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
This file contains 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
Oops, something went wrong.