@@ -174,7 +174,10 @@ impl<'a> Parser<'a> {
174
174
} else {
175
175
( None , None )
176
176
} ;
177
- let init = match ( self . parse_initializer ( let_span, ty. is_some ( ) , err. is_some ( ) ) , err) {
177
+ let init = match (
178
+ self . parse_initializer ( let_span. until ( pat. span ) , ty. is_some ( ) , err. is_some ( ) ) ,
179
+ err,
180
+ ) {
178
181
( Ok ( init) , None ) => {
179
182
// init parsed, ty parsed
180
183
init
@@ -231,25 +234,19 @@ impl<'a> Parser<'a> {
231
234
self . sess. span_diagnostic,
232
235
self . token. span,
233
236
E0067 ,
234
- "can't reassign to a uninitialized variable"
237
+ "can't reassign to an uninitialized variable"
235
238
) ;
236
239
err. span_suggestion_short (
237
240
self . token . span ,
238
- "replace with `=` to initialize the variable" ,
241
+ "initialize the variable" ,
239
242
"=" . to_string ( ) ,
240
- if has_ty {
241
- // for `let x: i8 += 1` it's highly likely that the `+` is a typo
242
- Applicability :: MachineApplicable
243
- } else {
244
- // for `let x += 1` it's a bit less likely that the `+` is a typo
245
- Applicability :: MaybeIncorrect
246
- } ,
243
+ Applicability :: MaybeIncorrect ,
247
244
) ;
248
245
// In case of code like `let x += 1` it's possible the user may have meant to write `x += 1`
249
246
if !has_ty {
250
247
err. span_suggestion_short (
251
248
let_span,
252
- "remove to reassign to a previously initialized variable" ,
249
+ "otherwise, reassign to a previously initialized variable" ,
253
250
"" . to_string ( ) ,
254
251
Applicability :: MaybeIncorrect ,
255
252
) ;
0 commit comments