@@ -93,7 +93,7 @@ pub trait BorrowckErrors {
93
93
opt_via : & str ,
94
94
old_loan_span : Span ,
95
95
old_opt_via : & str ,
96
- old_load_end_span : Span ,
96
+ old_load_end_span : Option < Span > ,
97
97
o : Origin )
98
98
-> DiagnosticBuilder
99
99
{
@@ -106,13 +106,17 @@ pub trait BorrowckErrors {
106
106
err. span_label ( new_loan_span,
107
107
format ! ( "mutable borrow starts here in previous \
108
108
iteration of loop{}", opt_via) ) ;
109
- err. span_label ( old_load_end_span, "mutable borrow ends here" ) ;
109
+ if let Some ( old_load_end_span) = old_load_end_span {
110
+ err. span_label ( old_load_end_span, "mutable borrow ends here" ) ;
111
+ }
110
112
} else {
111
113
err. span_label ( old_loan_span,
112
114
format ! ( "first mutable borrow occurs here{}" , old_opt_via) ) ;
113
115
err. span_label ( new_loan_span,
114
116
format ! ( "second mutable borrow occurs here{}" , opt_via) ) ;
115
- err. span_label ( old_load_end_span, "first borrow ends here" ) ;
117
+ if let Some ( old_load_end_span) = old_load_end_span {
118
+ err. span_label ( old_load_end_span, "first borrow ends here" ) ;
119
+ }
116
120
}
117
121
err
118
122
}
@@ -121,7 +125,7 @@ pub trait BorrowckErrors {
121
125
new_loan_span : Span ,
122
126
desc : & str ,
123
127
old_loan_span : Span ,
124
- old_load_end_span : Span ,
128
+ old_load_end_span : Option < Span > ,
125
129
o : Origin )
126
130
-> DiagnosticBuilder
127
131
{
@@ -134,9 +138,11 @@ pub trait BorrowckErrors {
134
138
err. span_label (
135
139
new_loan_span,
136
140
"second closure is constructed here" ) ;
137
- err. span_label (
138
- old_load_end_span,
139
- "borrow from first closure ends here" ) ;
141
+ if let Some ( old_load_end_span) = old_load_end_span {
142
+ err. span_label (
143
+ old_load_end_span,
144
+ "borrow from first closure ends here" ) ;
145
+ }
140
146
err
141
147
}
142
148
@@ -147,7 +153,7 @@ pub trait BorrowckErrors {
147
153
old_loan_span : Span ,
148
154
noun_old : & str ,
149
155
old_opt_via : & str ,
150
- previous_end_span : Span ,
156
+ previous_end_span : Option < Span > ,
151
157
o : Origin )
152
158
-> DiagnosticBuilder
153
159
{
@@ -158,7 +164,9 @@ pub trait BorrowckErrors {
158
164
format ! ( "closure construction occurs here{}" , opt_via) ) ;
159
165
err. span_label ( old_loan_span,
160
166
format ! ( "borrow occurs here{}" , old_opt_via) ) ;
161
- err. span_label ( previous_end_span, "borrow ends here" ) ;
167
+ if let Some ( previous_end_span) = previous_end_span {
168
+ err. span_label ( previous_end_span, "borrow ends here" ) ;
169
+ }
162
170
err
163
171
}
164
172
@@ -169,7 +177,7 @@ pub trait BorrowckErrors {
169
177
kind_new : & str ,
170
178
old_loan_span : Span ,
171
179
old_opt_via : & str ,
172
- previous_end_span : Span ,
180
+ previous_end_span : Option < Span > ,
173
181
o : Origin )
174
182
-> DiagnosticBuilder
175
183
{
@@ -181,7 +189,9 @@ pub trait BorrowckErrors {
181
189
format ! ( "borrow occurs here{}" , opt_via) ) ;
182
190
err. span_label ( old_loan_span,
183
191
format ! ( "closure construction occurs here{}" , old_opt_via) ) ;
184
- err. span_label ( previous_end_span, "borrow from closure ends here" ) ;
192
+ if let Some ( previous_end_span) = previous_end_span {
193
+ err. span_label ( previous_end_span, "borrow from closure ends here" ) ;
194
+ }
185
195
err
186
196
}
187
197
@@ -194,7 +204,7 @@ pub trait BorrowckErrors {
194
204
noun_old : & str ,
195
205
kind_old : & str ,
196
206
msg_old : & str ,
197
- old_load_end_span : Span ,
207
+ old_load_end_span : Option < Span > ,
198
208
o : Origin )
199
209
-> DiagnosticBuilder
200
210
{
@@ -203,7 +213,9 @@ pub trait BorrowckErrors {
203
213
desc_new, msg_new, kind_new, noun_old, kind_old, msg_old, OGN =o) ;
204
214
err. span_label ( span, format ! ( "{} borrow occurs here{}" , kind_new, msg_new) ) ;
205
215
err. span_label ( old_span, format ! ( "{} borrow occurs here{}" , kind_old, msg_old) ) ;
206
- err. span_label ( old_load_end_span, format ! ( "{} borrow ends here" , kind_old) ) ;
216
+ if let Some ( old_load_end_span) = old_load_end_span {
217
+ err. span_label ( old_load_end_span, format ! ( "{} borrow ends here" , kind_old) ) ;
218
+ }
207
219
err
208
220
}
209
221
0 commit comments