1
Fork 0

add test for #[test] attribute only allowed on non associated functions

This commit is contained in:
giacomo 2018-11-17 11:39:58 +01:00
parent 0671bdb1eb
commit 2b7c3fb725
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,19 @@
// #[test] attribute is not allowed on associated functions or methods
// reworded error message
// compile-flags:--test
struct A {}
impl A {
#[test]
fn new() -> A { //~ ERROR #[test] attribute is only allowed on non associated functions
A {}
}
}
#[test]
fn test() {
let _ = A::new();
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: #[test] attribute is only allowed on non associated functions
--> $DIR/test-attr-non-associated-functions.rs:9:2
|
LL | fn new() -> A { //~ ERROR #[test] attribute is only allowed on non associated functions
| _____^
LL | | A {}
LL | | }
| |_____^
error: aborting due to previous error