about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-03-20 02:52:07 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-05-03 13:33:53 +0300
commit1443c7646d37eb69c434268ec8b27cd0cf82d9f2 (patch)
treecf73ba71c11ff4aafcc88db6efb49209cf564cbf /src/test/ui/parser
parente327a823d8b64e294e490efeca7829f383aa119d (diff)
downloadrust-1443c7646d37eb69c434268ec8b27cd0cf82d9f2.tar.gz
rust-1443c7646d37eb69c434268ec8b27cd0cf82d9f2.zip
parser: Remove support for inner attributes on non-block expressions
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/stmt_expr_attrs_placement.rs16
-rw-r--r--src/test/ui/parser/stmt_expr_attrs_placement.stderr58
2 files changed, 73 insertions, 1 deletions
diff --git a/src/test/ui/parser/stmt_expr_attrs_placement.rs b/src/test/ui/parser/stmt_expr_attrs_placement.rs
index b8a794f4b92..d488cd0c2d3 100644
--- a/src/test/ui/parser/stmt_expr_attrs_placement.rs
+++ b/src/test/ui/parser/stmt_expr_attrs_placement.rs
@@ -8,15 +8,31 @@ fn main() {
     //~^ ERROR an inner attribute is not permitted in this context
 
     let b = (#![allow(warnings)] 1, 2);
+    //~^ ERROR an inner attribute is not permitted in this context
 
     let c = {
         #![allow(warnings)]
         (#![allow(warnings)] 1, 2)
+        //~^ ERROR an inner attribute is not permitted in this context
     };
 
     let d = {
         #![allow(warnings)]
         let e = (#![allow(warnings)] 1, 2);
+        //~^ ERROR an inner attribute is not permitted in this context
         e
     };
+
+    let e = [#![allow(warnings)] 1, 2];
+    //~^ ERROR an inner attribute is not permitted in this context
+
+    let f = [#![allow(warnings)] 1; 0];
+    //~^ ERROR an inner attribute is not permitted in this context
+
+    let g = match true { #![allow(warnings)] _ => {} };
+    //~^ ERROR an inner attribute is not permitted in this context
+
+    struct MyStruct { field: u8 }
+    let h = MyStruct { #![allow(warnings)] field: 0 };
+    //~^ ERROR an inner attribute is not permitted in this context
 }
diff --git a/src/test/ui/parser/stmt_expr_attrs_placement.stderr b/src/test/ui/parser/stmt_expr_attrs_placement.stderr
index 1886a0f9ba0..185cc009640 100644
--- a/src/test/ui/parser/stmt_expr_attrs_placement.stderr
+++ b/src/test/ui/parser/stmt_expr_attrs_placement.stderr
@@ -6,5 +6,61 @@ LL |     let a = #![allow(warnings)] (1, 2);
    |
    = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
 
-error: aborting due to previous error
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:10:14
+   |
+LL |     let b = (#![allow(warnings)] 1, 2);
+   |              ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:15:10
+   |
+LL |         (#![allow(warnings)] 1, 2)
+   |          ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:21:18
+   |
+LL |         let e = (#![allow(warnings)] 1, 2);
+   |                  ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:26:14
+   |
+LL |     let e = [#![allow(warnings)] 1, 2];
+   |              ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:29:14
+   |
+LL |     let f = [#![allow(warnings)] 1; 0];
+   |              ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:32:26
+   |
+LL |     let g = match true { #![allow(warnings)] _ => {} };
+   |                          ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: an inner attribute is not permitted in this context
+  --> $DIR/stmt_expr_attrs_placement.rs:36:24
+   |
+LL |     let h = MyStruct { #![allow(warnings)] field: 0 };
+   |                        ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
+
+error: aborting due to 8 previous errors