Skip to content

Commit e25129b

Browse files
take advantage of a labelled block
Co-authored-by: Michael Goulet <[email protected]>
1 parent 3c7f1f1 commit e25129b

File tree

1 file changed

+8
-8
lines changed
  • compiler/rustc_typeck/src/check

1 file changed

+8
-8
lines changed

compiler/rustc_typeck/src/check/pat.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
669669
}
670670

671671
let ident_kind = match binding_parent {
672-
hir::Node::Param(_) => Some("parameter"),
673-
hir::Node::Local(_) => Some("variable"),
674-
hir::Node::Arm(_) => Some("binding"),
672+
hir::Node::Param(_) => "parameter",
673+
hir::Node::Local(_) => "variable",
674+
hir::Node::Arm(_) => "binding",
675675

676676
// Provide diagnostics only if the parent pattern is struct-like,
677677
// i.e. where `mut binding` makes sense
@@ -680,24 +680,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
680680
| PatKind::TupleStruct(..)
681681
| PatKind::Or(..)
682682
| PatKind::Tuple(..)
683-
| PatKind::Slice(..) => Some("binding"),
683+
| PatKind::Slice(..) => "binding",
684684

685685
PatKind::Wild
686686
| PatKind::Binding(..)
687687
| PatKind::Path(..)
688688
| PatKind::Box(..)
689689
| PatKind::Ref(..)
690690
| PatKind::Lit(..)
691-
| PatKind::Range(..) => None,
691+
| PatKind::Range(..) => break 'block None,
692692
},
693693

694694
// Don't provide suggestions in other cases
695-
_ => None,
695+
_ => break 'block None,
696696
};
697697

698-
ident_kind.map(|thing| (
698+
Some((
699699
pat.span,
700-
format!("to declare a mutable {thing} use `mut variable_name`"),
700+
format!("to declare a mutable {ident_kind} use `mut variable_name`"),
701701
format!("mut {binding}"),
702702
))
703703

0 commit comments

Comments
 (0)