]> git.lizzy.rs Git - rust.git/commitdiff
defatalize expand_test_or_bench
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 17 Mar 2020 12:27:56 +0000 (13:27 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Tue, 24 Mar 2020 05:28:56 +0000 (06:28 +0100)
src/librustc_builtin_macros/test.rs
src/test/ui/test-attrs/test-attr-non-associated-functions.rs
src/test/ui/test-attrs/test-attr-non-associated-functions.stderr

index 39009ca27f102d46cc050ae5b162f77e8679e6a7..bdc4ae2fe274b9598ef2cca04a10e1b578714b11 100644 (file)
@@ -74,16 +74,16 @@ pub fn expand_test_or_bench(
         return vec![];
     }
 
-    let item = if let Annotatable::Item(i) = item {
-        i
-    } else {
-        cx.parse_sess
-            .span_diagnostic
-            .span_fatal(
-                item.span(),
+    let item = match item {
+        Annotatable::Item(i) => i,
+        other => {
+            cx.struct_span_err(
+                other.span(),
                 "`#[test]` attribute is only allowed on non associated functions",
             )
-            .raise();
+            .emit();
+            return vec![other];
+        }
     };
 
     if let ast::ItemKind::MacCall(_) = item.kind {
index e475f5b4a75a515f7d97b02a1583ce120617bc94..31e567c396067495eb1e8c9b55d7cda283faa659 100644 (file)
@@ -6,7 +6,13 @@ struct A {}
 
 impl A {
     #[test]
-    fn new() -> A { //~ ERROR `#[test]` attribute is only allowed on non associated functions
+    fn new() -> A {
+        //~^ ERROR `#[test]` attribute is only allowed on non associated functions
+        A {}
+    }
+    #[test]
+    fn recovery_witness() -> A {
+        //~^ ERROR `#[test]` attribute is only allowed on non associated functions
         A {}
     }
 }
index cb3ae51823e45bd993f6500b2f54613be44306ee..a81b8f3980c374c7bc7c1112fc2a260d5a03f813 100644 (file)
@@ -2,9 +2,19 @@ error: `#[test]` attribute is only allowed on non associated functions
   --> $DIR/test-attr-non-associated-functions.rs:9:5
    |
 LL | /     fn new() -> A {
+LL | |
 LL | |         A {}
 LL | |     }
    | |_____^
 
-error: aborting due to previous error
+error: `#[test]` attribute is only allowed on non associated functions
+  --> $DIR/test-attr-non-associated-functions.rs:14:5
+   |
+LL | /     fn recovery_witness() -> A {
+LL | |
+LL | |         A {}
+LL | |     }
+   | |_____^
+
+error: aborting due to 2 previous errors