@@ -17,6 +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
21
21
22
pub struct MoveErrorCollector < ' tcx > {
22
23
errors : Vec < MoveError < ' tcx > >
@@ -40,12 +41,12 @@ impl<'tcx> MoveErrorCollector<'tcx> {
40
41
41
42
pub struct MoveError < ' tcx > {
42
43
move_from : mc:: cmt < ' tcx > ,
43
- move_to : Option < MoveSpanAndPath >
44
+ move_to : Option < MoveSpanAndPath < ' tcx > >
44
45
}
45
46
46
47
impl < ' tcx > MoveError < ' tcx > {
47
48
pub fn with_move_info ( move_from : mc:: cmt < ' tcx > ,
48
- move_to : Option < MoveSpanAndPath > )
49
+ move_to : Option < MoveSpanAndPath < ' tcx > > )
49
50
-> MoveError < ' tcx > {
50
51
MoveError {
51
52
move_from : move_from,
@@ -55,32 +56,43 @@ impl<'tcx> MoveError<'tcx> {
55
56
}
56
57
57
58
#[ derive( Clone ) ]
58
- pub struct MoveSpanAndPath {
59
+ pub struct MoveSpanAndPath < ' tcx > {
59
60
pub span : syntax_pos:: Span ,
60
61
pub name : ast:: Name ,
62
+ pub pat_source : PatternSource < ' tcx > ,
61
63
}
62
64
63
65
pub struct GroupedMoveErrors < ' tcx > {
64
66
move_from : mc:: cmt < ' tcx > ,
65
- move_to_places : Vec < MoveSpanAndPath >
67
+ move_to_places : Vec < MoveSpanAndPath < ' tcx > >
66
68
}
67
69
68
- fn report_move_errors < ' a , ' tcx > ( bccx : & BorrowckCtxt < ' a , ' tcx > ,
69
- errors : & Vec < MoveError < ' tcx > > ) {
70
+ fn report_move_errors < ' a , ' tcx > ( bccx : & BorrowckCtxt < ' a , ' tcx > , errors : & Vec < MoveError < ' tcx > > ) {
70
71
let grouped_errors = group_errors_with_same_origin ( errors) ;
71
72
for error in & grouped_errors {
72
73
let mut err = report_cannot_move_out_of ( bccx, error. move_from . clone ( ) ) ;
73
74
let mut is_first_note = true ;
74
- for move_to in & error. move_to_places {
75
- err = note_move_destination ( err, move_to. span , move_to. name , is_first_note) ;
76
- is_first_note = false ;
75
+
76
+ if let Some ( pattern_source) = error. move_to_places . get ( 0 ) {
77
+
78
+ match pattern_source. pat_source {
79
+ PatternSource :: LetDecl ( _) => { }
80
+ _ => {
81
+ for move_to in & error. move_to_places {
82
+
83
+ err = note_move_destination ( err, move_to. span , move_to. name , is_first_note) ;
84
+ is_first_note = false ;
85
+ }
86
+ }
77
87
}
88
+ }
78
89
if let NoteClosureEnv ( upvar_id) = error. move_from . note {
79
- err. span_label ( bccx. tcx . hir . span ( upvar_id. var_id ) , & "captured outer variable" ) ;
90
+ err. span_label ( bccx. tcx . hir . span ( upvar_id. var_id ) , & "captured outer variable" ) ;
80
91
}
81
92
err. emit ( ) ;
93
+
94
+ }
82
95
}
83
- }
84
96
85
97
fn group_errors_with_same_origin < ' tcx > ( errors : & Vec < MoveError < ' tcx > > )
86
98
-> Vec < GroupedMoveErrors < ' tcx > > {
0 commit comments