about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/test-attr-non-associated-functions.rs19
-rw-r--r--src/test/ui/test-attr-non-associated-functions.stderr11
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
+