This commit is contained in:
Alice Ryhl
2026-09-07 13:56:42 +00:00
parent c317698ed6
commit 40bbaeaed1
2 changed files with 92 additions and 1 deletions

View File

@@ -1,15 +1,20 @@
//@ run-pass
//@ check-fail
#![feature(arbitrary_self_types)]
use std::ops::Receiver;
trait Trait {
fn foo(self: &dyn Receiver<Target=Self>);
//~^ 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<Target=Self>) {
//~^ 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<Target=Thing> = &x;
//~^ ERROR: the trait `std::ops::Receiver` is not dyn compatible
y.foo();
}

View File

@@ -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<Target=Self>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $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<Target=Self>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $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<Target=Self>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `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 <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $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<Target=Self>) {
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<Target=Self>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $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<Target=Self>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `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 <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $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<Target=Self>);
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<Target=Thing> = &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 <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $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`.