about summary refs log tree commit diff
path: root/tests/ui/cast
diff options
context:
space:
mode:
authorMaybe Lapkin <waffle.lapkin@gmail.com>2024-07-04 16:46:00 +0200
committerMaybe Lapkin <waffle.lapkin@gmail.com>2024-07-04 17:57:31 +0200
commitdc420a282b0cbfb717e1958bc28cc8ba0e335d6f (patch)
treee5bf0991cf6f51c62b8236d1053b0b424655681a /tests/ui/cast
parentb16f8034316d4cd1d4a8766899d8cf30f7d73730 (diff)
downloadrust-dc420a282b0cbfb717e1958bc28cc8ba0e335d6f.tar.gz
rust-dc420a282b0cbfb717e1958bc28cc8ba0e335d6f.zip
Use `DiagSymbolList` for a lint diagnostic
Diffstat (limited to 'tests/ui/cast')
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-add-auto.rs7
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-add-auto.stderr22
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/ui/cast/ptr-to-trait-obj-add-auto.rs b/tests/ui/cast/ptr-to-trait-obj-add-auto.rs
index 75b56816984..70293b28ee0 100644
--- a/tests/ui/cast/ptr-to-trait-obj-add-auto.rs
+++ b/tests/ui/cast/ptr-to-trait-obj-add-auto.rs
@@ -8,4 +8,11 @@ fn add_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send) {
     //~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 }
 
+// (to test diagnostic list formatting)
+fn add_multiple_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send + Sync + Unpin) {
+    x as _
+    //~^ warning: adding auto traits `Sync`, `Send`, and `Unpin` to a trait object in a pointer cast may cause UB later on
+    //~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+}
+
 fn main() {}
diff --git a/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr b/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr
index ff8c7057c96..beb71eb100b 100644
--- a/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr
+++ b/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr
@@ -8,7 +8,16 @@ LL |     x as _
    = note: for more information, see issue #125289 <https://github.com/rust-lang/rust/issues/125289>
    = note: `#[warn(ptr_cast_add_auto_to_object)]` on by default
 
-warning: 1 warning emitted
+warning: adding auto traits `Sync`, `Send`, and `Unpin` to a trait object in a pointer cast may cause UB later on
+  --> $DIR/ptr-to-trait-obj-add-auto.rs:13:5
+   |
+LL |     x as _
+   |     ^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #125289 <https://github.com/rust-lang/rust/issues/125289>
+
+warning: 2 warnings emitted
 
 Future incompatibility report: Future breakage diagnostic:
 warning: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
@@ -21,3 +30,14 @@ LL |     x as _
    = note: for more information, see issue #125289 <https://github.com/rust-lang/rust/issues/125289>
    = note: `#[warn(ptr_cast_add_auto_to_object)]` on by default
 
+Future breakage diagnostic:
+warning: adding auto traits `Sync`, `Send`, and `Unpin` to a trait object in a pointer cast may cause UB later on
+  --> $DIR/ptr-to-trait-obj-add-auto.rs:13:5
+   |
+LL |     x as _
+   |     ^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #125289 <https://github.com/rust-lang/rust/issues/125289>
+   = note: `#[warn(ptr_cast_add_auto_to_object)]` on by default
+