From 40bbaeaed1017cbb9f8cabcbc4ec69fc915cb070 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Mon, 7 Sep 2026 13:56:42 +0000 Subject: [PATCH] Fix test --- .../self/arbitrary-self-types-dyn-receiver.rs | 8 +- .../arbitrary-self-types-dyn-receiver.stderr | 85 +++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/ui/self/arbitrary-self-types-dyn-receiver.stderr diff --git a/tests/ui/self/arbitrary-self-types-dyn-receiver.rs b/tests/ui/self/arbitrary-self-types-dyn-receiver.rs index fe128301d49..3be08611c9e 100644 --- a/tests/ui/self/arbitrary-self-types-dyn-receiver.rs +++ b/tests/ui/self/arbitrary-self-types-dyn-receiver.rs @@ -1,15 +1,20 @@ -//@ run-pass +//@ check-fail #![feature(arbitrary_self_types)] use std::ops::Receiver; trait Trait { fn foo(self: &dyn Receiver); + //~^ ERROR: the trait `std::ops::Receiver` is not dyn compatible + //~| ERROR: the trait `std::ops::Receiver` is not dyn compatible } struct Thing; impl Trait for Thing { fn foo(self: &dyn Receiver) { + //~^ ERROR: the trait `std::ops::Receiver` is not dyn compatible + //~| ERROR: the trait `std::ops::Receiver` is not dyn compatible + //~| ERROR: the trait `std::ops::Receiver` is not dyn compatible println!("huh???"); } } @@ -17,5 +22,6 @@ impl Trait for Thing { fn main() { let x = Box::new(Thing); let y: &dyn Receiver = &x; + //~^ ERROR: the trait `std::ops::Receiver` is not dyn compatible y.foo(); } diff --git a/tests/ui/self/arbitrary-self-types-dyn-receiver.stderr b/tests/ui/self/arbitrary-self-types-dyn-receiver.stderr new file mode 100644 index 00000000000..24acb56ffb1 --- /dev/null +++ b/tests/ui/self/arbitrary-self-types-dyn-receiver.stderr @@ -0,0 +1,85 @@ +error[E0038]: the trait `std::ops::Receiver` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-receiver.rs:14:5 + | +LL | fn foo(self: &dyn Receiver) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::ops::Receiver` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: the trait is not dyn compatible because it opted out of dyn-compatibility + +error[E0038]: the trait `std::ops::Receiver` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-receiver.rs:14:18 + | +LL | fn foo(self: &dyn Receiver) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::ops::Receiver` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: the trait is not dyn compatible because it opted out of dyn-compatibility + +error[E0038]: the trait `std::ops::Receiver` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-receiver.rs:14:19 + | +LL | fn foo(self: &dyn Receiver) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ `std::ops::Receiver` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: the trait is not dyn compatible because it opted out of dyn-compatibility +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn foo(self: &dyn Receiver) { +LL + fn foo(self: &Self) { + | + +error[E0038]: the trait `std::ops::Receiver` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-receiver.rs:7:18 + | +LL | fn foo(self: &dyn Receiver); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::ops::Receiver` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: the trait is not dyn compatible because it opted out of dyn-compatibility + +error[E0038]: the trait `std::ops::Receiver` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-receiver.rs:7:19 + | +LL | fn foo(self: &dyn Receiver); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ `std::ops::Receiver` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: the trait is not dyn compatible because it opted out of dyn-compatibility +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn foo(self: &dyn Receiver); +LL + fn foo(self: &Self); + | + +error[E0038]: the trait `std::ops::Receiver` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-receiver.rs:24:17 + | +LL | let y: &dyn Receiver = &x; + | ^^^^^^^^^^^^^^^^^^^^^^ `std::ops::Receiver` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: the trait is not dyn compatible because it opted out of dyn-compatibility + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0038`.