@@ -174,7 +174,10 @@ impl<'a> Parser<'a> {
174174 } else {
175175 ( None , None )
176176 } ;
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+ ) {
178181 ( Ok ( init) , None ) => {
179182 // init parsed, ty parsed
180183 init
@@ -231,25 +234,19 @@ impl<'a> Parser<'a> {
231234 self . sess. span_diagnostic,
232235 self . token. span,
233236 E0067 ,
234- "can't reassign to a uninitialized variable"
237+ "can't reassign to an uninitialized variable"
235238 ) ;
236239 err. span_suggestion_short (
237240 self . token . span ,
238- "replace with `=` to initialize the variable" ,
241+ "initialize the variable" ,
239242 "=" . 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 ,
247244 ) ;
248245 // In case of code like `let x += 1` it's possible the user may have meant to write `x += 1`
249246 if !has_ty {
250247 err. span_suggestion_short (
251248 let_span,
252- "remove to reassign to a previously initialized variable" ,
249+ "otherwise, reassign to a previously initialized variable" ,
253250 "" . to_string ( ) ,
254251 Applicability :: MaybeIncorrect ,
255252 ) ;
0 commit comments