about summary refs log tree commit diff
path: root/tests/ui/diagnostic_namespace
diff options
context:
space:
mode:
authormejrs <59372212+mejrs@users.noreply.github.com>2025-05-23 18:52:18 +0200
committermejrs <59372212+mejrs@users.noreply.github.com>2025-06-09 16:28:57 +0200
commit70f78fb2ba2b5ada70dfda2ea219483e545816c7 (patch)
tree53189efb5db3790b7b3d69117546d42a7f800eda /tests/ui/diagnostic_namespace
parent44f415c1d617ebc7b931a243b7b321ef8a6ca47c (diff)
downloadrust-70f78fb2ba2b5ada70dfda2ea219483e545816c7.tar.gz
rust-70f78fb2ba2b5ada70dfda2ea219483e545816c7.zip
Add test for flailing diagnostic spans
Diffstat (limited to 'tests/ui/diagnostic_namespace')
-rw-r--r--tests/ui/diagnostic_namespace/multiline_spans.rs53
-rw-r--r--tests/ui/diagnostic_namespace/multiline_spans.stderr61
2 files changed, 114 insertions, 0 deletions
diff --git a/tests/ui/diagnostic_namespace/multiline_spans.rs b/tests/ui/diagnostic_namespace/multiline_spans.rs
new file mode 100644
index 00000000000..97dd07b2bf3
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/multiline_spans.rs
@@ -0,0 +1,53 @@
+#![crate_type = "lib"]
+#![deny(unknown_or_malformed_diagnostic_attributes)]
+
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+                                         multiline string \
+                                         {unknown}")]
+//~^^ ERROR there is no parameter `unknown` on trait `MultiLine` [unknown_or_malformed_diagnostic_attributes]
+pub trait MultiLine {}
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+                                         multiline string {unknown}")]
+//~^ ERROR there is no parameter `unknown` on trait `MultiLine2` [unknown_or_malformed_diagnostic_attributes]
+pub trait MultiLine2 {}
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+    multiline string {unknown}")]
+//~^ ERROR there is no parameter `unknown` on trait `MultiLine3` [unknown_or_malformed_diagnostic_attributes]
+pub trait MultiLine3 {}
+
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+\
+                \
+                                \
+                                                \
+    multiline string {unknown}")]
+//~^^^^ ERROR there is no parameter `unknown` on trait `MultiLine4` [unknown_or_malformed_diagnostic_attributes]
+pub trait MultiLine4 {}
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+                                         multiline string \
+                                         {Self:+}")]
+//~^^^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
+pub trait MultiLineFmt {}
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+                                         multiline string {Self:X}")]
+pub trait MultiLineFmt2 {}
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+    multiline string {Self:#}")]
+//~^^ ERROR invalid format specifier [unknown_or_malformed_diagnostic_attributes]
+pub trait MultiLineFmt3 {}
+
+
+#[diagnostic::on_unimplemented(message = "here is a big \
+\
+                \
+                                \
+                                                \
+    multiline string {Self:?}")]
+pub trait MultiLineFmt4 {}
diff --git a/tests/ui/diagnostic_namespace/multiline_spans.stderr b/tests/ui/diagnostic_namespace/multiline_spans.stderr
new file mode 100644
index 00000000000..8d86560b66c
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/multiline_spans.stderr
@@ -0,0 +1,61 @@
+error: there is no parameter `unknown` on trait `MultiLine`
+  --> $DIR/multiline_spans.rs:6:17
+   |
+LL | ...                   multiline string \
+   | ^^^^^^^
+   |
+   = help: expect either a generic argument name or `{Self}` as format argument
+note: the lint level is defined here
+  --> $DIR/multiline_spans.rs:2:9
+   |
+LL | #![deny(unknown_or_malformed_diagnostic_attributes)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: there is no parameter `unknown` on trait `MultiLine2`
+  --> $DIR/multiline_spans.rs:12:17
+   |
+LL | ...                   multiline string {unknown}")]
+   | ^^^^^^^
+   |
+   = help: expect either a generic argument name or `{Self}` as format argument
+
+error: there is no parameter `unknown` on trait `MultiLine3`
+  --> $DIR/multiline_spans.rs:17:17
+   |
+LL |     multiline string {unknown}")]
+   |                 ^^^^^^^
+   |
+   = help: expect either a generic argument name or `{Self}` as format argument
+
+error: there is no parameter `unknown` on trait `MultiLine4`
+  --> $DIR/multiline_spans.rs:24:15
+   |
+LL | /                 \
+LL | |                                 \
+   | |___^
+   |
+   = help: expect either a generic argument name or `{Self}` as format argument
+
+error: invalid format specifier
+  --> $DIR/multiline_spans.rs:31:42
+   |
+LL |   #[diagnostic::on_unimplemented(message = "here is a big \
+   |  __________________________________________^
+LL | |                                          multiline string \
+LL | |                                          {Self:+}")]
+   | |__________________________________________________^
+   |
+   = help: no format specifier are supported in this position
+
+error: invalid format specifier
+  --> $DIR/multiline_spans.rs:41:42
+   |
+LL |   #[diagnostic::on_unimplemented(message = "here is a big \
+   |  __________________________________________^
+LL | |     multiline string {Self:#}")]
+   | |______________________________^
+   |
+   = help: no format specifier are supported in this position
+
+error: aborting due to 6 previous errors
+