@@ -181,38 +181,36 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
181
181
) ;
182
182
}
183
183
184
- if let Some ( ty) = self . retrieve_type_for_place ( used_place) {
185
- let needs_note = match ty. sty {
186
- ty:: Closure ( id, _) => {
187
- let tables = self . infcx . tcx . typeck_tables_of ( id) ;
188
- let node_id = self . infcx . tcx . hir ( ) . as_local_node_id ( id) . unwrap ( ) ;
189
- let hir_id = self . infcx . tcx . hir ( ) . node_to_hir_id ( node_id) ;
190
-
191
- tables. closure_kind_origins ( ) . get ( hir_id) . is_none ( )
192
- }
193
- _ => true ,
194
- } ;
184
+ let ty = used_place. ty ( self . mir , self . infcx . tcx ) . to_ty ( self . infcx . tcx ) ;
185
+ let needs_note = match ty. sty {
186
+ ty:: Closure ( id, _) => {
187
+ let tables = self . infcx . tcx . typeck_tables_of ( id) ;
188
+ let node_id = self . infcx . tcx . hir ( ) . as_local_node_id ( id) . unwrap ( ) ;
189
+ let hir_id = self . infcx . tcx . hir ( ) . node_to_hir_id ( node_id) ;
195
190
196
- if needs_note {
197
- let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
198
- let place = & self . move_data . move_paths [ mpi] . place ;
199
-
200
- if let Some ( ty) = self . retrieve_type_for_place ( place) {
201
- let note_msg = match self . describe_place_with_options (
202
- place,
203
- IncludingDowncast ( true ) ,
204
- ) {
205
- Some ( name) => format ! ( "`{}`" , name) ,
206
- None => "value" . to_owned ( ) ,
207
- } ;
208
-
209
- err. note ( & format ! (
210
- "move occurs because {} has type `{}`, \
211
- which does not implement the `Copy` trait",
212
- note_msg, ty
213
- ) ) ;
214
- }
191
+ tables. closure_kind_origins ( ) . get ( hir_id) . is_none ( )
215
192
}
193
+ _ => true ,
194
+ } ;
195
+
196
+ if needs_note {
197
+ let mpi = self . move_data . moves [ move_out_indices[ 0 ] ] . path ;
198
+ let place = & self . move_data . move_paths [ mpi] . place ;
199
+
200
+ let ty = place. ty ( self . mir , self . infcx . tcx ) . to_ty ( self . infcx . tcx ) ;
201
+ let note_msg = match self . describe_place_with_options (
202
+ place,
203
+ IncludingDowncast ( true ) ,
204
+ ) {
205
+ Some ( name) => format ! ( "`{}`" , name) ,
206
+ None => "value" . to_owned ( ) ,
207
+ } ;
208
+
209
+ err. note ( & format ! (
210
+ "move occurs because {} has type `{}`, \
211
+ which does not implement the `Copy` trait",
212
+ note_msg, ty
213
+ ) ) ;
216
214
}
217
215
218
216
if let Some ( ( _, mut old_err) ) = self . move_error_reported
@@ -1558,7 +1556,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1558
1556
) ?;
1559
1557
buf. push_str ( "[" ) ;
1560
1558
if self . append_local_to_string ( index, buf) . is_err ( ) {
1561
- buf. push_str ( ".. " ) ;
1559
+ buf. push_str ( "_ " ) ;
1562
1560
}
1563
1561
buf. push_str ( "]" ) ;
1564
1562
}
@@ -1663,22 +1661,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1663
1661
}
1664
1662
}
1665
1663
1666
- /// Retrieve type of a place for the current MIR representation
1667
- fn retrieve_type_for_place ( & self , place : & Place < ' tcx > ) -> Option < ty:: Ty > {
1668
- match place {
1669
- Place :: Local ( local) => {
1670
- let local = & self . mir . local_decls [ * local] ;
1671
- Some ( local. ty )
1672
- }
1673
- Place :: Promoted ( ref prom) => Some ( prom. 1 ) ,
1674
- Place :: Static ( ref st) => Some ( st. ty ) ,
1675
- Place :: Projection ( ref proj) => match proj. elem {
1676
- ProjectionElem :: Field ( _, ty) => Some ( ty) ,
1677
- _ => None ,
1678
- } ,
1679
- }
1680
- }
1681
-
1682
1664
/// Check if a place is a thread-local static.
1683
1665
pub fn is_place_thread_local ( & self , place : & Place < ' tcx > ) -> bool {
1684
1666
if let Place :: Static ( statik) = place {
0 commit comments