@@ -55,8 +55,8 @@ use hir_def::{
5555 resolver:: { HasResolver , Resolver } ,
5656 type_ref:: TypesSourceMap ,
5757 AdtId , AssocItemId , AssocItemLoc , AttrDefId , CallableDefId , ConstId , ConstParamId ,
58- CrateRootModuleId , DefWithBodyId , EnumId , EnumVariantId , ExternCrateId , FunctionId ,
59- GenericDefId , GenericParamId , HasModule , ImplId , InTypeConstId , ItemContainerId ,
58+ CrateRootModuleId , DefWithBodyId , EnumId , EnumVariantId , ExternBlockId , ExternCrateId ,
59+ FunctionId , GenericDefId , GenericParamId , HasModule , ImplId , InTypeConstId , ItemContainerId ,
6060 LifetimeParamId , LocalFieldId , Lookup , MacroExpander , MacroId , ModuleId , StaticId , StructId ,
6161 SyntheticSyntax , TraitAliasId , TupleId , TypeAliasId , TypeOrConstParamId , TypeParamId , UnionId ,
6262} ;
@@ -2327,6 +2327,13 @@ impl Function {
23272327 db. function_data ( self . id ) . is_async ( )
23282328 }
23292329
2330+ pub fn extern_block ( self , db : & dyn HirDatabase ) -> Option < ExternBlock > {
2331+ match self . id . lookup ( db. upcast ( ) ) . container {
2332+ ItemContainerId :: ExternBlockId ( id) => Some ( ExternBlock { id } ) ,
2333+ _ => None ,
2334+ }
2335+ }
2336+
23302337 pub fn returns_impl_future ( self , db : & dyn HirDatabase ) -> bool {
23312338 if self . is_async ( db) {
23322339 return true ;
@@ -2761,6 +2768,13 @@ impl Static {
27612768 Type :: from_value_def ( db, self . id )
27622769 }
27632770
2771+ pub fn extern_block ( self , db : & dyn HirDatabase ) -> Option < ExternBlock > {
2772+ match self . id . lookup ( db. upcast ( ) ) . container {
2773+ ItemContainerId :: ExternBlockId ( id) => Some ( ExternBlock { id } ) ,
2774+ _ => None ,
2775+ }
2776+ }
2777+
27642778 /// Evaluate the static initializer.
27652779 pub fn eval ( self , db : & dyn HirDatabase ) -> Result < EvaluatedConst , ConstEvalError > {
27662780 db. const_eval ( self . id . into ( ) , Substitution :: empty ( Interner ) , None )
@@ -2928,6 +2942,17 @@ impl HasVisibility for TypeAlias {
29282942 }
29292943}
29302944
2945+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
2946+ pub struct ExternBlock {
2947+ pub ( crate ) id : ExternBlockId ,
2948+ }
2949+
2950+ impl ExternBlock {
2951+ pub fn module ( self , db : & dyn HirDatabase ) -> Module {
2952+ Module { id : self . id . module ( db. upcast ( ) ) }
2953+ }
2954+ }
2955+
29312956#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
29322957pub struct StaticLifetime ;
29332958
@@ -6177,9 +6202,15 @@ impl HasContainer for TraitAlias {
61776202 }
61786203}
61796204
6205+ impl HasContainer for ExternBlock {
6206+ fn container ( & self , db : & dyn HirDatabase ) -> ItemContainer {
6207+ ItemContainer :: Module ( Module { id : self . id . lookup ( db. upcast ( ) ) . container } )
6208+ }
6209+ }
6210+
61806211fn container_id_to_hir ( c : ItemContainerId ) -> ItemContainer {
61816212 match c {
6182- ItemContainerId :: ExternBlockId ( _id ) => ItemContainer :: ExternBlock ( ) ,
6213+ ItemContainerId :: ExternBlockId ( id ) => ItemContainer :: ExternBlock ( ExternBlock { id } ) ,
61836214 ItemContainerId :: ModuleId ( id) => ItemContainer :: Module ( Module { id } ) ,
61846215 ItemContainerId :: ImplId ( id) => ItemContainer :: Impl ( Impl { id } ) ,
61856216 ItemContainerId :: TraitId ( id) => ItemContainer :: Trait ( Trait { id } ) ,
@@ -6191,7 +6222,7 @@ pub enum ItemContainer {
61916222 Trait ( Trait ) ,
61926223 Impl ( Impl ) ,
61936224 Module ( Module ) ,
6194- ExternBlock ( ) ,
6225+ ExternBlock ( ExternBlock ) ,
61956226 Crate ( CrateId ) ,
61966227}
61976228
0 commit comments