@@ -2209,25 +2209,104 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2209
2209
}
2210
2210
}
2211
2211
}
2212
-
2213
- CastKind :: Misc => {
2212
+ CastKind :: IntToInt => {
2214
2213
let ty_from = op. ty ( body, tcx) ;
2215
2214
let cast_ty_from = CastTy :: from_ty ( ty_from) ;
2216
2215
let cast_ty_to = CastTy :: from_ty ( * ty) ;
2217
- // Misc casts are either between floats and ints, or one ptr type to another.
2218
2216
match ( cast_ty_from, cast_ty_to) {
2219
- (
2220
- Some ( CastTy :: Int ( _) | CastTy :: Float ) ,
2221
- Some ( CastTy :: Int ( _) | CastTy :: Float ) ,
2222
- )
2223
- | ( Some ( CastTy :: Ptr ( _) | CastTy :: FnPtr ) , Some ( CastTy :: Ptr ( _) ) ) => ( ) ,
2217
+ ( Some ( CastTy :: Int ( _) ) , Some ( CastTy :: Int ( _) ) ) => ( ) ,
2224
2218
_ => {
2225
2219
span_mirbug ! (
2226
2220
self ,
2227
2221
rvalue,
2228
- "Invalid Misc cast {:?} -> {:?}" ,
2222
+ "Invalid IntToInt cast {:?} -> {:?}" ,
2229
2223
ty_from,
2230
- ty,
2224
+ ty
2225
+ )
2226
+ }
2227
+ }
2228
+ }
2229
+ CastKind :: IntToFloat => {
2230
+ let ty_from = op. ty ( body, tcx) ;
2231
+ let cast_ty_from = CastTy :: from_ty ( ty_from) ;
2232
+ let cast_ty_to = CastTy :: from_ty ( * ty) ;
2233
+ match ( cast_ty_from, cast_ty_to) {
2234
+ ( Some ( CastTy :: Int ( _) ) , Some ( CastTy :: Float ) ) => ( ) ,
2235
+ _ => {
2236
+ span_mirbug ! (
2237
+ self ,
2238
+ rvalue,
2239
+ "Invalid IntToFloat cast {:?} -> {:?}" ,
2240
+ ty_from,
2241
+ ty
2242
+ )
2243
+ }
2244
+ }
2245
+ }
2246
+ CastKind :: FloatToInt => {
2247
+ let ty_from = op. ty ( body, tcx) ;
2248
+ let cast_ty_from = CastTy :: from_ty ( ty_from) ;
2249
+ let cast_ty_to = CastTy :: from_ty ( * ty) ;
2250
+ match ( cast_ty_from, cast_ty_to) {
2251
+ ( Some ( CastTy :: Float ) , Some ( CastTy :: Int ( _) ) ) => ( ) ,
2252
+ _ => {
2253
+ span_mirbug ! (
2254
+ self ,
2255
+ rvalue,
2256
+ "Invalid FloatToInt cast {:?} -> {:?}" ,
2257
+ ty_from,
2258
+ ty
2259
+ )
2260
+ }
2261
+ }
2262
+ }
2263
+ CastKind :: FloatToFloat => {
2264
+ let ty_from = op. ty ( body, tcx) ;
2265
+ let cast_ty_from = CastTy :: from_ty ( ty_from) ;
2266
+ let cast_ty_to = CastTy :: from_ty ( * ty) ;
2267
+ match ( cast_ty_from, cast_ty_to) {
2268
+ ( Some ( CastTy :: Float ) , Some ( CastTy :: Float ) ) => ( ) ,
2269
+ _ => {
2270
+ span_mirbug ! (
2271
+ self ,
2272
+ rvalue,
2273
+ "Invalid FloatToFloat cast {:?} -> {:?}" ,
2274
+ ty_from,
2275
+ ty
2276
+ )
2277
+ }
2278
+ }
2279
+ }
2280
+ CastKind :: FnPtrToPtr => {
2281
+ let ty_from = op. ty ( body, tcx) ;
2282
+ let cast_ty_from = CastTy :: from_ty ( ty_from) ;
2283
+ let cast_ty_to = CastTy :: from_ty ( * ty) ;
2284
+ match ( cast_ty_from, cast_ty_to) {
2285
+ ( Some ( CastTy :: FnPtr ) , Some ( CastTy :: Ptr ( _) ) ) => ( ) ,
2286
+ _ => {
2287
+ span_mirbug ! (
2288
+ self ,
2289
+ rvalue,
2290
+ "Invalid FnPtrToPtr cast {:?} -> {:?}" ,
2291
+ ty_from,
2292
+ ty
2293
+ )
2294
+ }
2295
+ }
2296
+ }
2297
+ CastKind :: PtrToPtr => {
2298
+ let ty_from = op. ty ( body, tcx) ;
2299
+ let cast_ty_from = CastTy :: from_ty ( ty_from) ;
2300
+ let cast_ty_to = CastTy :: from_ty ( * ty) ;
2301
+ match ( cast_ty_from, cast_ty_to) {
2302
+ ( Some ( CastTy :: Ptr ( _) ) , Some ( CastTy :: Ptr ( _) ) ) => ( ) ,
2303
+ _ => {
2304
+ span_mirbug ! (
2305
+ self ,
2306
+ rvalue,
2307
+ "Invalid PtrToPtr cast {:?} -> {:?}" ,
2308
+ ty_from,
2309
+ ty
2231
2310
)
2232
2311
}
2233
2312
}
0 commit comments