about summary refs log tree commit diff
path: root/tests/ui/parser/attribute
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-24 06:37:41 +0000
committerbors <bors@rust-lang.org>2024-04-24 06:37:41 +0000
commita3fddf2384f9dc0d67252a2ec3481c8e27121aa3 (patch)
tree24d179c88d79c08cb94c57cca50cdfaa7579c1a3 /tests/ui/parser/attribute
parent26faaa30475a1be4cc26e13882e8d943df91f3d1 (diff)
parent7e968351aa7abb766f56640f7dd9460749ef6f2b (diff)
Auto merge of #3506 - rust-lang:rustup-2024-04-24, r=RalfJung
Automatic Rustup
Diffstat (limited to 'tests/ui/parser/attribute')
-rw-r--r--tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed15
-rw-r--r--tests/ui/parser/attribute/attr-binary-expr-ambigous.rs15
-rw-r--r--tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr46
3 files changed, 76 insertions, 0 deletions
diff --git a/tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed b/tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed
new file mode 100644
index 00000000000..aae71ede771
--- /dev/null
+++ b/tests/ui/parser/attribute/attr-binary-expr-ambigous.fixed
@@ -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);
+}
diff --git a/tests/ui/parser/attribute/attr-binary-expr-ambigous.rs b/tests/ui/parser/attribute/attr-binary-expr-ambigous.rs
new file mode 100644
index 00000000000..613e01d743b
--- /dev/null
+++ b/tests/ui/parser/attribute/attr-binary-expr-ambigous.rs
@@ -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);
+}
diff --git a/tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr b/tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr
new file mode 100644
index 00000000000..0430570fd49
--- /dev/null
+++ b/tests/ui/parser/attribute/attr-binary-expr-ambigous.stderr
@@ -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
+