]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / ui / lint / semicolon-in-expressions-from-macros / semicolon-in-expressions-from-macros.rs
index 0bbd7dc6c8a7aff906f98990f7c63997aa00d879..fff380934e8e9be3f682b211f087d1576ae8f79b 100644 (file)
@@ -1,14 +1,17 @@
 // check-pass
 // edition:2018
+#![feature(stmt_expr_attributes)]
 #![warn(semicolon_in_expressions_from_macros)]
 
 #[allow(dead_code)]
 macro_rules! foo {
     ($val:ident) => {
-        true; //~ WARN trailing
-              //~| WARN this was previously
-              //~| WARN trailing
-              //~| WARN this was previously
+        true; //~  WARN trailing semicolon in macro
+              //~| WARN this was previously accepted
+              //~| WARN trailing semicolon in macro
+              //~| WARN this was previously accepted
+              //~| WARN trailing semicolon in macro
+              //~| WARN this was previously accepted
     }
 }
 
@@ -18,17 +21,14 @@ async fn bar() {
 }
 
 fn main() {
-    // This `allow` doesn't work
     #[allow(semicolon_in_expressions_from_macros)]
     let _ = {
         foo!(first)
     };
 
-    // This 'allow' doesn't work either
     #[allow(semicolon_in_expressions_from_macros)]
     let _ = foo!(second);
 
-    // But this 'allow' does
     #[allow(semicolon_in_expressions_from_macros)]
     fn inner() {
         let _ = foo!(third);
@@ -38,4 +38,14 @@ fn main() {
     async {
         let _ = foo!(fourth);
     };
+
+    let _ = {
+        foo!(warn_in_block)
+    };
+
+    let _ = foo!(warn_in_expr);
+
+    // This `#[allow]` does not work, since the attribute gets dropped
+    // when we expand the macro
+    let _ = #[allow(semicolon_in_expressions_from_macros)] foo!(allow_does_not_work);
 }