@@ -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
@@ -6180,9 +6205,15 @@ impl HasContainer for TraitAlias {
61806205 }
61816206}
61826207
6208+ impl HasContainer for ExternBlock {
6209+ fn container ( & self , db : & dyn HirDatabase ) -> ItemContainer {
6210+ ItemContainer :: Module ( Module { id : self . id . lookup ( db. upcast ( ) ) . container } )
6211+ }
6212+ }
6213+
61836214fn container_id_to_hir ( c : ItemContainerId ) -> ItemContainer {
61846215 match c {
6185- ItemContainerId :: ExternBlockId ( _id ) => ItemContainer :: ExternBlock ( ) ,
6216+ ItemContainerId :: ExternBlockId ( id ) => ItemContainer :: ExternBlock ( ExternBlock { id } ) ,
61866217 ItemContainerId :: ModuleId ( id) => ItemContainer :: Module ( Module { id } ) ,
61876218 ItemContainerId :: ImplId ( id) => ItemContainer :: Impl ( Impl { id } ) ,
61886219 ItemContainerId :: TraitId ( id) => ItemContainer :: Trait ( Trait { id } ) ,
@@ -6194,7 +6225,7 @@ pub enum ItemContainer {
61946225 Trait ( Trait ) ,
61956226 Impl ( Impl ) ,
61966227 Module ( Module ) ,
6197- ExternBlock ( ) ,
6228+ ExternBlock ( ExternBlock ) ,
61986229 Crate ( CrateId ) ,
61996230}
62006231
0 commit comments