Skip to content

Commit

Permalink
add test for #[test] attribute only allowed on non associated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zeegomo committed Nov 17, 2018
1 parent 0671bdb commit 2b7c3fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/ui/test-attr-non-associated-functions.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions src/test/ui/test-attr-non-associated-functions.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2b7c3fb

Please sign in to comment.