1010
1111use rustc:: hir;
1212use rustc:: mir:: * ;
13- use rustc:: ty:: { self , TyCtxt } ;
13+ use rustc:: ty;
1414use rustc_errors:: DiagnosticBuilder ;
1515use syntax_pos:: Span ;
1616
17- use dataflow:: move_paths:: { IllegalMoveOrigin , IllegalMoveOriginKind , MoveData } ;
17+ use borrow_check:: MirBorrowckCtxt ;
18+ use dataflow:: move_paths:: { IllegalMoveOrigin , IllegalMoveOriginKind } ;
1819use dataflow:: move_paths:: { LookupResult , MoveError , MovePathIndex } ;
1920use util:: borrowck_errors:: { BorrowckErrors , Origin } ;
2021
21- pub ( crate ) fn report_move_errors < ' gcx , ' tcx > (
22- mir : & Mir < ' tcx > ,
23- tcx : TyCtxt < ' _ , ' gcx , ' tcx > ,
24- move_errors : Vec < MoveError < ' tcx > > ,
25- move_data : & MoveData < ' tcx > ,
26- ) {
27- MoveErrorCtxt {
28- mir,
29- tcx,
30- move_data,
31- } . report_errors ( move_errors) ;
32- }
33-
34- #[ derive( Copy , Clone ) ]
35- struct MoveErrorCtxt < ' a , ' gcx : ' tcx , ' tcx : ' a > {
36- mir : & ' a Mir < ' tcx > ,
37- tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
38- move_data : & ' a MoveData < ' tcx > ,
39- }
40-
4122// Often when desugaring a pattern match we may have many individual moves in
4223// MIR that are all part of one operation from the user's point-of-view. For
4324// example:
@@ -76,15 +57,15 @@ enum GroupedMoveError<'tcx> {
7657 } ,
7758}
7859
79- impl < ' a , ' gcx , ' tcx > MoveErrorCtxt < ' a , ' gcx , ' tcx > {
80- fn report_errors ( self , move_errors : Vec < MoveError < ' tcx > > ) {
60+ impl < ' a , ' gcx , ' tcx > MirBorrowckCtxt < ' a , ' gcx , ' tcx > {
61+ pub ( crate ) fn report_move_errors ( & self , move_errors : Vec < MoveError < ' tcx > > ) {
8162 let grouped_errors = self . group_move_errors ( move_errors) ;
8263 for error in grouped_errors {
8364 self . report ( error) ;
8465 }
8566 }
8667
87- fn group_move_errors ( self , errors : Vec < MoveError < ' tcx > > ) -> Vec < GroupedMoveError < ' tcx > > {
68+ fn group_move_errors ( & self , errors : Vec < MoveError < ' tcx > > ) -> Vec < GroupedMoveError < ' tcx > > {
8869 let mut grouped_errors = Vec :: new ( ) ;
8970 for error in errors {
9071 self . append_to_grouped_errors ( & mut grouped_errors, error) ;
@@ -93,7 +74,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
9374 }
9475
9576 fn append_to_grouped_errors (
96- self ,
77+ & self ,
9778 grouped_errors : & mut Vec < GroupedMoveError < ' tcx > > ,
9879 error : MoveError < ' tcx > ,
9980 ) {
@@ -158,7 +139,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
158139 }
159140
160141 fn append_binding_error (
161- self ,
142+ & self ,
162143 grouped_errors : & mut Vec < GroupedMoveError < ' tcx > > ,
163144 kind : IllegalMoveOriginKind < ' tcx > ,
164145 move_from : & Place < ' tcx > ,
@@ -236,7 +217,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
236217 } ;
237218 }
238219
239- fn report ( self , error : GroupedMoveError < ' tcx > ) {
220+ fn report ( & self , error : GroupedMoveError < ' tcx > ) {
240221 let ( mut err, err_span) = {
241222 let ( span, kind) : ( Span , & IllegalMoveOriginKind ) = match error {
242223 GroupedMoveError :: MovesFromMatchPlace { span, ref kind, .. }
@@ -279,7 +260,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
279260 }
280261
281262 fn add_move_hints (
282- self ,
263+ & self ,
283264 error : GroupedMoveError < ' tcx > ,
284265 err : & mut DiagnosticBuilder < ' a > ,
285266 span : Span ,
@@ -365,7 +346,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
365346 }
366347 }
367348
368- fn suitable_to_remove_deref ( self , proj : & PlaceProjection < ' tcx > , snippet : & str ) -> bool {
349+ fn suitable_to_remove_deref ( & self , proj : & PlaceProjection < ' tcx > , snippet : & str ) -> bool {
369350 let is_shared_ref = |ty : ty:: Ty | match ty. sty {
370351 ty:: TypeVariants :: TyRef ( .., hir:: Mutability :: MutImmutable ) => true ,
371352 _ => false ,
0 commit comments