take advantage of a labelled block
Co-authored-by: Michael Goulet <michael@errs.io>
This commit is contained in:
parent
3c7f1f1601
commit
e25129b055
@ -669,9 +669,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ident_kind = match binding_parent {
|
let ident_kind = match binding_parent {
|
||||||
hir::Node::Param(_) => Some("parameter"),
|
hir::Node::Param(_) => "parameter",
|
||||||
hir::Node::Local(_) => Some("variable"),
|
hir::Node::Local(_) => "variable",
|
||||||
hir::Node::Arm(_) => Some("binding"),
|
hir::Node::Arm(_) => "binding",
|
||||||
|
|
||||||
// Provide diagnostics only if the parent pattern is struct-like,
|
// Provide diagnostics only if the parent pattern is struct-like,
|
||||||
// i.e. where `mut binding` makes sense
|
// i.e. where `mut binding` makes sense
|
||||||
@ -680,7 +680,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
| PatKind::TupleStruct(..)
|
| PatKind::TupleStruct(..)
|
||||||
| PatKind::Or(..)
|
| PatKind::Or(..)
|
||||||
| PatKind::Tuple(..)
|
| PatKind::Tuple(..)
|
||||||
| PatKind::Slice(..) => Some("binding"),
|
| PatKind::Slice(..) => "binding",
|
||||||
|
|
||||||
PatKind::Wild
|
PatKind::Wild
|
||||||
| PatKind::Binding(..)
|
| PatKind::Binding(..)
|
||||||
@ -688,16 +688,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
| PatKind::Box(..)
|
| PatKind::Box(..)
|
||||||
| PatKind::Ref(..)
|
| PatKind::Ref(..)
|
||||||
| PatKind::Lit(..)
|
| PatKind::Lit(..)
|
||||||
| PatKind::Range(..) => None,
|
| PatKind::Range(..) => break 'block None,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Don't provide suggestions in other cases
|
// Don't provide suggestions in other cases
|
||||||
_ => None,
|
_ => break 'block None,
|
||||||
};
|
};
|
||||||
|
|
||||||
ident_kind.map(|thing| (
|
Some((
|
||||||
pat.span,
|
pat.span,
|
||||||
format!("to declare a mutable {thing} use `mut variable_name`"),
|
format!("to declare a mutable {ident_kind} use `mut variable_name`"),
|
||||||
format!("mut {binding}"),
|
format!("mut {binding}"),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user