@@ -11,8 +11,8 @@ use hir::{
1111 Adt , AsAssocItem , AsExternAssocItem , AssocItem , AttributeTemplate , BuiltinAttr , BuiltinType ,
1212 Const , Crate , DefWithBody , DeriveHelper , DocLinkDef , ExternAssocItem , ExternCrateDecl , Field ,
1313 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 ,
1616} ;
1717use stdx:: { format_to, impl_from} ;
1818use syntax:: {
@@ -39,12 +39,13 @@ pub enum Definition {
3939 Trait ( Trait ) ,
4040 TraitAlias ( TraitAlias ) ,
4141 TypeAlias ( TypeAlias ) ,
42- BuiltinType ( BuiltinType ) ,
4342 SelfType ( Impl ) ,
4443 GenericParam ( GenericParam ) ,
4544 Local ( Local ) ,
4645 Label ( Label ) ,
4746 DeriveHelper ( DeriveHelper ) ,
47+ BuiltinType ( BuiltinType ) ,
48+ BuiltinLifetime ( StaticLifetime ) ,
4849 BuiltinAttr ( BuiltinAttr ) ,
4950 ToolModule ( ToolModule ) ,
5051 ExternCrateDecl ( ExternCrateDecl ) ,
@@ -83,6 +84,7 @@ impl Definition {
8384 Definition :: DeriveHelper ( it) => it. derive ( ) . module ( db) ,
8485 Definition :: BuiltinAttr ( _)
8586 | Definition :: BuiltinType ( _)
87+ | Definition :: BuiltinLifetime ( _)
8688 | Definition :: TupleField ( _)
8789 | Definition :: ToolModule ( _) => return None ,
8890 } ;
@@ -112,6 +114,7 @@ impl Definition {
112114 Definition :: BuiltinType ( _) | Definition :: TupleField ( _) => Visibility :: Public ,
113115 Definition :: Macro ( _) => return None ,
114116 Definition :: BuiltinAttr ( _)
117+ | Definition :: BuiltinLifetime ( _)
115118 | Definition :: ToolModule ( _)
116119 | Definition :: SelfType ( _)
117120 | Definition :: Local ( _)
@@ -141,6 +144,7 @@ impl Definition {
141144 Definition :: Local ( it) => it. name ( db) ,
142145 Definition :: GenericParam ( it) => it. name ( db) ,
143146 Definition :: Label ( it) => it. name ( db) ,
147+ Definition :: BuiltinLifetime ( StaticLifetime ) => hir:: known:: STATIC_LIFETIME ,
144148 Definition :: BuiltinAttr ( _) => return None , // FIXME
145149 Definition :: ToolModule ( _) => return None , // FIXME
146150 Definition :: DeriveHelper ( it) => it. name ( db) ,
@@ -174,6 +178,7 @@ impl Definition {
174178 doc_owner. docs ( fd. 0 . db )
175179 } )
176180 }
181+ Definition :: BuiltinLifetime ( StaticLifetime ) => None ,
177182 Definition :: Local ( _) => None ,
178183 Definition :: SelfType ( impl_def) => {
179184 impl_def. self_ty ( db) . as_adt ( ) . map ( |adt| adt. docs ( db) ) ?
@@ -228,6 +233,7 @@ impl Definition {
228233 Definition :: TraitAlias ( it) => it. display ( db) . to_string ( ) ,
229234 Definition :: TypeAlias ( it) => it. display ( db) . to_string ( ) ,
230235 Definition :: BuiltinType ( it) => it. name ( ) . display ( db) . to_string ( ) ,
236+ Definition :: BuiltinLifetime ( it) => it. name ( ) . display ( db) . to_string ( ) ,
231237 Definition :: Local ( it) => {
232238 let ty = it. ty ( db) ;
233239 let ty_display = ty. display_truncated ( db, None ) ;
@@ -693,6 +699,9 @@ impl NameRefClass {
693699 ) -> Option < NameRefClass > {
694700 let _p = tracing:: span!( tracing:: Level :: INFO , "NameRefClass::classify_lifetime" , ?lifetime)
695701 . entered ( ) ;
702+ if lifetime. text ( ) == "'static" {
703+ return Some ( NameRefClass :: Definition ( Definition :: BuiltinLifetime ( StaticLifetime ) ) ) ;
704+ }
696705 let parent = lifetime. syntax ( ) . parent ( ) ?;
697706 match parent. kind ( ) {
698707 SyntaxKind :: BREAK_EXPR | SyntaxKind :: CONTINUE_EXPR => {
0 commit comments