forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#124099 - voidc:disallow-ambiguous-expr-attr…
…s, r=davidtwco Disallow ambiguous attributes on expressions This implements the suggestion in [rust-lang#15701](rust-lang#15701 (comment)) to disallow ambiguous outer attributes on expressions. This should resolve one of the concerns blocking the stabilization of `stmt_expr_attributes`.
- Loading branch information
Showing
15 changed files
with
141 additions
and
49 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ run-rustfix | ||
#![feature(stmt_expr_attributes)] | ||
#![allow(unused_assignments, unused_attributes)] | ||
|
||
fn main() { | ||
let mut x = (#[deprecated] 1) + 2; //~ ERROR ambiguous | ||
|
||
(#[deprecated] x) = 4; //~ ERROR ambiguous | ||
|
||
x = (#[deprecated] 5) as i32; //~ ERROR ambiguous | ||
|
||
let _r = (#[deprecated] 1)..6; //~ ERROR ambiguous | ||
|
||
println!("{}", x); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ run-rustfix | ||
#![feature(stmt_expr_attributes)] | ||
#![allow(unused_assignments, unused_attributes)] | ||
|
||
fn main() { | ||
let mut x = #[deprecated] 1 + 2; //~ ERROR ambiguous | ||
|
||
#[deprecated] x = 4; //~ ERROR ambiguous | ||
|
||
x = #[deprecated] 5 as i32; //~ ERROR ambiguous | ||
|
||
let _r = #[deprecated] 1..6; //~ ERROR ambiguous | ||
|
||
println!("{}", x); | ||
} |
46 changes: 46 additions & 0 deletions
46
tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
error: ambiguous outer attributes | ||
--> $DIR/attr-binary-expr-ambigous.rs:6:17 | ||
| | ||
LL | let mut x = #[deprecated] 1 + 2; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: wrap the expression in parentheses | ||
| | ||
LL | let mut x = (#[deprecated] 1) + 2; | ||
| + + | ||
|
||
error: ambiguous outer attributes | ||
--> $DIR/attr-binary-expr-ambigous.rs:8:5 | ||
| | ||
LL | #[deprecated] x = 4; | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: wrap the expression in parentheses | ||
| | ||
LL | (#[deprecated] x) = 4; | ||
| + + | ||
|
||
error: ambiguous outer attributes | ||
--> $DIR/attr-binary-expr-ambigous.rs:10:9 | ||
| | ||
LL | x = #[deprecated] 5 as i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: wrap the expression in parentheses | ||
| | ||
LL | x = (#[deprecated] 5) as i32; | ||
| + + | ||
|
||
error: ambiguous outer attributes | ||
--> $DIR/attr-binary-expr-ambigous.rs:12:14 | ||
| | ||
LL | let _r = #[deprecated] 1..6; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: wrap the expression in parentheses | ||
| | ||
LL | let _r = (#[deprecated] 1)..6; | ||
| + + | ||
|
||
error: aborting due to 4 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