about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGeorg Semmler <github@weiznich.de>2023-12-23 14:02:01 +0100
committerGeorg Semmler <github@weiznich.de>2024-01-05 15:23:10 +0100
commit91e1af38623e05c52591aae2aa4a213553907ea0 (patch)
tree679b2e6ab7a113591f531fe7c703106f8b3895dc
parent2c3aeea1baf4eed29f131f53e852532d8e3833c3 (diff)
downloadrust-91e1af38623e05c52591aae2aa4a213553907ea0.tar.gz
rust-91e1af38623e05c52591aae2aa4a213553907ea0.zip
Add a test that emitting diagnostics does not require the crate to use
the corresponding feature.
-rw-r--r--tests/ui/diagnostic_namespace/on_unimplemented/auxiliary/other.rs8
-rw-r--r--tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.rs12
-rw-r--r--tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.stderr19
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/auxiliary/other.rs b/tests/ui/diagnostic_namespace/on_unimplemented/auxiliary/other.rs
new file mode 100644
index 00000000000..884bab2800a
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/on_unimplemented/auxiliary/other.rs
@@ -0,0 +1,8 @@
+#![feature(diagnostic_namespace)]
+
+#[diagnostic::on_unimplemented(
+    message = "Message",
+    note = "Note",
+    label = "label"
+)]
+pub trait Foo {}
diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.rs b/tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.rs
new file mode 100644
index 00000000000..b39375a09f3
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.rs
@@ -0,0 +1,12 @@
+// aux-build:other.rs
+
+extern crate other;
+
+use other::Foo;
+
+fn take_foo(_: impl Foo) {}
+
+fn main() {
+    take_foo(());
+    //~^ERROR Message
+}
diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.stderr
new file mode 100644
index 00000000000..a9968538d0d
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/on_unimplemented/error_is_shown_in_downstream_crates.stderr
@@ -0,0 +1,19 @@
+error[E0277]: Message
+  --> $DIR/error_is_shown_in_downstream_crates.rs:10:14
+   |
+LL |     take_foo(());
+   |     -------- ^^ label
+   |     |
+   |     required by a bound introduced by this call
+   |
+   = help: the trait `Foo` is not implemented for `()`
+   = note: Note
+note: required by a bound in `take_foo`
+  --> $DIR/error_is_shown_in_downstream_crates.rs:7:21
+   |
+LL | fn take_foo(_: impl Foo) {}
+   |                     ^^^ required by this bound in `take_foo`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.