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