Skip to content

Commit b9341e2

Browse files
committed
Fix binding mode hints always adding parentheses to or-patterns
1 parent 271f7b4 commit b9341e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/ide/src/inlay_hints/binding_mode.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ pub(super) fn hints(
3131
.last();
3232
let range =
3333
outer_paren_pat.as_ref().map_or_else(|| pat.syntax(), |it| it.syntax()).text_range();
34-
sema.pattern_adjustments(&pat).iter().for_each(|ty| {
34+
let pattern_adjustments = sema.pattern_adjustments(&pat);
35+
pattern_adjustments.iter().for_each(|ty| {
3536
let reference = ty.is_reference();
3637
let mut_reference = ty.is_mutable_reference();
3738
let r = match (reference, mut_reference) {
@@ -61,7 +62,7 @@ pub(super) fn hints(
6162
tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
6263
});
6364
}
64-
ast::Pat::OrPat(pat) if outer_paren_pat.is_none() => {
65+
ast::Pat::OrPat(pat) if !pattern_adjustments.is_empty() && outer_paren_pat.is_none() => {
6566
acc.push(InlayHint {
6667
range: pat.syntax().text_range(),
6768
kind: InlayKind::OpeningParenthesis,

0 commit comments

Comments
 (0)