Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,11 @@ fn rewrite_let(
// TODO(ytmimi) comments could appear between `let` and the `pat`

// 4 = "let ".len()
let pat_shape = shape.offset_left(4, pat.span)?;
let mut pat_shape = shape.offset_left(4, pat.span)?;
if context.config.style_edition() >= StyleEdition::Edition2027 {
// 2 for the length of " ="
pat_shape = pat_shape.sub_width(2, pat.span)?;
}
let pat_str = pat.rewrite_result(context, pat_shape)?;
result.push_str(&pat_str);

Expand Down
14 changes: 14 additions & 0 deletions tests/source/issue-6202/long_pat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// max_width = 120
// error_on_line_overflow = true
// style_edition = "2027"

impl EarlyLintPass for NeedlessContinue {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if let ExprKind::Loop(body, label, ..) | ExprKind::While(_, body, label) | ExprKind::ForLoop { body, label, .. } =
&expr.kind
&& !in_external_macro(cx.sess, expr.span)
{
check_final_block_stmt(cx, body, label, expr.span.ctxt());
}
}
}
15 changes: 15 additions & 0 deletions tests/target/issue-6202/long_pat.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// max_width = 120
// error_on_line_overflow = true
// style_edition = "2027"

impl EarlyLintPass for NeedlessContinue {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if let ExprKind::Loop(body, label, ..)
| ExprKind::While(_, body, label)
| ExprKind::ForLoop { body, label, .. } = &expr.kind
&& !in_external_macro(cx.sess, expr.span)
{
check_final_block_stmt(cx, body, label, expr.span.ctxt());
}
}
}
Loading