Merge #11771
11771: feat: Visualize compiler inserted reborrows via inlay hints r=Veykril a=Veykril Disabled by default.  Closes https://github.com/rust-analyzer/rust-analyzer/issues/11275 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
@@ -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,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user