@@ -191,38 +191,36 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
191
191
) ;
192
192
}
193
193
194
- if let Some ( ty) = self . retrieve_type_for_place ( used_place) {
195
- let needs_note = match ty. sty {
196
- ty:: Closure ( id, _) => {
197
- let tables = self . infcx . tcx . typeck_tables_of ( id) ;
198
- let node_id = self . infcx . tcx . hir ( ) . as_local_node_id ( id) . unwrap ( ) ;
199
- let hir_id = self . infcx . tcx . hir ( ) . node_to_hir_id ( node_id) ;
200
-
201
- tables. closure_kind_origins ( ) . get ( hir_id) . is_none ( )
202
- }
203
- _ => true ,
204
- } ;
194
+ let ty = used_place. ty ( self . mir , self . infcx . tcx ) . to_ty ( self . infcx . tcx ) ;
195
+ let needs_note = match ty. sty {
196
+ ty:: Closure ( id, _) => {
197
+ let tables = self . infcx . tcx . typeck_tables_of ( id) ;
198
+ let node_id = self . infcx . tcx . hir ( ) . as_local_node_id ( id) . unwrap ( ) ;
199
+ let hir_id = self . infcx . tcx . hir ( ) . node_to_hir_id ( node_id) ;
205
200
206
- if needs_note {
207
- let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
208
- let place = & self . move_data . move_paths [ mpi] . place ;
209
-
210
- if let Some ( ty) = self . retrieve_type_for_place ( place) {
211
- let note_msg = match self . describe_place_with_options (
212
- place,
213
- IncludingDowncast ( true ) ,
214
- ) {
215
- Some ( name) => format ! ( "`{}`" , name) ,
216
- None => "value" . to_owned ( ) ,
217
- } ;
218
-
219
- err. note ( & format ! (
220
- "move occurs because {} has type `{}`, \
221
- which does not implement the `Copy` trait",
222
- note_msg, ty
223
- ) ) ;
224
- }
201
+ tables. closure_kind_origins ( ) . get ( hir_id) . is_none ( )
225
202
}
203
+ _ => true ,
204
+ } ;
205
+
206
+ if needs_note {
207
+ let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
208
+ let place = & self . move_data . move_paths [ mpi] . place ;
209
+
210
+ let ty = place. ty ( self . mir , self . infcx . tcx ) . to_ty ( self . infcx . tcx ) ;
211
+ let note_msg = match self . describe_place_with_options (
212
+ place,
213
+ IncludingDowncast ( true ) ,
214
+ ) {
215
+ Some ( name) => format ! ( "`{}`" , name) ,
216
+ None => "value" . to_owned ( ) ,
217
+ } ;
218
+
219
+ err. note ( & format ! (
220
+ "move occurs because {} has type `{}`, \
221
+ which does not implement the `Copy` trait",
222
+ note_msg, ty
223
+ ) ) ;
226
224
}
227
225
228
226
if let Some ( ( _, mut old_err) ) = self . move_error_reported
@@ -1673,22 +1671,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1673
1671
}
1674
1672
}
1675
1673
1676
- /// Retrieve type of a place for the current MIR representation
1677
- fn retrieve_type_for_place ( & self , place : & Place < ' tcx > ) -> Option < ty:: Ty > {
1678
- match place {
1679
- Place :: Local ( local) => {
1680
- let local = & self . mir . local_decls [ * local] ;
1681
- Some ( local. ty )
1682
- }
1683
- Place :: Promoted ( ref prom) => Some ( prom. 1 ) ,
1684
- Place :: Static ( ref st) => Some ( st. ty ) ,
1685
- Place :: Projection ( ref proj) => match proj. elem {
1686
- ProjectionElem :: Field ( _, ty) => Some ( ty) ,
1687
- _ => None ,
1688
- } ,
1689
- }
1690
- }
1691
-
1692
1674
/// Check if a place is a thread-local static.
1693
1675
pub fn is_place_thread_local ( & self , place : & Place < ' tcx > ) -> bool {
1694
1676
if let Place :: Static ( statik) = place {
0 commit comments