File tree Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -74,16 +74,16 @@ pub fn expand_test_or_bench(
7474 return vec ! [ ] ;
7575 }
7676
77- let item = if let Annotatable :: Item ( i) = item {
78- i
79- } else {
80- cx. parse_sess
81- . span_diagnostic
82- . span_fatal (
83- item. span ( ) ,
77+ let item = match item {
78+ Annotatable :: Item ( i) => i,
79+ other => {
80+ cx. struct_span_err (
81+ other. span ( ) ,
8482 "`#[test]` attribute is only allowed on non associated functions" ,
8583 )
86- . raise ( ) ;
84+ . emit ( ) ;
85+ return vec ! [ other] ;
86+ }
8787 } ;
8888
8989 if let ast:: ItemKind :: MacCall ( _) = item. kind {
Original file line number Diff line number Diff line change @@ -6,7 +6,13 @@ struct A {}
66
77impl A {
88 #[ test]
9- fn new ( ) -> A { //~ ERROR `#[test]` attribute is only allowed on non associated functions
9+ fn new ( ) -> A {
10+ //~^ ERROR `#[test]` attribute is only allowed on non associated functions
11+ A { }
12+ }
13+ #[ test]
14+ fn recovery_witness ( ) -> A {
15+ //~^ ERROR `#[test]` attribute is only allowed on non associated functions
1016 A { }
1117 }
1218}
Original file line number Diff line number Diff line change @@ -2,9 +2,19 @@ error: `#[test]` attribute is only allowed on non associated functions
22 --> $DIR/test-attr-non-associated-functions.rs:9:5
33 |
44LL | / fn new() -> A {
5+ LL | |
56LL | | A {}
67LL | | }
78 | |_____^
89
9- error: aborting due to previous error
10+ error: `#[test]` attribute is only allowed on non associated functions
11+ --> $DIR/test-attr-non-associated-functions.rs:14:5
12+ |
13+ LL | / fn recovery_witness() -> A {
14+ LL | |
15+ LL | | A {}
16+ LL | | }
17+ | |_____^
18+
19+ error: aborting due to 2 previous errors
1020
You can’t perform that action at this time.
0 commit comments