Auto merge of #13149 - jusexton:issue-13123, r=dswij
Fix while_let_on_iterator dropping loop label when applying fix. Loop label was not persisted when displaying help and was therefore producing broken rust code when applying fixes. Solution was to store the `ast::Label` when creating a `higher::WhileLet` from an expression and add the label name to the lint suggestion and diagnostics. --- Fixes: https://github.com/rust-lang/rust-clippy/issues/13123 changelog: [`while_let_on_iterator`]: Fix issue dropping loop label when displaying help and applying fixes.
This commit is contained in:
commit
d20be39c7f
5 changed files with 33 additions and 4 deletions
|
|
@ -367,6 +367,7 @@ pub struct WhileLet<'hir> {
|
|||
pub let_expr: &'hir Expr<'hir>,
|
||||
/// `while let` loop body
|
||||
pub if_then: &'hir Expr<'hir>,
|
||||
pub label: Option<ast::Label>,
|
||||
/// `while let PAT = EXPR`
|
||||
/// ^^^^^^^^^^^^^^
|
||||
pub let_span: Span,
|
||||
|
|
@ -399,7 +400,7 @@ impl<'hir> WhileLet<'hir> {
|
|||
}),
|
||||
..
|
||||
},
|
||||
_,
|
||||
label,
|
||||
LoopSource::While,
|
||||
_,
|
||||
) = expr.kind
|
||||
|
|
@ -408,6 +409,7 @@ impl<'hir> WhileLet<'hir> {
|
|||
let_pat,
|
||||
let_expr,
|
||||
if_then,
|
||||
label,
|
||||
let_span,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue