@@ -11,8 +11,8 @@ use hir::{
11
11
Adt , AsAssocItem , AsExternAssocItem , AssocItem , AttributeTemplate , BuiltinAttr , BuiltinType ,
12
12
Const , Crate , DefWithBody , DeriveHelper , DocLinkDef , ExternAssocItem , ExternCrateDecl , Field ,
13
13
Function , GenericParam , HasVisibility , HirDisplay , Impl , Label , Local , Macro , Module ,
14
- ModuleDef , Name , PathResolution , Semantics , Static , ToolModule , Trait , TraitAlias , TupleField ,
15
- TypeAlias , Variant , VariantDef , Visibility ,
14
+ ModuleDef , Name , PathResolution , Semantics , Static , StaticLifetime , ToolModule , Trait ,
15
+ TraitAlias , TupleField , TypeAlias , Variant , VariantDef , Visibility ,
16
16
} ;
17
17
use stdx:: { format_to, impl_from} ;
18
18
use syntax:: {
@@ -39,12 +39,13 @@ pub enum Definition {
39
39
Trait ( Trait ) ,
40
40
TraitAlias ( TraitAlias ) ,
41
41
TypeAlias ( TypeAlias ) ,
42
- BuiltinType ( BuiltinType ) ,
43
42
SelfType ( Impl ) ,
44
43
GenericParam ( GenericParam ) ,
45
44
Local ( Local ) ,
46
45
Label ( Label ) ,
47
46
DeriveHelper ( DeriveHelper ) ,
47
+ BuiltinType ( BuiltinType ) ,
48
+ BuiltinLifetime ( StaticLifetime ) ,
48
49
BuiltinAttr ( BuiltinAttr ) ,
49
50
ToolModule ( ToolModule ) ,
50
51
ExternCrateDecl ( ExternCrateDecl ) ,
@@ -83,6 +84,7 @@ impl Definition {
83
84
Definition :: DeriveHelper ( it) => it. derive ( ) . module ( db) ,
84
85
Definition :: BuiltinAttr ( _)
85
86
| Definition :: BuiltinType ( _)
87
+ | Definition :: BuiltinLifetime ( _)
86
88
| Definition :: TupleField ( _)
87
89
| Definition :: ToolModule ( _) => return None ,
88
90
} ;
@@ -112,6 +114,7 @@ impl Definition {
112
114
Definition :: BuiltinType ( _) | Definition :: TupleField ( _) => Visibility :: Public ,
113
115
Definition :: Macro ( _) => return None ,
114
116
Definition :: BuiltinAttr ( _)
117
+ | Definition :: BuiltinLifetime ( _)
115
118
| Definition :: ToolModule ( _)
116
119
| Definition :: SelfType ( _)
117
120
| Definition :: Local ( _)
@@ -141,6 +144,7 @@ impl Definition {
141
144
Definition :: Local ( it) => it. name ( db) ,
142
145
Definition :: GenericParam ( it) => it. name ( db) ,
143
146
Definition :: Label ( it) => it. name ( db) ,
147
+ Definition :: BuiltinLifetime ( StaticLifetime ) => hir:: known:: STATIC_LIFETIME ,
144
148
Definition :: BuiltinAttr ( _) => return None , // FIXME
145
149
Definition :: ToolModule ( _) => return None , // FIXME
146
150
Definition :: DeriveHelper ( it) => it. name ( db) ,
@@ -174,6 +178,7 @@ impl Definition {
174
178
doc_owner. docs ( fd. 0 . db )
175
179
} )
176
180
}
181
+ Definition :: BuiltinLifetime ( StaticLifetime ) => None ,
177
182
Definition :: Local ( _) => None ,
178
183
Definition :: SelfType ( impl_def) => {
179
184
impl_def. self_ty ( db) . as_adt ( ) . map ( |adt| adt. docs ( db) ) ?
@@ -228,6 +233,7 @@ impl Definition {
228
233
Definition :: TraitAlias ( it) => it. display ( db) . to_string ( ) ,
229
234
Definition :: TypeAlias ( it) => it. display ( db) . to_string ( ) ,
230
235
Definition :: BuiltinType ( it) => it. name ( ) . display ( db) . to_string ( ) ,
236
+ Definition :: BuiltinLifetime ( it) => it. name ( ) . display ( db) . to_string ( ) ,
231
237
Definition :: Local ( it) => {
232
238
let ty = it. ty ( db) ;
233
239
let ty_display = ty. display_truncated ( db, None ) ;
@@ -693,6 +699,9 @@ impl NameRefClass {
693
699
) -> Option < NameRefClass > {
694
700
let _p = tracing:: span!( tracing:: Level :: INFO , "NameRefClass::classify_lifetime" , ?lifetime)
695
701
. entered ( ) ;
702
+ if lifetime. text ( ) == "'static" {
703
+ return Some ( NameRefClass :: Definition ( Definition :: BuiltinLifetime ( StaticLifetime ) ) ) ;
704
+ }
696
705
let parent = lifetime. syntax ( ) . parent ( ) ?;
697
706
match parent. kind ( ) {
698
707
SyntaxKind :: BREAK_EXPR | SyntaxKind :: CONTINUE_EXPR => {
0 commit comments