casting b"text"
to * const u8
doesn't work in const_eval
This commit is contained in:
parent
68d399d7e3
commit
7461e450b9
@ -1117,6 +1117,12 @@ fn cast_const<'tcx>(tcx: &TyCtxt<'tcx>, val: ConstVal, ty: ty::Ty) -> CastResult
|
||||
Float(f) => cast_const_float(tcx, f, ty),
|
||||
Char(c) => cast_const_int(tcx, Infer(c as u64), ty),
|
||||
Function(_) => Err(UnimplementedConstVal("casting fn pointers")),
|
||||
ByteStr(_) => match ty.sty {
|
||||
ty::TyRawPtr(_) => {
|
||||
Err(ErrKind::UnimplementedConstVal("casting a bytestr to a raw ptr"))
|
||||
},
|
||||
_ => Err(CannotCast),
|
||||
},
|
||||
_ => Err(CannotCast),
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#![deny(const_err)]
|
||||
|
||||
const X: *const u8 = b"" as _;
|
||||
|
||||
fn main() {
|
||||
let _ = ((-1 as i8) << 8 - 1) as f32;
|
||||
|
Loading…
x
Reference in New Issue
Block a user