@@ -1665,9 +1665,11 @@ impl Enum {
16651665
16661666 /// The type of the enum variant bodies.
16671667 pub fn variant_body_ty < ' db > ( self , db : & ' db dyn HirDatabase ) -> Type < ' db > {
1668- let interner = DbInterner :: new_no_crate ( db) ;
1668+ let krate = self . id . lookup ( db) . container . krate ( db) ;
1669+ let interner = DbInterner :: new_with ( db, krate) ;
16691670 Type :: new_for_crate (
1670- self . id . lookup ( db) . container . krate ( db) ,
1671+ db,
1672+ krate,
16711673 match EnumSignature :: variant_body_type ( db, self . id ) {
16721674 layout:: IntegerType :: Pointer ( sign) => match sign {
16731675 true => Ty :: new_int ( interner, rustc_type_ir:: IntTy :: Isize ) ,
@@ -2267,8 +2269,11 @@ impl DefWithBody {
22672269 mir:: MirSpan :: Unknown => continue ,
22682270 } ;
22692271 acc. push (
2270- MovedOutOfRef { ty : Type :: new_for_crate ( krate, moof. ty . as_ref ( ) ) , span }
2271- . into ( ) ,
2272+ MovedOutOfRef {
2273+ ty : Type :: new_for_crate ( db, krate, moof. ty . as_ref ( ) ) ,
2274+ span,
2275+ }
2276+ . into ( ) ,
22722277 )
22732278 }
22742279 let mol = & borrowck_result. mutability_of_locals ;
@@ -3485,7 +3490,7 @@ impl BuiltinType {
34853490 pub fn ty < ' db > ( self , db : & ' db dyn HirDatabase ) -> Type < ' db > {
34863491 let core = Crate :: core ( db) . map ( |core| core. id ) . unwrap_or_else ( || all_crates ( db) [ 0 ] ) ;
34873492 let interner = DbInterner :: new_no_crate ( db) ;
3488- Type :: new_for_crate ( core, Ty :: from_builtin_type ( interner, self . inner ) )
3493+ Type :: new_for_crate ( db , core, Ty :: from_builtin_type ( interner, self . inner ) )
34893494 }
34903495
34913496 pub fn name ( self ) -> Name {
@@ -5534,8 +5539,13 @@ impl<'db> Type<'db> {
55345539 Type { env : environment, ty }
55355540 }
55365541
5537- pub ( crate ) fn new_for_crate ( krate : base_db:: Crate , ty : Ty < ' db > ) -> Self {
5538- Type { env : empty_param_env ( krate) , ty }
5542+ pub ( crate ) fn new_for_crate (
5543+ db : & ' db dyn HirDatabase ,
5544+ krate : base_db:: Crate ,
5545+ ty : Ty < ' db > ,
5546+ ) -> Self {
5547+ let interner = DbInterner :: new_with ( db, krate) ;
5548+ Type { env : ParamEnvAndCrate { param_env : ParamEnv :: empty ( interner) , krate } , ty }
55395549 }
55405550
55415551 fn new ( db : & ' db dyn HirDatabase , lexical_env : impl HasResolver , ty : Ty < ' db > ) -> Self {
@@ -5588,15 +5598,18 @@ impl<'db> Type<'db> {
55885598 Type :: new ( db, def, ty. instantiate ( interner, args) . skip_norm_wip ( ) )
55895599 }
55905600
5591- pub fn new_slice ( ty : Self ) -> Self {
5592- let interner = DbInterner :: conjure ( ) ;
5601+ pub fn new_slice ( db : & ' db dyn HirDatabase , ty : Self ) -> Self {
5602+ let interner = DbInterner :: new_no_crate ( db ) ;
55935603 Type { env : ty. env , ty : Ty :: new_slice ( interner, ty. ty ) }
55945604 }
55955605
5596- pub fn new_tuple ( krate : base_db:: Crate , tys : & [ Self ] ) -> Self {
5606+ pub fn new_tuple ( db : & ' db dyn HirDatabase , krate : base_db:: Crate , tys : & [ Self ] ) -> Self {
55975607 let tys = tys. iter ( ) . map ( |it| it. ty ) ;
5598- let interner = DbInterner :: conjure ( ) ;
5599- Type { env : empty_param_env ( krate) , ty : Ty :: new_tup_from_iter ( interner, tys) }
5608+ let interner = DbInterner :: new_with ( db, krate) ;
5609+ Type {
5610+ env : ParamEnvAndCrate { param_env : ParamEnv :: empty ( interner) , krate } ,
5611+ ty : Ty :: new_tup_from_iter ( interner, tys) ,
5612+ }
56005613 }
56015614
56025615 pub fn is_unit ( & self ) -> bool {
@@ -5708,8 +5721,8 @@ impl<'db> Type<'db> {
57085721 Some ( ( self . derived ( ty) , m) )
57095722 }
57105723
5711- pub fn add_reference ( & self , mutability : Mutability ) -> Self {
5712- let interner = DbInterner :: conjure ( ) ;
5724+ pub fn add_reference ( & self , db : & ' db dyn HirDatabase , mutability : Mutability ) -> Self {
5725+ let interner = DbInterner :: new_no_crate ( db ) ;
57135726 let ty_mutability = match mutability {
57145727 Mutability :: Shared => hir_ty:: next_solver:: Mutability :: Not ,
57155728 Mutability :: Mut => hir_ty:: next_solver:: Mutability :: Mut ,
@@ -6012,9 +6025,9 @@ impl<'db> Type<'db> {
60126025 }
60136026 }
60146027
6015- pub fn fingerprint_for_trait_impl ( & self ) -> Option < SimplifiedType > {
6028+ pub fn fingerprint_for_trait_impl ( & self , db : & ' db dyn HirDatabase ) -> Option < SimplifiedType > {
60166029 fast_reject:: simplify_type (
6017- DbInterner :: conjure ( ) ,
6030+ DbInterner :: new_no_crate ( db ) ,
60186031 self . ty ,
60196032 fast_reject:: TreatParams :: AsRigid ,
60206033 )
@@ -7430,9 +7443,10 @@ fn param_env_from_resolver<'db>(
74307443 resolver : & Resolver < ' _ > ,
74317444) -> ParamEnvAndCrate < ' db > {
74327445 ParamEnvAndCrate {
7433- param_env : resolver
7434- . generic_def ( )
7435- . map_or_else ( ParamEnv :: empty, |generic_def| db. trait_environment ( generic_def. into ( ) ) ) ,
7446+ param_env : resolver. generic_def ( ) . map_or_else (
7447+ || ParamEnv :: empty ( DbInterner :: new_no_crate ( db) ) ,
7448+ |generic_def| db. trait_environment ( generic_def. into ( ) ) ,
7449+ ) ,
74367450 krate : resolver. krate ( ) ,
74377451 }
74387452}
@@ -7451,10 +7465,6 @@ fn body_param_env_from_has_crate<'db>(
74517465 ParamEnvAndCrate { param_env : db. trait_environment ( id. into ( ) ) , krate : id. krate ( db) }
74527466}
74537467
7454- fn empty_param_env < ' db > ( krate : base_db:: Crate ) -> ParamEnvAndCrate < ' db > {
7455- ParamEnvAndCrate { param_env : ParamEnv :: empty ( ) , krate }
7456- }
7457-
74587468// FIXME: We probably don't want to expose this.
74597469pub trait MacroCallIdExt {
74607470 fn loc ( self , db : & dyn HirDatabase ) -> hir_expand:: MacroCallLoc ;
0 commit comments