@@ -191,38 +191,36 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
191191 ) ;
192192 }
193193
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) ;
205200
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 ( )
225202 }
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+ ) ) ;
226224 }
227225
228226 if let Some ( ( _, mut old_err) ) = self . move_error_reported
@@ -1568,7 +1566,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15681566 ) ?;
15691567 buf. push_str ( "[" ) ;
15701568 if self . append_local_to_string ( index, buf) . is_err ( ) {
1571- buf. push_str ( ".. " ) ;
1569+ buf. push_str ( "_ " ) ;
15721570 }
15731571 buf. push_str ( "]" ) ;
15741572 }
@@ -1673,22 +1671,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16731671 }
16741672 }
16751673
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-
16921674 /// Check if a place is a thread-local static.
16931675 pub fn is_place_thread_local ( & self , place : & Place < ' tcx > ) -> bool {
16941676 if let Place :: Static ( statik) = place {
0 commit comments