1 //! Implementation of "implicit static" inlay hints:
3 //! static S: &/* 'static */str = "";
11 use crate::{InlayHint, InlayHintsConfig, InlayKind, InlayTooltip, LifetimeElisionHints}
;
14 acc
: &mut Vec
<InlayHint
>,
15 config
: &InlayHintsConfig
,
16 statik_or_const
: Either
<ast
::Static
, ast
::Const
>,
18 if config
.lifetime_elision_hints
!= LifetimeElisionHints
::Always
{
22 if let Either
::Right(it
) = &statik_or_const
{
23 if ast
::AssocItemList
::can_cast(
24 it
.syntax().parent().map_or(SyntaxKind
::EOF
, |it
| it
.kind()),
30 if let Some(ast
::Type
::RefType(ty
)) = statik_or_const
.either(|it
| it
.ty(), |it
| it
.ty()) {
31 if ty
.lifetime().is_none() {
32 let t
= ty
.amp_token()?
;
34 range
: t
.text_range(),
35 kind
: InlayKind
::LifetimeHint
,
36 label
: "'static".to_owned().into(),
37 tooltip
: Some(InlayTooltip
::String("Elided static lifetime".into())),
48 inlay_hints
::tests
::{check_with_config, TEST_CONFIG}
,
49 InlayHintsConfig
, LifetimeElisionHints
,
53 fn hints_lifetimes_static() {
56 lifetime_elision_hints
: LifetimeElisionHints
::Always
,
65 const C: &dyn Trait = panic!();
70 const C: &dyn Trait = panic!();