diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2021-04-03 18:46:25 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2021-04-03 19:42:09 +0300 |
| commit | cd22425990462d55dbd01a432dfd2aa517d5ca9c (patch) | |
| tree | 46f2fa75fef5f91ca8c43fc96baad37879f9be34 /src/test | |
| parent | 97717a561844eccbb6d6cc114adb94a8fa4e0172 (diff) | |
| download | rust-cd22425990462d55dbd01a432dfd2aa517d5ca9c.tar.gz rust-cd22425990462d55dbd01a432dfd2aa517d5ca9c.zip | |
expand: Do not ICE when a legacy AST-based macro attribute produces and empty expression
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/macros/attr-empty-expr.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/macros/attr-empty-expr.stderr | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/macros/attr-empty-expr.rs b/src/test/ui/macros/attr-empty-expr.rs new file mode 100644 index 00000000000..d4d1a3ee71e --- /dev/null +++ b/src/test/ui/macros/attr-empty-expr.rs @@ -0,0 +1,11 @@ +// AST-based macro attributes expanding to an empty expression produce an error and not ICE. + +#![feature(custom_test_frameworks)] +#![feature(stmt_expr_attributes)] +#![feature(test)] + +fn main() { + let _ = #[test] 0; //~ ERROR removing an expression is not supported in this position + let _ = #[bench] 1; //~ ERROR removing an expression is not supported in this position + let _ = #[test_case] 2; //~ ERROR removing an expression is not supported in this position +} diff --git a/src/test/ui/macros/attr-empty-expr.stderr b/src/test/ui/macros/attr-empty-expr.stderr new file mode 100644 index 00000000000..53721053bcc --- /dev/null +++ b/src/test/ui/macros/attr-empty-expr.stderr @@ -0,0 +1,20 @@ +error: removing an expression is not supported in this position + --> $DIR/attr-empty-expr.rs:8:13 + | +LL | let _ = #[test] 0; + | ^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/attr-empty-expr.rs:9:13 + | +LL | let _ = #[bench] 1; + | ^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/attr-empty-expr.rs:10:13 + | +LL | let _ = #[test_case] 2; + | ^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + |
