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(
74
74
return vec ! [ ] ;
75
75
}
76
76
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 ( ) ,
84
82
"`#[test]` attribute is only allowed on non associated functions" ,
85
83
)
86
- . raise ( ) ;
84
+ . emit ( ) ;
85
+ return vec ! [ other] ;
86
+ }
87
87
} ;
88
88
89
89
if let ast:: ItemKind :: MacCall ( _) = item. kind {
Original file line number Diff line number Diff line change @@ -6,7 +6,13 @@ struct A {}
6
6
7
7
impl A {
8
8
#[ 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
10
16
A { }
11
17
}
12
18
}
Original file line number Diff line number Diff line change @@ -2,9 +2,19 @@ error: `#[test]` attribute is only allowed on non associated functions
2
2
--> $DIR/test-attr-non-associated-functions.rs:9:5
3
3
|
4
4
LL | / fn new() -> A {
5
+ LL | |
5
6
LL | | A {}
6
7
LL | | }
7
8
| |_____^
8
9
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
10
20
You can’t perform that action at this time.
0 commit comments