add test for #[test] attribute only allowed on non associated functions
This commit is contained in:
parent
0671bdb1eb
commit
2b7c3fb725
2 changed files with 30 additions and 0 deletions
19
src/test/ui/test-attr-non-associated-functions.rs
Normal file
19
src/test/ui/test-attr-non-associated-functions.rs
Normal 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() {}
|
11
src/test/ui/test-attr-non-associated-functions.stderr
Normal file
11
src/test/ui/test-attr-non-associated-functions.stderr
Normal 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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue