about summary refs log tree commit diff
path: root/tests/ui/diagnostic_namespace
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-05-07 23:12:22 -0400
committerMichael Goulet <michael@errs.io>2024-05-07 23:13:44 -0400
commita8f2e33eec57d56477c45396e4860f92247f353a (patch)
tree63d534d0668af038b6c05a2c51d5502716805e4b /tests/ui/diagnostic_namespace
parenta60f077c38fe66d05449919842d3d73e3299bbab (diff)
downloadrust-a8f2e33eec57d56477c45396e4860f92247f353a.tar.gz
rust-a8f2e33eec57d56477c45396e4860f92247f353a.zip
Add more ICEs due to malformed diagnostic::on_unimplemented
Diffstat (limited to 'tests/ui/diagnostic_namespace')
-rw-r--r--tests/ui/diagnostic_namespace/auxiliary/bad_on_unimplemented.rs26
-rw-r--r--tests/ui/diagnostic_namespace/malformed_foreign_on_unimplemented.rs31
-rw-r--r--tests/ui/diagnostic_namespace/on_unimplemented_ice.rs17
-rw-r--r--tests/ui/diagnostic_namespace/on_unimplemented_ice.stderr17
4 files changed, 56 insertions, 35 deletions
diff --git a/tests/ui/diagnostic_namespace/auxiliary/bad_on_unimplemented.rs b/tests/ui/diagnostic_namespace/auxiliary/bad_on_unimplemented.rs
index 4a5fca43e36..e44c7e4e850 100644
--- a/tests/ui/diagnostic_namespace/auxiliary/bad_on_unimplemented.rs
+++ b/tests/ui/diagnostic_namespace/auxiliary/bad_on_unimplemented.rs
@@ -1,2 +1,26 @@
 #[diagnostic::on_unimplemented(aa = "broken")]
-pub trait Test {}
+pub trait MissingAttr {}
+
+#[diagnostic::on_unimplemented(label = "a", label = "b")]
+pub trait DuplicateAttr {}
+
+#[diagnostic::on_unimplemented = "broken"]
+pub trait NotMetaList {}
+
+#[diagnostic::on_unimplemented]
+pub trait Empty {}
+
+#[diagnostic::on_unimplemented {}]
+pub trait WrongDelim {}
+
+#[diagnostic::on_unimplemented(label = "{A:.3}")]
+pub trait BadFormatter<A> {}
+
+#[diagnostic::on_unimplemented(label = "test {}")]
+pub trait NoImplicitArgs {}
+
+#[diagnostic::on_unimplemented(label = "{missing}")]
+pub trait MissingArg {}
+
+#[diagnostic::on_unimplemented(label = "{_}")]
+pub trait BadArg {}
diff --git a/tests/ui/diagnostic_namespace/malformed_foreign_on_unimplemented.rs b/tests/ui/diagnostic_namespace/malformed_foreign_on_unimplemented.rs
new file mode 100644
index 00000000000..8b7467a17d0
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/malformed_foreign_on_unimplemented.rs
@@ -0,0 +1,31 @@
+//@ edition:2021
+//@ aux-build:bad_on_unimplemented.rs
+
+// Do not ICE when encountering a malformed `#[diagnostic::on_unimplemented]` annotation in a
+// dependency when incorrectly used (#124651).
+
+extern crate bad_on_unimplemented;
+
+use bad_on_unimplemented::*;
+
+fn missing_attr<T: MissingAttr>(_: T) {}
+fn duplicate_attr<T: DuplicateAttr>(_: T) {}
+fn not_meta_list<T: NotMetaList>(_: T) {}
+fn empty<T: Empty>(_: T) {}
+fn wrong_delim<T: WrongDelim>(_: T) {}
+fn bad_formatter<T: BadFormatter<()>>(_: T) {}
+fn no_implicit_args<T: NoImplicitArgs>(_: T) {}
+fn missing_arg<T: MissingArg>(_: T) {}
+fn bad_arg<T: BadArg>(_: T) {}
+
+fn main() {
+    missing_attr(()); //~ ERROR E0277
+    duplicate_attr(()); //~ ERROR E0277
+    not_meta_list(()); //~ ERROR E0277
+    empty(()); //~ ERROR E0277
+    wrong_delim(()); //~ ERROR E0277
+    bad_formatter(()); //~ ERROR E0277
+    no_implicit_args(()); //~ ERROR E0277
+    missing_arg(()); //~ ERROR E0277
+    bad_arg(()); //~ ERROR E0277
+}
diff --git a/tests/ui/diagnostic_namespace/on_unimplemented_ice.rs b/tests/ui/diagnostic_namespace/on_unimplemented_ice.rs
deleted file mode 100644
index 8969f5030e2..00000000000
--- a/tests/ui/diagnostic_namespace/on_unimplemented_ice.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-//@ edition:2021
-//@ compile-flags:--test
-//@ aux-build:bad_on_unimplemented.rs
-
-// Do not ICE when encountering a malformed `#[diagnostic::on_unimplemented]` annotation in a
-// dependency when incorrectly used (#124651).
-
-extern crate bad_on_unimplemented;
-
-use bad_on_unimplemented::Test;
-
-fn breakage<T: Test>(_: T) {}
-
-#[test]
-fn test() {
-    breakage(1); //~ ERROR E0277
-}
diff --git a/tests/ui/diagnostic_namespace/on_unimplemented_ice.stderr b/tests/ui/diagnostic_namespace/on_unimplemented_ice.stderr
deleted file mode 100644
index 1c0da96abd9..00000000000
--- a/tests/ui/diagnostic_namespace/on_unimplemented_ice.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0277]: the trait bound `{integer}: Test` is not satisfied
-  --> $DIR/on_unimplemented_ice.rs:16:14
-   |
-LL |     breakage(1);
-   |     -------- ^ the trait `Test` is not implemented for `{integer}`
-   |     |
-   |     required by a bound introduced by this call
-   |
-note: required by a bound in `breakage`
-  --> $DIR/on_unimplemented_ice.rs:12:16
-   |
-LL | fn breakage<T: Test>(_: T) {}
-   |                ^^^^ required by this bound in `breakage`
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0277`.