@@ -1056,28 +1056,39 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1056
1056
}
1057
1057
}
1058
1058
1059
- #[ allow( dead_code) ]
1060
1059
fn check_rvalue ( & mut self , mir : & Mir < ' tcx > , rv : & Rvalue < ' tcx > , location : Location ) {
1061
1060
let tcx = self . tcx ( ) ;
1062
1061
match rv {
1063
- Rvalue :: Aggregate ( ref ak, ref ops) => {
1062
+ Rvalue :: Aggregate ( ak, ops) => {
1064
1063
match * * ak {
1065
1064
// tuple rvalue field type is always the type of the op. Nothing to check here.
1066
1065
AggregateKind :: Tuple => { } ,
1067
1066
_ => {
1068
1067
for ( i, op) in ops. iter ( ) . enumerate ( ) {
1069
- let field_ty = if let Ok ( field_ty) = self . aggregate_field_ty ( ak, i, location) {
1070
- field_ty
1071
- } else {
1072
- // TODO(nashenas88) log span_mirbug terr??
1073
- continue ;
1068
+ let field_ty = match self . aggregate_field_ty ( ak, i, location) {
1069
+ Ok ( field_ty) => field_ty,
1070
+ Err ( FieldAccessError :: OutOfRange { field_count } ) => {
1071
+ span_mirbug ! (
1072
+ self ,
1073
+ rv,
1074
+ "accessed field #{} but variant only has {}" ,
1075
+ i,
1076
+ field_count) ;
1077
+ continue ;
1078
+ } ,
1074
1079
} ;
1075
1080
let op_ty = match op {
1076
1081
Operand :: Consume ( lv) => lv. ty ( mir, tcx) . to_ty ( tcx) ,
1077
1082
Operand :: Constant ( c) => c. ty ,
1078
1083
} ;
1079
- if let Err ( _terr) = self . sub_types ( op_ty, field_ty, location. at_successor_within_block ( ) ) {
1080
- // TODO(nashenas88) log span_mirbug terr??
1084
+ if let Err ( terr) = self . sub_types ( op_ty, field_ty, location. at_successor_within_block ( ) ) {
1085
+ span_mirbug ! (
1086
+ self ,
1087
+ rv,
1088
+ "{:?} is not a subtype of {:?}: {:?}" ,
1089
+ op_ty,
1090
+ field_ty,
1091
+ terr) ;
1081
1092
}
1082
1093
}
1083
1094
} ,
0 commit comments