Skip to content

Commit 2b7c3fb

Browse files
committed
add test for #[test] attribute only allowed on non associated functions
1 parent 0671bdb commit 2b7c3fb

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// #[test] attribute is not allowed on associated functions or methods
2+
// reworded error message
3+
// compile-flags:--test
4+
5+
struct A {}
6+
7+
impl A {
8+
#[test]
9+
fn new() -> A { //~ ERROR #[test] attribute is only allowed on non associated functions
10+
A {}
11+
}
12+
}
13+
14+
#[test]
15+
fn test() {
16+
let _ = A::new();
17+
}
18+
19+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: #[test] attribute is only allowed on non associated functions
2+
--> $DIR/test-attr-non-associated-functions.rs:9:2
3+
|
4+
LL | fn new() -> A { //~ ERROR #[test] attribute is only allowed on non associated functions
5+
| _____^
6+
LL | | A {}
7+
LL | | }
8+
| |_____^
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)