@@ -133,34 +133,37 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
133
133
}
134
134
135
135
fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
136
- if let StatementKind :: Assign ( box ( dest, rvalue) ) = & statement. kind {
137
- // LHS and RHS of the assignment must have the same type.
138
- let left_ty = dest. ty ( & self . body . local_decls , self . tcx ) . ty ;
139
- let right_ty = rvalue. ty ( & self . body . local_decls , self . tcx ) ;
140
- if !mir_assign_valid_types ( self . tcx , right_ty, left_ty) {
141
- self . fail (
142
- location,
143
- format ! (
144
- "encountered `Assign` statement with incompatible types:\n \
145
- left-hand side has type: {}\n \
146
- right-hand side has type: {}",
147
- left_ty, right_ty,
148
- ) ,
149
- ) ;
150
- }
151
- // The sides of an assignment must not alias. Currently this just checks whether the places
152
- // are identical.
153
- match rvalue {
154
- Rvalue :: Use ( Operand :: Copy ( src) | Operand :: Move ( src) ) => {
155
- if dest == src {
156
- self . fail (
157
- location,
158
- "encountered `Assign` statement with overlapping memory" ,
159
- ) ;
136
+ match & statement. kind {
137
+ StatementKind :: Assign ( box ( dest, rvalue) ) => {
138
+ // LHS and RHS of the assignment must have the same type.
139
+ let left_ty = dest. ty ( & self . body . local_decls , self . tcx ) . ty ;
140
+ let right_ty = rvalue. ty ( & self . body . local_decls , self . tcx ) ;
141
+ if !mir_assign_valid_types ( self . tcx , right_ty, left_ty) {
142
+ self . fail (
143
+ location,
144
+ format ! (
145
+ "encountered `Assign` statement with incompatible types:\n \
146
+ left-hand side has type: {}\n \
147
+ right-hand side has type: {}",
148
+ left_ty, right_ty,
149
+ ) ,
150
+ ) ;
151
+ }
152
+ // The sides of an assignment must not alias. Currently this just checks whether the places
153
+ // are identical.
154
+ match rvalue {
155
+ Rvalue :: Use ( Operand :: Copy ( src) | Operand :: Move ( src) ) => {
156
+ if dest == src {
157
+ self . fail (
158
+ location,
159
+ "encountered `Assign` statement with overlapping memory" ,
160
+ ) ;
161
+ }
160
162
}
163
+ _ => { }
161
164
}
162
- _ => { }
163
165
}
166
+ _ => { }
164
167
}
165
168
}
166
169
0 commit comments