mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Rollup merge of #105710 - compiler-errors:dyn-star-rigid-cast, r=eholk
Don't bug if we're trying to cast `dyn*` to another type Fixes #105097
This commit is contained in:
commit
86bbc20146
@ -847,13 +847,15 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
|
||||
(Int(_) | Float, Int(_) | Float) => Ok(CastKind::NumericCast),
|
||||
|
||||
(_, DynStar) | (DynStar, _) => {
|
||||
(_, DynStar) => {
|
||||
if fcx.tcx.features().dyn_star {
|
||||
bug!("should be handled by `try_coerce`")
|
||||
} else {
|
||||
Err(CastError::IllegalCast)
|
||||
}
|
||||
}
|
||||
|
||||
(DynStar, _) => Err(CastError::IllegalCast),
|
||||
}
|
||||
}
|
||||
|
||||
|
11
src/test/ui/dyn-star/dyn-to-rigid.rs
Normal file
11
src/test/ui/dyn-star/dyn-to-rigid.rs
Normal file
@ -0,0 +1,11 @@
|
||||
#![feature(dyn_star)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Tr {}
|
||||
|
||||
fn f(x: dyn* Tr) -> usize {
|
||||
x as usize
|
||||
//~^ ERROR casting `(dyn* Tr + 'static)` as `usize` is invalid
|
||||
}
|
||||
|
||||
fn main() {}
|
9
src/test/ui/dyn-star/dyn-to-rigid.stderr
Normal file
9
src/test/ui/dyn-star/dyn-to-rigid.stderr
Normal file
@ -0,0 +1,9 @@
|
||||
error[E0606]: casting `(dyn* Tr + 'static)` as `usize` is invalid
|
||||
--> $DIR/dyn-to-rigid.rs:7:5
|
||||
|
|
||||
LL | x as usize
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0606`.
|
Loading…
Reference in New Issue
Block a user