diff options
| author | Michael Goulet <michael@errs.io> | 2022-11-19 04:48:01 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-11-24 01:10:24 +0000 |
| commit | c620a972f3bae8171e17eb8a243b419caadd9ab7 (patch) | |
| tree | a6ed01263d6ad7420e52e5fed47dcac11ad4a03d /src/test/ui | |
| parent | 70f8737b2f5d3bf7d6b784fad00b663b7ff9feda (diff) | |
| download | rust-c620a972f3bae8171e17eb8a243b419caadd9ab7.tar.gz rust-c620a972f3bae8171e17eb8a243b419caadd9ab7.zip | |
Disable dyn* upcasting
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr | 23 | ||||
| -rw-r--r-- | src/test/ui/dyn-star/upcast.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/dyn-star/upcast.stderr | 20 |
4 files changed, 57 insertions, 2 deletions
diff --git a/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs new file mode 100644 index 00000000000..a4eb669e321 --- /dev/null +++ b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.rs @@ -0,0 +1,13 @@ +#![feature(dyn_star, trait_upcasting)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +trait A: B {} +trait B {} +impl A for usize {} +impl B for usize {} + +fn main() { + let x: Box<dyn* A> = Box::new(1usize as dyn* A); + let y: Box<dyn* B> = x; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr new file mode 100644 index 00000000000..2fc751b3b4a --- /dev/null +++ b/src/test/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr @@ -0,0 +1,23 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/no-unsize-coerce-dyn-trait.rs:1:12 + | +LL | #![feature(dyn_star, trait_upcasting)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/no-unsize-coerce-dyn-trait.rs:11:26 + | +LL | let y: Box<dyn* B> = x; + | ----------- ^ expected trait `B`, found trait `A` + | | + | expected due to this + | + = note: expected struct `Box<dyn* B>` + found struct `Box<dyn* A>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/dyn-star/upcast.rs b/src/test/ui/dyn-star/upcast.rs index cee76ada7df..24c077047e9 100644 --- a/src/test/ui/dyn-star/upcast.rs +++ b/src/test/ui/dyn-star/upcast.rs @@ -1,7 +1,6 @@ -// run-pass +// known-bug: unknown #![feature(dyn_star, trait_upcasting)] -#![allow(incomplete_features)] trait Foo: Bar { fn hello(&self); diff --git a/src/test/ui/dyn-star/upcast.stderr b/src/test/ui/dyn-star/upcast.stderr new file mode 100644 index 00000000000..6a95f7754e6 --- /dev/null +++ b/src/test/ui/dyn-star/upcast.stderr @@ -0,0 +1,20 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/upcast.rs:3:12 + | +LL | #![feature(dyn_star, trait_upcasting)] + | ^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: `dyn* Foo` needs to be a pointer-sized type + --> $DIR/upcast.rs:30:23 + | +LL | let w: dyn* Bar = w; + | ^ `dyn* Foo` needs to be a pointer-sized type + | + = help: the trait `PointerSized` is not implemented for `dyn* Foo` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. |
