@@ -17,7 +17,7 @@ use rustc::ty;
17
17
use syntax:: ast;
18
18
use syntax_pos;
19
19
use errors:: DiagnosticBuilder ;
20
- use rustc :: hir :: map :: PatternSource ;
20
+ use borrowck :: gather_loans :: gather_moves :: PatternSource ;
21
21
22
22
pub struct MoveErrorCollector < ' tcx > {
23
23
errors : Vec < MoveError < ' tcx > >
@@ -41,12 +41,12 @@ impl<'tcx> MoveErrorCollector<'tcx> {
41
41
42
42
pub struct MoveError < ' tcx > {
43
43
move_from : mc:: cmt < ' tcx > ,
44
- move_to : Option < MoveSpanAndPath < ' tcx > >
44
+ move_to : Option < MovePlace < ' tcx > >
45
45
}
46
46
47
47
impl < ' tcx > MoveError < ' tcx > {
48
48
pub fn with_move_info ( move_from : mc:: cmt < ' tcx > ,
49
- move_to : Option < MoveSpanAndPath < ' tcx > > )
49
+ move_to : Option < MovePlace < ' tcx > > )
50
50
-> MoveError < ' tcx > {
51
51
MoveError {
52
52
move_from : move_from,
@@ -56,27 +56,27 @@ impl<'tcx> MoveError<'tcx> {
56
56
}
57
57
58
58
#[ derive( Clone ) ]
59
- pub struct MoveSpanAndPath < ' tcx > {
59
+ pub struct MovePlace < ' tcx > {
60
60
pub span : syntax_pos:: Span ,
61
61
pub name : ast:: Name ,
62
62
pub pat_source : PatternSource < ' tcx > ,
63
63
}
64
64
65
65
pub struct GroupedMoveErrors < ' tcx > {
66
66
move_from : mc:: cmt < ' tcx > ,
67
- move_to_places : Vec < MoveSpanAndPath < ' tcx > >
67
+ move_to_places : Vec < MovePlace < ' tcx > >
68
68
}
69
69
70
70
fn report_move_errors < ' a , ' tcx > ( bccx : & BorrowckCtxt < ' a , ' tcx > , errors : & Vec < MoveError < ' tcx > > ) {
71
71
let grouped_errors = group_errors_with_same_origin ( errors) ;
72
72
for error in & grouped_errors {
73
73
let mut err = report_cannot_move_out_of ( bccx, error. move_from . clone ( ) ) ;
74
74
let mut is_first_note = true ;
75
-
76
- if let Some ( pattern_source ) = error . move_to_places . get ( 0 ) {
77
-
78
- match pattern_source . pat_source {
79
- PatternSource :: LetDecl ( _ ) => { }
75
+ match error . move_to_places . get ( 0 ) {
76
+ Some ( & MovePlace { pat_source : PatternSource :: LetDecl ( _ ) , .. } ) => {
77
+ // ignore patterns that are found at the top-level of a `let`;
78
+ // see `get_pattern_source()` for details
79
+ }
80
80
_ => {
81
81
for move_to in & error. move_to_places {
82
82
@@ -85,14 +85,14 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<Move
85
85
}
86
86
}
87
87
}
88
- }
89
88
if let NoteClosureEnv ( upvar_id) = error. move_from . note {
90
- err. span_label ( bccx. tcx . hir . span ( upvar_id. var_id ) , & "captured outer variable" ) ;
89
+ err. span_label ( bccx. tcx . hir . span ( upvar_id. var_id ) ,
90
+ & "captured outer variable" ) ;
91
91
}
92
92
err. emit ( ) ;
93
-
94
- }
93
+
95
94
}
95
+ }
96
96
97
97
fn group_errors_with_same_origin < ' tcx > ( errors : & Vec < MoveError < ' tcx > > )
98
98
-> Vec < GroupedMoveErrors < ' tcx > > {
0 commit comments