about summary refs log tree commit diff
path: root/tests/ui/diagnostic_namespace
diff options
context:
space:
mode:
authorGeorg Semmler <github@weiznich.de>2024-05-29 08:59:06 +0200
committerGeorg Semmler <github@weiznich.de>2024-05-29 22:59:53 +0200
commitf9adc1ee9d5b94d4ccb744cf686091c16849a4ee (patch)
treeb059207115ac70ac0aeb05c7638d925274220425 /tests/ui/diagnostic_namespace
parent751691271d76b8435559200b84d1947c2bd735bd (diff)
downloadrust-f9adc1ee9d5b94d4ccb744cf686091c16849a4ee.tar.gz
rust-f9adc1ee9d5b94d4ccb744cf686091c16849a4ee.zip
Refactor `#[diagnostic::do_not_recommend]` support
This commit refactors the `#[do_not_recommend]` support in the old
parser to also apply to projection errors and not only to selection
errors. This allows the attribute to be used more widely.
Diffstat (limited to 'tests/ui/diagnostic_namespace')
-rw-r--r--tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.current.stderr15
-rw-r--r--tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.next.stderr15
-rw-r--r--tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.rs27
3 files changed, 57 insertions, 0 deletions
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.current.stderr
new file mode 100644
index 00000000000..bcede8a255f
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.current.stderr
@@ -0,0 +1,15 @@
+error[E0277]: Very important message!
+  --> $DIR/type_mismatch.rs:25:14
+   |
+LL |     verify::<u8>();
+   |              ^^ the trait `TheImportantOne` is not implemented for `u8`
+   |
+note: required by a bound in `verify`
+  --> $DIR/type_mismatch.rs:22:14
+   |
+LL | fn verify<T: TheImportantOne>() {}
+   |              ^^^^^^^^^^^^^^^ required by this bound in `verify`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.next.stderr
new file mode 100644
index 00000000000..bcede8a255f
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.next.stderr
@@ -0,0 +1,15 @@
+error[E0277]: Very important message!
+  --> $DIR/type_mismatch.rs:25:14
+   |
+LL |     verify::<u8>();
+   |              ^^ the trait `TheImportantOne` is not implemented for `u8`
+   |
+note: required by a bound in `verify`
+  --> $DIR/type_mismatch.rs:22:14
+   |
+LL | fn verify<T: TheImportantOne>() {}
+   |              ^^^^^^^^^^^^^^^ required by this bound in `verify`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.rs b/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.rs
new file mode 100644
index 00000000000..d6721ccc848
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/do_not_recommend/type_mismatch.rs
@@ -0,0 +1,27 @@
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+
+#![feature(do_not_recommend)]
+
+#[diagnostic::on_unimplemented(message = "Very important message!")]
+trait TheImportantOne {}
+
+trait ImplementationDetail {
+    type Restriction;
+}
+
+#[diagnostic::do_not_recommend]
+impl<T: ImplementationDetail<Restriction = ()>> TheImportantOne for T {}
+
+// Comment out this `impl` to show the expected error message.
+impl ImplementationDetail for u8 {
+    type Restriction = u8;
+}
+
+fn verify<T: TheImportantOne>() {}
+
+pub fn main() {
+    verify::<u8>();
+    //~^ERROR: Very important message! [E0277]
+}