Skip to content

Commit 5a42b65

Browse files
committed
defatalize expand_test_or_bench
1 parent c440890 commit 5a42b65

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

src/librustc_builtin_macros/test.rs

+8-8
Original file line numberDiff line numberDiff 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 {

src/test/ui/test-attrs/test-attr-non-associated-functions.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ struct A {}
66

77
impl 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
}

src/test/ui/test-attrs/test-attr-non-associated-functions.stderr

+11-1
Original file line numberDiff line numberDiff 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
|
44
LL | / fn new() -> A {
5+
LL | |
56
LL | | A {}
67
LL | | }
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

0 commit comments

Comments
 (0)