10
10
11
11
use rustc:: hir;
12
12
use rustc:: mir:: * ;
13
- use rustc:: ty:: { self , TyCtxt } ;
13
+ use rustc:: ty;
14
14
use rustc_errors:: DiagnosticBuilder ;
15
15
use syntax_pos:: Span ;
16
16
17
- use dataflow:: move_paths:: { IllegalMoveOrigin , IllegalMoveOriginKind , MoveData } ;
17
+ use borrow_check:: MirBorrowckCtxt ;
18
+ use dataflow:: move_paths:: { IllegalMoveOrigin , IllegalMoveOriginKind } ;
18
19
use dataflow:: move_paths:: { LookupResult , MoveError , MovePathIndex } ;
19
20
use util:: borrowck_errors:: { BorrowckErrors , Origin } ;
20
21
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
-
41
22
// Often when desugaring a pattern match we may have many individual moves in
42
23
// MIR that are all part of one operation from the user's point-of-view. For
43
24
// example:
@@ -76,15 +57,15 @@ enum GroupedMoveError<'tcx> {
76
57
} ,
77
58
}
78
59
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 > > ) {
81
62
let grouped_errors = self . group_move_errors ( move_errors) ;
82
63
for error in grouped_errors {
83
64
self . report ( error) ;
84
65
}
85
66
}
86
67
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 > > {
88
69
let mut grouped_errors = Vec :: new ( ) ;
89
70
for error in errors {
90
71
self . append_to_grouped_errors ( & mut grouped_errors, error) ;
@@ -93,7 +74,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
93
74
}
94
75
95
76
fn append_to_grouped_errors (
96
- self ,
77
+ & self ,
97
78
grouped_errors : & mut Vec < GroupedMoveError < ' tcx > > ,
98
79
error : MoveError < ' tcx > ,
99
80
) {
@@ -158,7 +139,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
158
139
}
159
140
160
141
fn append_binding_error (
161
- self ,
142
+ & self ,
162
143
grouped_errors : & mut Vec < GroupedMoveError < ' tcx > > ,
163
144
kind : IllegalMoveOriginKind < ' tcx > ,
164
145
move_from : & Place < ' tcx > ,
@@ -236,7 +217,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
236
217
} ;
237
218
}
238
219
239
- fn report ( self , error : GroupedMoveError < ' tcx > ) {
220
+ fn report ( & self , error : GroupedMoveError < ' tcx > ) {
240
221
let ( mut err, err_span) = {
241
222
let ( span, kind) : ( Span , & IllegalMoveOriginKind ) = match error {
242
223
GroupedMoveError :: MovesFromMatchPlace { span, ref kind, .. }
@@ -279,7 +260,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
279
260
}
280
261
281
262
fn add_move_hints (
282
- self ,
263
+ & self ,
283
264
error : GroupedMoveError < ' tcx > ,
284
265
err : & mut DiagnosticBuilder < ' a > ,
285
266
span : Span ,
@@ -365,7 +346,7 @@ impl<'a, 'gcx, 'tcx> MoveErrorCtxt<'a, 'gcx, 'tcx> {
365
346
}
366
347
}
367
348
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 {
369
350
let is_shared_ref = |ty : ty:: Ty | match ty. sty {
370
351
ty:: TypeVariants :: TyRef ( .., hir:: Mutability :: MutImmutable ) => true ,
371
352
_ => false ,
0 commit comments