@@ -9,7 +9,6 @@ use rustc_middle::ty::adjustment::PointerCoercion;
99use rustc_middle:: ty:: layout:: { IntegerExt , LayoutOf , TyAndLayout } ;
1010use rustc_middle:: ty:: { self , FloatTy , Ty } ;
1111use rustc_middle:: { bug, span_bug} ;
12- use rustc_type_ir:: TyKind :: * ;
1312use tracing:: trace;
1413
1514use super :: util:: ensure_monomorphic_enough;
@@ -182,9 +181,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
182181 src : & ImmTy < ' tcx , M :: Provenance > ,
183182 cast_to : TyAndLayout < ' tcx > ,
184183 ) -> InterpResult < ' tcx , ImmTy < ' tcx , M :: Provenance > > {
185- use rustc_type_ir:: TyKind :: * ;
186-
187- let Float ( fty) = src. layout . ty . kind ( ) else {
184+ let ty:: Float ( fty) = src. layout . ty . kind ( ) else {
188185 bug ! ( "FloatToFloat/FloatToInt cast: source type {} is not a float type" , src. layout. ty)
189186 } ;
190187 let val = match fty {
@@ -277,27 +274,27 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
277274 let signed = src_layout. backend_repr . is_signed ( ) ; // Also asserts that abi is `Scalar`.
278275
279276 let v = match src_layout. ty . kind ( ) {
280- Uint ( _) | RawPtr ( ..) | FnPtr ( ..) => scalar. to_uint ( src_layout. size ) ?,
281- Int ( _) => scalar. to_int ( src_layout. size ) ? as u128 , // we will cast back to `i128` below if the sign matters
282- Bool => scalar. to_bool ( ) ?. into ( ) ,
283- Char => scalar. to_char ( ) ?. into ( ) ,
277+ ty :: Uint ( _) | ty :: RawPtr ( ..) | ty :: FnPtr ( ..) => scalar. to_uint ( src_layout. size ) ?,
278+ ty :: Int ( _) => scalar. to_int ( src_layout. size ) ? as u128 , // we will cast back to `i128` below if the sign matters
279+ ty :: Bool => scalar. to_bool ( ) ?. into ( ) ,
280+ ty :: Char => scalar. to_char ( ) ?. into ( ) ,
284281 _ => span_bug ! ( self . cur_span( ) , "invalid int-like cast from {}" , src_layout. ty) ,
285282 } ;
286283
287284 interp_ok ( match * cast_ty. kind ( ) {
288285 // int -> int
289- Int ( _) | Uint ( _) => {
286+ ty :: Int ( _) | ty :: Uint ( _) => {
290287 let size = match * cast_ty. kind ( ) {
291- Int ( t) => Integer :: from_int_ty ( self , t) . size ( ) ,
292- Uint ( t) => Integer :: from_uint_ty ( self , t) . size ( ) ,
288+ ty :: Int ( t) => Integer :: from_int_ty ( self , t) . size ( ) ,
289+ ty :: Uint ( t) => Integer :: from_uint_ty ( self , t) . size ( ) ,
293290 _ => bug ! ( ) ,
294291 } ;
295292 let v = size. truncate ( v) ;
296293 Scalar :: from_uint ( v, size)
297294 }
298295
299296 // signed int -> float
300- Float ( fty) if signed => {
297+ ty :: Float ( fty) if signed => {
301298 let v = v as i128 ;
302299 match fty {
303300 FloatTy :: F16 => Scalar :: from_f16 ( Half :: from_i128 ( v) . value ) ,
@@ -307,15 +304,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
307304 }
308305 }
309306 // unsigned int -> float
310- Float ( fty) => match fty {
307+ ty :: Float ( fty) => match fty {
311308 FloatTy :: F16 => Scalar :: from_f16 ( Half :: from_u128 ( v) . value ) ,
312309 FloatTy :: F32 => Scalar :: from_f32 ( Single :: from_u128 ( v) . value ) ,
313310 FloatTy :: F64 => Scalar :: from_f64 ( Double :: from_u128 ( v) . value ) ,
314311 FloatTy :: F128 => Scalar :: from_f128 ( Quad :: from_u128 ( v) . value ) ,
315312 } ,
316313
317314 // u8 -> char
318- Char => Scalar :: from_u32 ( u8:: try_from ( v) . unwrap ( ) . into ( ) ) ,
315+ ty :: Char => Scalar :: from_u32 ( u8:: try_from ( v) . unwrap ( ) . into ( ) ) ,
319316
320317 // Casts to bool are not permitted by rustc, no need to handle them here.
321318 _ => span_bug ! ( self . cur_span( ) , "invalid int to {} cast" , cast_ty) ,
@@ -332,11 +329,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
332329 + FloatConvert < Double >
333330 + FloatConvert < Quad > ,
334331 {
335- use rustc_type_ir:: TyKind :: * ;
336-
337332 match * dest_ty. kind ( ) {
338333 // float -> uint
339- Uint ( t) => {
334+ ty :: Uint ( t) => {
340335 let size = Integer :: from_uint_ty ( self , t) . size ( ) ;
341336 // `to_u128` is a saturating cast, which is what we need
342337 // (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
@@ -345,15 +340,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
345340 Scalar :: from_uint ( v, size)
346341 }
347342 // float -> int
348- Int ( t) => {
343+ ty :: Int ( t) => {
349344 let size = Integer :: from_int_ty ( self , t) . size ( ) ;
350345 // `to_i128` is a saturating cast, which is what we need
351346 // (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
352347 let v = f. to_i128 ( size. bits_usize ( ) ) . value ;
353348 Scalar :: from_int ( v, size)
354349 }
355350 // float -> float
356- Float ( fty) => match fty {
351+ ty :: Float ( fty) => match fty {
357352 FloatTy :: F16 => {
358353 Scalar :: from_f16 ( self . adjust_nan ( f. convert ( & mut false ) . value , & [ f] ) )
359354 }
0 commit comments