mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add parentheses for binding mode hints when they attach to an Or-pattern
This commit is contained in:
parent
632f804797
commit
b6c2bb21ab
2 changed files with 40 additions and 12 deletions
|
@ -65,10 +65,11 @@ pub enum InlayKind {
|
|||
ClosureReturnTypeHint,
|
||||
GenericParamListHint,
|
||||
AdjustmentHint,
|
||||
AdjustmentHintClosingParenthesis,
|
||||
LifetimeHint,
|
||||
ParameterHint,
|
||||
TypeHint,
|
||||
OpeningParenthesis,
|
||||
ClosingParenthesis,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -671,7 +672,7 @@ fn adjustment_hints(
|
|||
if needs_parens {
|
||||
acc.push(InlayHint {
|
||||
range: expr.syntax().text_range(),
|
||||
kind: InlayKind::AdjustmentHint,
|
||||
kind: InlayKind::OpeningParenthesis,
|
||||
label: "(".into(),
|
||||
tooltip: None,
|
||||
});
|
||||
|
@ -716,7 +717,7 @@ fn adjustment_hints(
|
|||
if needs_parens {
|
||||
acc.push(InlayHint {
|
||||
range: expr.syntax().text_range(),
|
||||
kind: InlayKind::AdjustmentHintClosingParenthesis,
|
||||
kind: InlayKind::ClosingParenthesis,
|
||||
label: ")".into(),
|
||||
tooltip: None,
|
||||
});
|
||||
|
@ -880,6 +881,20 @@ fn binding_mode_hints(
|
|||
tooltip: Some(InlayTooltip::String("Inferred binding mode".into())),
|
||||
});
|
||||
}
|
||||
ast::Pat::OrPat(pat) => {
|
||||
acc.push(InlayHint {
|
||||
range: pat.syntax().text_range(),
|
||||
kind: InlayKind::OpeningParenthesis,
|
||||
label: "(".into(),
|
||||
tooltip: None,
|
||||
});
|
||||
acc.push(InlayHint {
|
||||
range: pat.syntax().text_range(),
|
||||
kind: InlayKind::ClosingParenthesis,
|
||||
label: ")".into(),
|
||||
tooltip: None,
|
||||
});
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
|
@ -2951,9 +2966,18 @@ fn __(
|
|||
(x,) => ()
|
||||
}
|
||||
match &(0,) {
|
||||
(x,) => ()
|
||||
//^^^^ &
|
||||
(x,) | (x,) => (),
|
||||
//^^^^^^^^^^^&
|
||||
//^ ref
|
||||
//^ ref
|
||||
//^^^^^^^^^^^(
|
||||
//^^^^^^^^^^^)
|
||||
((x,) | (x,)) => (),
|
||||
//^^^^^^^^^^^&
|
||||
//^ ref
|
||||
//^ ref
|
||||
//^^^^^^^^^^^(
|
||||
//^^^^^^^^^^^)
|
||||
}
|
||||
match &mut (0,) {
|
||||
(x,) => ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue