@@ -5,16 +5,17 @@ use rustc_const_eval::util::{call_kind, CallDesugaringKind};
55use rustc_errors:: { Applicability , Diagnostic } ;
66use rustc_hir as hir;
77use rustc_hir:: def:: Namespace ;
8- use rustc_hir:: def_id:: DefId ;
98use rustc_hir:: GeneratorKind ;
109use rustc_infer:: infer:: TyCtxtInferExt ;
10+ use rustc_middle:: mir:: tcx:: PlaceTy ;
1111use rustc_middle:: mir:: {
1212 AggregateKind , Constant , FakeReadCause , Field , Local , LocalInfo , LocalKind , Location , Operand ,
1313 Place , PlaceRef , ProjectionElem , Rvalue , Statement , StatementKind , Terminator , TerminatorKind ,
1414} ;
1515use rustc_middle:: ty:: print:: Print ;
1616use rustc_middle:: ty:: { self , DefIdTree , Instance , Ty , TyCtxt } ;
1717use rustc_mir_dataflow:: move_paths:: { InitLocation , LookupResult } ;
18+ use rustc_span:: def_id:: LocalDefId ;
1819use rustc_span:: { symbol:: sym, Span , DUMMY_SP } ;
1920use rustc_target:: abi:: VariantIdx ;
2021use rustc_trait_selection:: traits:: type_known_to_meet_bound_modulo_regions;
@@ -41,7 +42,6 @@ pub(crate) use outlives_suggestion::OutlivesSuggestionBuilder;
4142pub ( crate ) use region_errors:: { ErrorConstraintInfo , RegionErrorKind , RegionErrors } ;
4243pub ( crate ) use region_name:: { RegionName , RegionNameSource } ;
4344pub ( crate ) use rustc_const_eval:: util:: CallKind ;
44- use rustc_middle:: mir:: tcx:: PlaceTy ;
4545
4646pub ( super ) struct IncludingDowncast ( pub ( super ) bool ) ;
4747
@@ -325,10 +325,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
325325 // so it's safe to call `expect_local`.
326326 //
327327 // We know the field exists so it's safe to call operator[] and `unwrap` here.
328+ let def_id = def_id. expect_local ( ) ;
328329 let var_id = self
329330 . infcx
330331 . tcx
331- . typeck ( def_id. expect_local ( ) )
332+ . typeck ( def_id)
332333 . closure_min_captures_flattened ( def_id)
333334 . nth ( field. index ( ) )
334335 . unwrap ( )
@@ -715,12 +716,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
715716
716717 debug ! ( "move_spans: moved_place={:?} location={:?} stmt={:?}" , moved_place, location, stmt) ;
717718 if let StatementKind :: Assign ( box ( _, Rvalue :: Aggregate ( ref kind, ref places) ) ) = stmt. kind {
718- match kind {
719- box AggregateKind :: Closure ( def_id, _)
720- | box AggregateKind :: Generator ( def_id, _, _) => {
719+ match * * kind {
720+ AggregateKind :: Closure ( def_id, _) | AggregateKind :: Generator ( def_id, _, _) => {
721721 debug ! ( "move_spans: def_id={:?} places={:?}" , def_id, places) ;
722722 if let Some ( ( args_span, generator_kind, capture_kind_span, path_span) ) =
723- self . closure_span ( * def_id, moved_place, places)
723+ self . closure_span ( def_id, moved_place, places)
724724 {
725725 return ClosureUse {
726726 generator_kind,
@@ -847,7 +847,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
847847 if let StatementKind :: Assign ( box ( _, Rvalue :: Aggregate ( ref kind, ref places) ) ) =
848848 stmt. kind
849849 {
850- let ( def_id, is_generator) = match kind {
850+ let ( & def_id, is_generator) = match kind {
851851 box AggregateKind :: Closure ( def_id, _) => ( def_id, false ) ,
852852 box AggregateKind :: Generator ( def_id, _, _) => ( def_id, true ) ,
853853 _ => continue ,
@@ -858,7 +858,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
858858 def_id, is_generator, places
859859 ) ;
860860 if let Some ( ( args_span, generator_kind, capture_kind_span, path_span) ) =
861- self . closure_span ( * def_id, Place :: from ( target) . as_ref ( ) , places)
861+ self . closure_span ( def_id, Place :: from ( target) . as_ref ( ) , places)
862862 {
863863 return ClosureUse { generator_kind, args_span, capture_kind_span, path_span } ;
864864 } else {
@@ -879,25 +879,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
879879 /// The second span is the location the use resulting in the captured path of the capture
880880 fn closure_span (
881881 & self ,
882- def_id : DefId ,
882+ def_id : LocalDefId ,
883883 target_place : PlaceRef < ' tcx > ,
884884 places : & [ Operand < ' tcx > ] ,
885885 ) -> Option < ( Span , Option < GeneratorKind > , Span , Span ) > {
886886 debug ! (
887887 "closure_span: def_id={:?} target_place={:?} places={:?}" ,
888888 def_id, target_place, places
889889 ) ;
890- let local_did = def_id. as_local ( ) ?;
891- let hir_id = self . infcx . tcx . hir ( ) . local_def_id_to_hir_id ( local_did) ;
890+ let hir_id = self . infcx . tcx . hir ( ) . local_def_id_to_hir_id ( def_id) ;
892891 let expr = & self . infcx . tcx . hir ( ) . expect_expr ( hir_id) . kind ;
893892 debug ! ( "closure_span: hir_id={:?} expr={:?}" , hir_id, expr) ;
894893 if let hir:: ExprKind :: Closure ( & hir:: Closure { body, fn_decl_span, .. } ) = expr {
895- for ( captured_place, place) in self
896- . infcx
897- . tcx
898- . typeck ( def_id. expect_local ( ) )
899- . closure_min_captures_flattened ( def_id)
900- . zip ( places)
894+ for ( captured_place, place) in
895+ self . infcx . tcx . typeck ( def_id) . closure_min_captures_flattened ( def_id) . zip ( places)
901896 {
902897 match place {
903898 Operand :: Copy ( place) | Operand :: Move ( place)
0 commit comments