Skip to content

Commit 80c3eaa

Browse files
committed
Use let-chain instead of match on Option
1 parent 8205e6b commit 80c3eaa

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,13 +2605,14 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
26052605
&& let ast::ExprKind::Path(None, ref path) = lhs.kind
26062606
&& self.r.tcx.sess.source_map().is_line_before_span_empty(ident_span)
26072607
{
2608-
let (span, text) = match path.segments.first() {
2609-
Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => {
2610-
// a special case for #117894
2611-
let name = name.strip_prefix('_').unwrap_or(name);
2612-
(ident_span, format!("let {name}"))
2613-
}
2614-
_ => (ident_span.shrink_to_lo(), "let ".to_string()),
2608+
let (span, text) = if let Some(seg) = path.segments.first()
2609+
&& let Some(name) = seg.ident.as_str().strip_prefix("let")
2610+
{
2611+
// a special case for #117894
2612+
let name = name.strip_prefix('_').unwrap_or(name);
2613+
(ident_span, format!("let {name}"))
2614+
} else {
2615+
(ident_span.shrink_to_lo(), "let ".to_string())
26152616
};
26162617

26172618
err.span_suggestion_verbose(

0 commit comments

Comments
 (0)