Don't allow implement CoerceUnsized into dyn-star

This commit is contained in:
Michael Goulet 2022-10-22 03:41:09 +00:00
parent a3c0a02361
commit 0af211af67
3 changed files with 19 additions and 1 deletions

View File

@ -840,7 +840,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// `T` -> `Trait`
(_, &ty::Dynamic(..)) => {
(_, &ty::Dynamic(_, _, ty::Dyn)) => {
candidates.vec.push(BuiltinUnsizeCandidate);
}

View File

@ -0,0 +1,9 @@
#![feature(dyn_star)]
#![allow(incomplete_features)]
use std::fmt::Debug;
fn main() {
let i = 42 as &dyn* Debug;
//~^ ERROR non-primitive cast: `i32` as `&dyn* Debug`
}

View File

@ -0,0 +1,9 @@
error[E0605]: non-primitive cast: `i32` as `&dyn* Debug`
--> $DIR/unsize-into-ref-dyn-star.rs:7:13
|
LL | let i = 42 as &dyn* Debug;
| ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
error: aborting due to previous error
For more information about this error, try `rustc --explain E0605`.