mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
feat: Visualize compiler inserted reborrows via inlay hints
This commit is contained in:
parent
2598575a35
commit
37b48ceb8f
9 changed files with 126 additions and 13 deletions
|
@ -256,6 +256,8 @@ config_data! {
|
|||
inlayHints_chainingHints: bool = "true",
|
||||
/// Whether to show inlay type hints for return types of closures with blocks.
|
||||
inlayHints_closureReturnTypeHints: bool = "false",
|
||||
/// Whether to show inlay type hints for compiler inserted reborrows.
|
||||
inlayHints_reborrowHints: bool = "false",
|
||||
/// Whether to show inlay type hints for elided lifetimes in function signatures.
|
||||
inlayHints_lifetimeElisionHints: LifetimeElisionDef = "\"never\"",
|
||||
/// Whether to prefer using parameter names as the name for elided lifetime hints if possible.
|
||||
|
@ -866,6 +868,7 @@ impl Config {
|
|||
LifetimeElisionDef::SkipTrivial => LifetimeElisionHints::SkipTrivial,
|
||||
},
|
||||
hide_named_constructor_hints: self.data.inlayHints_hideNamedConstructorHints,
|
||||
reborrow_hints: self.data.inlayHints_reborrowHints,
|
||||
param_names_for_lifetime_elision_hints: self
|
||||
.data
|
||||
.inlayHints_lifetimeElisionHints_useParameterNames,
|
||||
|
|
|
@ -426,7 +426,11 @@ pub(crate) fn inlay_hint(
|
|||
_ => inlay_hint.label.to_string(),
|
||||
}),
|
||||
position: match inlay_hint.kind {
|
||||
InlayKind::ParameterHint => position(line_index, inlay_hint.range.start()),
|
||||
// before annotated thing
|
||||
InlayKind::ParameterHint | InlayKind::ImplicitReborrow => {
|
||||
position(line_index, inlay_hint.range.start())
|
||||
}
|
||||
// after annotated thing
|
||||
InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::TypeHint
|
||||
| InlayKind::ChainingHint
|
||||
|
@ -438,7 +442,9 @@ pub(crate) fn inlay_hint(
|
|||
InlayKind::ClosureReturnTypeHint | InlayKind::TypeHint | InlayKind::ChainingHint => {
|
||||
Some(lsp_ext::InlayHintKind::TYPE)
|
||||
}
|
||||
InlayKind::GenericParamListHint | InlayKind::LifetimeHint => None,
|
||||
InlayKind::GenericParamListHint
|
||||
| InlayKind::LifetimeHint
|
||||
| InlayKind::ImplicitReborrow => None,
|
||||
},
|
||||
tooltip: None,
|
||||
padding_left: Some(match inlay_hint.kind {
|
||||
|
@ -447,6 +453,7 @@ pub(crate) fn inlay_hint(
|
|||
InlayKind::ChainingHint => true,
|
||||
InlayKind::GenericParamListHint => false,
|
||||
InlayKind::LifetimeHint => false,
|
||||
InlayKind::ImplicitReborrow => false,
|
||||
}),
|
||||
padding_right: Some(match inlay_hint.kind {
|
||||
InlayKind::TypeHint | InlayKind::ChainingHint | InlayKind::ClosureReturnTypeHint => {
|
||||
|
@ -455,6 +462,7 @@ pub(crate) fn inlay_hint(
|
|||
InlayKind::ParameterHint => true,
|
||||
InlayKind::LifetimeHint => true,
|
||||
InlayKind::GenericParamListHint => false,
|
||||
InlayKind::ImplicitReborrow => false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue