defatalize expand_test_or_bench
This commit is contained in:
parent
0e0f9311da
commit
3979964200
@ -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 {
|
||||
|
@ -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 {}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user