-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow ambiguous attributes on expressions
- Loading branch information
Showing
13 changed files
with
126 additions
and
34 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
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