Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/core/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ unsafe impl<T: ?Sized> DerefPure for &mut T {}
/// ```
#[lang = "receiver"]
#[unstable(feature = "arbitrary_self_types", issue = "44874")]
#[rustc_dyn_incompatible_trait]
pub trait Receiver: PointeeSized {
/// The target type on which the method may be called.
#[rustc_diagnostic_item = "receiver_target"]
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/self/arbitrary-self-types-dyn-receiver.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
//@ 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???");
}
}

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();
}
85 changes: 85 additions & 0 deletions tests/ui/self/arbitrary-self-types-dyn-receiver.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Loading