Auto merge of #13820 - Veykril:or-pat-bm-fix, r=Veykril

Fix binding mode hints always adding parentheses to or-patterns
This commit is contained in:
bors 2022-12-22 23:02:19 +00:00
commit a06525517b

View file

@ -31,7 +31,8 @@ pub(super) fn hints(
.last(); .last();
let range = let range =
outer_paren_pat.as_ref().map_or_else(|| pat.syntax(), |it| it.syntax()).text_range(); outer_paren_pat.as_ref().map_or_else(|| pat.syntax(), |it| it.syntax()).text_range();
sema.pattern_adjustments(&pat).iter().for_each(|ty| { let pattern_adjustments = sema.pattern_adjustments(&pat);
pattern_adjustments.iter().for_each(|ty| {
let reference = ty.is_reference(); let reference = ty.is_reference();
let mut_reference = ty.is_mutable_reference(); let mut_reference = ty.is_mutable_reference();
let r = match (reference, mut_reference) { let r = match (reference, mut_reference) {
@ -61,7 +62,7 @@ pub(super) fn hints(
tooltip: Some(InlayTooltip::String("Inferred binding mode".into())), tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
}); });
} }
ast::Pat::OrPat(pat) if outer_paren_pat.is_none() => { ast::Pat::OrPat(pat) if !pattern_adjustments.is_empty() && outer_paren_pat.is_none() => {
acc.push(InlayHint { acc.push(InlayHint {
range: pat.syntax().text_range(), range: pat.syntax().text_range(),
kind: InlayKind::OpeningParenthesis, kind: InlayKind::OpeningParenthesis,