Rollup merge of #103788 - chenyukang:yukang/fix-ice-103783, r=compiler-errors
Fix ICE in checking transmutability of NaughtyLenArray Fixes #103783
This commit is contained in:
commit
ff89ceca1f
@ -284,7 +284,8 @@ pub fn from_ty(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Result<Self, Err> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ty::Array(ty, len) => {
|
ty::Array(ty, len) => {
|
||||||
let len = len.try_eval_usize(tcx, ParamEnv::reveal_all()).unwrap();
|
let len =
|
||||||
|
len.try_eval_usize(tcx, ParamEnv::reveal_all()).ok_or(Err::Unspecified)?;
|
||||||
let elt = Tree::from_ty(*ty, tcx)?;
|
let elt = Tree::from_ty(*ty, tcx)?;
|
||||||
Ok(std::iter::repeat(elt)
|
Ok(std::iter::repeat(elt)
|
||||||
.take(len as usize)
|
.take(len as usize)
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
#![crate_type = "lib"]
|
||||||
|
#![feature(transmutability)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
mod assert {
|
||||||
|
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||||
|
pub struct Context;
|
||||||
|
|
||||||
|
pub fn is_maybe_transmutable<Src, Dst>()
|
||||||
|
where
|
||||||
|
Dst: BikeshedIntrinsicFrom<
|
||||||
|
Src,
|
||||||
|
Context,
|
||||||
|
{ Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||||
|
>,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test() {
|
||||||
|
type NaughtyLenArray = [u32; 3.14159]; //~ ERROR mismatched types
|
||||||
|
type JustUnit = ();
|
||||||
|
assert::is_maybe_transmutable::<JustUnit, NaughtyLenArray>();
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/issue-103783-array-length.rs:21:34
|
||||||
|
|
|
||||||
|
LL | type NaughtyLenArray = [u32; 3.14159];
|
||||||
|
| ^^^^^^^ expected `usize`, found floating-point number
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user