diff options
| author | giacomo <g.pasini98@gmail.com> | 2018-11-17 11:39:58 +0100 |
|---|---|---|
| committer | giacomo <g.pasini98@gmail.com> | 2018-11-17 11:39:58 +0100 |
| commit | 2b7c3fb725c4fe5ce968d62b3e07ebc74ffd82a3 (patch) | |
| tree | 34fc14f3771db498cab4fd4fcb8793cf3ac1d864 /src/test | |
| parent | 0671bdb1ebf61a2d8528738392e0a01c1436d49f (diff) | |
| download | rust-2b7c3fb725c4fe5ce968d62b3e07ebc74ffd82a3.tar.gz rust-2b7c3fb725c4fe5ce968d62b3e07ebc74ffd82a3.zip | |
add test for #[test] attribute only allowed on non associated functions
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/test-attr-non-associated-functions.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/test-attr-non-associated-functions.stderr | 11 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/test-attr-non-associated-functions.rs b/src/test/ui/test-attr-non-associated-functions.rs new file mode 100644 index 00000000000..872dbd89770 --- /dev/null +++ b/src/test/ui/test-attr-non-associated-functions.rs @@ -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() {} \ No newline at end of file diff --git a/src/test/ui/test-attr-non-associated-functions.stderr b/src/test/ui/test-attr-non-associated-functions.stderr new file mode 100644 index 00000000000..780a119a666 --- /dev/null +++ b/src/test/ui/test-attr-non-associated-functions.stderr @@ -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 + |
