mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-30 19:49:36 +00:00 
			
		
		
		
	chore: Replace some invokes with invoke_actual in hir-ty
				
					
				
			This commit is contained in:
		
							parent
							
								
									cdcadb4265
								
							
						
					
					
						commit
						bcc8e3a0b6
					
				
					 10 changed files with 81 additions and 74 deletions
				
			
		|  | @ -21,7 +21,7 @@ use hir_def::{ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|     AliasEq, AliasTy, BoundVar, DebruijnIndex, FnDefId, Interner, ProjectionTy, ProjectionTyExt, |     AliasEq, AliasTy, BoundVar, DebruijnIndex, Interner, ProjectionTy, ProjectionTyExt, | ||||||
|     QuantifiedWhereClause, Substitution, TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, |     QuantifiedWhereClause, Substitution, TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, | ||||||
|     WhereClause, |     WhereClause, | ||||||
|     db::{HirDatabase, InternedCoroutine}, |     db::{HirDatabase, InternedCoroutine}, | ||||||
|  | @ -53,7 +53,7 @@ pub(crate) type Variances = chalk_ir::Variances<Interner>; | ||||||
| 
 | 
 | ||||||
| impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> { | impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> { | ||||||
|     fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> { |     fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> { | ||||||
|         self.db.associated_ty_data(id) |         self.db.associated_ty_data(from_assoc_type_id(id)) | ||||||
|     } |     } | ||||||
|     fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> { |     fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> { | ||||||
|         self.db.trait_datum(self.krate, trait_id) |         self.db.trait_datum(self.krate, trait_id) | ||||||
|  | @ -105,7 +105,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> { | ||||||
|         &self, |         &self, | ||||||
|         fn_def_id: chalk_ir::FnDefId<Interner>, |         fn_def_id: chalk_ir::FnDefId<Interner>, | ||||||
|     ) -> Arc<rust_ir::FnDefDatum<Interner>> { |     ) -> Arc<rust_ir::FnDefDatum<Interner>> { | ||||||
|         self.db.fn_def_datum(fn_def_id) |         self.db.fn_def_datum(from_chalk(self.db, fn_def_id)) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn impls_for_trait( |     fn impls_for_trait( | ||||||
|  | @ -447,7 +447,7 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> { | ||||||
|         Arc::new(rust_ir::AdtSizeAlign::from_one_zst(false)) |         Arc::new(rust_ir::AdtSizeAlign::from_one_zst(false)) | ||||||
|     } |     } | ||||||
|     fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String { |     fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId<Interner>) -> String { | ||||||
|         let id = self.db.associated_ty_data(assoc_ty_id).name; |         let id = self.db.associated_ty_data(from_assoc_type_id(assoc_ty_id)).name; | ||||||
|         self.db.type_alias_data(id).name.display(self.db.upcast(), self.edition()).to_string() |         self.db.type_alias_data(id).name.display(self.db.upcast(), self.edition()).to_string() | ||||||
|     } |     } | ||||||
|     fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String { |     fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId<Interner>) -> String { | ||||||
|  | @ -583,11 +583,11 @@ impl chalk_ir::UnificationDatabase<Interner> for &dyn HirDatabase { | ||||||
|         &self, |         &self, | ||||||
|         fn_def_id: chalk_ir::FnDefId<Interner>, |         fn_def_id: chalk_ir::FnDefId<Interner>, | ||||||
|     ) -> chalk_ir::Variances<Interner> { |     ) -> chalk_ir::Variances<Interner> { | ||||||
|         HirDatabase::fn_def_variance(*self, fn_def_id) |         HirDatabase::fn_def_variance(*self, from_chalk(*self, fn_def_id)) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn adt_variance(&self, adt_id: chalk_ir::AdtId<Interner>) -> chalk_ir::Variances<Interner> { |     fn adt_variance(&self, adt_id: chalk_ir::AdtId<Interner>) -> chalk_ir::Variances<Interner> { | ||||||
|         HirDatabase::adt_variance(*self, adt_id) |         HirDatabase::adt_variance(*self, adt_id.0) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -602,10 +602,9 @@ pub(crate) fn program_clauses_for_chalk_env_query( | ||||||
| 
 | 
 | ||||||
| pub(crate) fn associated_ty_data_query( | pub(crate) fn associated_ty_data_query( | ||||||
|     db: &dyn HirDatabase, |     db: &dyn HirDatabase, | ||||||
|     id: AssocTypeId, |     type_alias: TypeAliasId, | ||||||
| ) -> Arc<AssociatedTyDatum> { | ) -> Arc<AssociatedTyDatum> { | ||||||
|     debug!("associated_ty_data {:?}", id); |     debug!("associated_ty_data {:?}", type_alias); | ||||||
|     let type_alias: TypeAliasId = from_assoc_type_id(id); |  | ||||||
|     let trait_ = match type_alias.lookup(db.upcast()).container { |     let trait_ = match type_alias.lookup(db.upcast()).container { | ||||||
|         ItemContainerId::TraitId(t) => t, |         ItemContainerId::TraitId(t) => t, | ||||||
|         _ => panic!("associated type not in trait"), |         _ => panic!("associated type not in trait"), | ||||||
|  | @ -656,7 +655,7 @@ pub(crate) fn associated_ty_data_query( | ||||||
|     let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses: vec![] }; |     let bound_data = rust_ir::AssociatedTyDatumBound { bounds, where_clauses: vec![] }; | ||||||
|     let datum = AssociatedTyDatum { |     let datum = AssociatedTyDatum { | ||||||
|         trait_id: to_chalk_trait_id(trait_), |         trait_id: to_chalk_trait_id(trait_), | ||||||
|         id, |         id: to_assoc_type_id(type_alias), | ||||||
|         name: type_alias, |         name: type_alias, | ||||||
|         binders: make_binders(db, &generic_params, bound_data), |         binders: make_binders(db, &generic_params, bound_data), | ||||||
|     }; |     }; | ||||||
|  | @ -923,8 +922,10 @@ fn type_alias_associated_ty_value( | ||||||
|     Arc::new(value) |     Arc::new(value) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub(crate) fn fn_def_datum_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Arc<FnDefDatum> { | pub(crate) fn fn_def_datum_query( | ||||||
|     let callable_def: CallableDefId = from_chalk(db, fn_def_id); |     db: &dyn HirDatabase, | ||||||
|  |     callable_def: CallableDefId, | ||||||
|  | ) -> Arc<FnDefDatum> { | ||||||
|     let generic_def = GenericDefId::from_callable(db.upcast(), callable_def); |     let generic_def = GenericDefId::from_callable(db.upcast(), callable_def); | ||||||
|     let generic_params = generics(db.upcast(), generic_def); |     let generic_params = generics(db.upcast(), generic_def); | ||||||
|     let (sig, binders) = db.callable_item_signature(callable_def).into_value_and_skipped_binders(); |     let (sig, binders) = db.callable_item_signature(callable_def).into_value_and_skipped_binders(); | ||||||
|  | @ -943,7 +944,7 @@ pub(crate) fn fn_def_datum_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Ar | ||||||
|         where_clauses, |         where_clauses, | ||||||
|     }; |     }; | ||||||
|     let datum = FnDefDatum { |     let datum = FnDefDatum { | ||||||
|         id: fn_def_id, |         id: callable_def.to_chalk(db), | ||||||
|         sig: chalk_ir::FnSig { |         sig: chalk_ir::FnSig { | ||||||
|             abi: sig.abi, |             abi: sig.abi, | ||||||
|             safety: chalk_ir::Safety::Safe, |             safety: chalk_ir::Safety::Safe, | ||||||
|  | @ -954,8 +955,10 @@ pub(crate) fn fn_def_datum_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Ar | ||||||
|     Arc::new(datum) |     Arc::new(datum) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub(crate) fn fn_def_variance_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> Variances { | pub(crate) fn fn_def_variance_query( | ||||||
|     let callable_def: CallableDefId = from_chalk(db, fn_def_id); |     db: &dyn HirDatabase, | ||||||
|  |     callable_def: CallableDefId, | ||||||
|  | ) -> Variances { | ||||||
|     Variances::from_iter( |     Variances::from_iter( | ||||||
|         Interner, |         Interner, | ||||||
|         db.variances_of(GenericDefId::from_callable(db.upcast(), callable_def)) |         db.variances_of(GenericDefId::from_callable(db.upcast(), callable_def)) | ||||||
|  | @ -971,10 +974,7 @@ pub(crate) fn fn_def_variance_query(db: &dyn HirDatabase, fn_def_id: FnDefId) -> | ||||||
|     ) |     ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub(crate) fn adt_variance_query( | pub(crate) fn adt_variance_query(db: &dyn HirDatabase, adt_id: hir_def::AdtId) -> Variances { | ||||||
|     db: &dyn HirDatabase, |  | ||||||
|     chalk_ir::AdtId(adt_id): AdtId, |  | ||||||
| ) -> Variances { |  | ||||||
|     Variances::from_iter( |     Variances::from_iter( | ||||||
|         Interner, |         Interner, | ||||||
|         db.variances_of(adt_id.into()).as_deref().unwrap_or_default().iter().map(|v| match v { |         db.variances_of(adt_id.into()).as_deref().unwrap_or_default().iter().map(|v| match v { | ||||||
|  |  | ||||||
|  | @ -17,8 +17,8 @@ use smallvec::SmallVec; | ||||||
| use triomphe::Arc; | use triomphe::Arc; | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|     Binders, ClosureId, Const, FnDefId, ImplTraitId, ImplTraits, InferenceResult, Interner, |     Binders, Const, ImplTraitId, ImplTraits, InferenceResult, Interner, PolyFnSig, Substitution, | ||||||
|     PolyFnSig, Substitution, TraitEnvironment, TraitRef, Ty, TyDefId, ValueTyDefId, chalk_db, |     TraitEnvironment, TraitRef, Ty, TyDefId, ValueTyDefId, chalk_db, | ||||||
|     consteval::ConstEvalError, |     consteval::ConstEvalError, | ||||||
|     drop::DropGlue, |     drop::DropGlue, | ||||||
|     dyn_compatibility::DynCompatibilityViolation, |     dyn_compatibility::DynCompatibilityViolation, | ||||||
|  | @ -39,8 +39,8 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> + std::fmt::Debug { | ||||||
|     #[salsa::cycle(crate::mir::mir_body_recover)] |     #[salsa::cycle(crate::mir::mir_body_recover)] | ||||||
|     fn mir_body(&self, def: DefWithBodyId) -> Result<Arc<MirBody>, MirLowerError>; |     fn mir_body(&self, def: DefWithBodyId) -> Result<Arc<MirBody>, MirLowerError>; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(crate::mir::mir_body_for_closure_query)] |     #[salsa::invoke_actual(crate::mir::mir_body_for_closure_query)] | ||||||
|     fn mir_body_for_closure(&self, def: ClosureId) -> Result<Arc<MirBody>, MirLowerError>; |     fn mir_body_for_closure(&self, def: InternedClosureId) -> Result<Arc<MirBody>, MirLowerError>; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(crate::mir::monomorphized_mir_body_query)] |     #[salsa::invoke(crate::mir::monomorphized_mir_body_query)] | ||||||
|     #[salsa::cycle(crate::mir::monomorphized_mir_body_recover)] |     #[salsa::cycle(crate::mir::monomorphized_mir_body_recover)] | ||||||
|  | @ -54,12 +54,12 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> + std::fmt::Debug { | ||||||
|     #[salsa::invoke(crate::mir::monomorphized_mir_body_for_closure_query)] |     #[salsa::invoke(crate::mir::monomorphized_mir_body_for_closure_query)] | ||||||
|     fn monomorphized_mir_body_for_closure( |     fn monomorphized_mir_body_for_closure( | ||||||
|         &self, |         &self, | ||||||
|         def: ClosureId, |         def: InternedClosureId, | ||||||
|         subst: Substitution, |         subst: Substitution, | ||||||
|         env: Arc<TraitEnvironment>, |         env: Arc<TraitEnvironment>, | ||||||
|     ) -> Result<Arc<MirBody>, MirLowerError>; |     ) -> Result<Arc<MirBody>, MirLowerError>; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(crate::mir::borrowck_query)] |     #[salsa::invoke_actual(crate::mir::borrowck_query)] | ||||||
|     #[salsa::lru(2024)] |     #[salsa::lru(2024)] | ||||||
|     fn borrowck(&self, def: DefWithBodyId) -> Result<Arc<[BorrowckResult]>, MirLowerError>; |     fn borrowck(&self, def: DefWithBodyId) -> Result<Arc<[BorrowckResult]>, MirLowerError>; | ||||||
| 
 | 
 | ||||||
|  | @ -110,9 +110,10 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> + std::fmt::Debug { | ||||||
|     fn dyn_compatibility_of_trait(&self, trait_: TraitId) -> Option<DynCompatibilityViolation>; |     fn dyn_compatibility_of_trait(&self, trait_: TraitId) -> Option<DynCompatibilityViolation>; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(crate::lower::ty_query)] |     #[salsa::invoke(crate::lower::ty_query)] | ||||||
|     #[salsa::cycle(crate::lower::ty_recover)] |     #[salsa::transparent] | ||||||
|     fn ty(&self, def: TyDefId) -> Binders<Ty>; |     fn ty(&self, def: TyDefId) -> Binders<Ty>; | ||||||
| 
 | 
 | ||||||
|  |     #[salsa::cycle(crate::lower::type_for_type_alias_with_diagnostics_query_recover)] | ||||||
|     #[salsa::invoke_actual(crate::lower::type_for_type_alias_with_diagnostics_query)] |     #[salsa::invoke_actual(crate::lower::type_for_type_alias_with_diagnostics_query)] | ||||||
|     fn type_for_type_alias_with_diagnostics(&self, def: TypeAliasId) -> (Binders<Ty>, Diagnostics); |     fn type_for_type_alias_with_diagnostics(&self, def: TypeAliasId) -> (Binders<Ty>, Diagnostics); | ||||||
| 
 | 
 | ||||||
|  | @ -244,11 +245,8 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> + std::fmt::Debug { | ||||||
|     #[salsa::interned] |     #[salsa::interned] | ||||||
|     fn intern_coroutine(&self, id: InternedCoroutine) -> InternedCoroutineId; |     fn intern_coroutine(&self, id: InternedCoroutine) -> InternedCoroutineId; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(chalk_db::associated_ty_data_query)] |     #[salsa::invoke_actual(chalk_db::associated_ty_data_query)] | ||||||
|     fn associated_ty_data( |     fn associated_ty_data(&self, id: TypeAliasId) -> sync::Arc<chalk_db::AssociatedTyDatum>; | ||||||
|         &self, |  | ||||||
|         id: chalk_db::AssocTypeId, |  | ||||||
|     ) -> sync::Arc<chalk_db::AssociatedTyDatum>; |  | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(chalk_db::trait_datum_query)] |     #[salsa::invoke(chalk_db::trait_datum_query)] | ||||||
|     fn trait_datum( |     fn trait_datum( | ||||||
|  | @ -264,14 +262,14 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> + std::fmt::Debug { | ||||||
|     fn impl_datum(&self, krate: Crate, impl_id: chalk_db::ImplId) |     fn impl_datum(&self, krate: Crate, impl_id: chalk_db::ImplId) | ||||||
|     -> sync::Arc<chalk_db::ImplDatum>; |     -> sync::Arc<chalk_db::ImplDatum>; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(chalk_db::fn_def_datum_query)] |     #[salsa::invoke_actual(chalk_db::fn_def_datum_query)] | ||||||
|     fn fn_def_datum(&self, fn_def_id: FnDefId) -> sync::Arc<chalk_db::FnDefDatum>; |     fn fn_def_datum(&self, fn_def_id: CallableDefId) -> sync::Arc<chalk_db::FnDefDatum>; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(chalk_db::fn_def_variance_query)] |     #[salsa::invoke_actual(chalk_db::fn_def_variance_query)] | ||||||
|     fn fn_def_variance(&self, fn_def_id: FnDefId) -> chalk_db::Variances; |     fn fn_def_variance(&self, fn_def_id: CallableDefId) -> chalk_db::Variances; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke(chalk_db::adt_variance_query)] |     #[salsa::invoke_actual(chalk_db::adt_variance_query)] | ||||||
|     fn adt_variance(&self, adt_id: chalk_db::AdtId) -> chalk_db::Variances; |     fn adt_variance(&self, adt_id: AdtId) -> chalk_db::Variances; | ||||||
| 
 | 
 | ||||||
|     #[salsa::invoke_actual(crate::variance::variances_of)] |     #[salsa::invoke_actual(crate::variance::variances_of)] | ||||||
|     #[salsa::cycle(crate::variance::variances_of_cycle)] |     #[salsa::cycle(crate::variance::variances_of_cycle)] | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ use crate::{ | ||||||
|     from_assoc_type_id, from_chalk_trait_id, |     from_assoc_type_id, from_chalk_trait_id, | ||||||
|     generics::{generics, trait_self_param_idx}, |     generics::{generics, trait_self_param_idx}, | ||||||
|     lower::callable_item_sig, |     lower::callable_item_sig, | ||||||
|     to_assoc_type_id, to_chalk_trait_id, |     to_chalk_trait_id, | ||||||
|     utils::elaborate_clause_supertraits, |     utils::elaborate_clause_supertraits, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -171,8 +171,7 @@ fn bounds_reference_self(db: &dyn HirDatabase, trait_: TraitId) -> bool { | ||||||
|         .iter() |         .iter() | ||||||
|         .filter_map(|(_, it)| match *it { |         .filter_map(|(_, it)| match *it { | ||||||
|             AssocItemId::TypeAliasId(id) => { |             AssocItemId::TypeAliasId(id) => { | ||||||
|                 let assoc_ty_id = to_assoc_type_id(id); |                 let assoc_ty_data = db.associated_ty_data(id); | ||||||
|                 let assoc_ty_data = db.associated_ty_data(assoc_ty_id); |  | ||||||
|                 Some(assoc_ty_data) |                 Some(assoc_ty_data) | ||||||
|             } |             } | ||||||
|             _ => None, |             _ => None, | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ use crate::{ | ||||||
|     DynTyExt, FnAbi, FnPointer, FnSig, Interner, OpaqueTy, ProjectionTyExt, Substitution, Ty, |     DynTyExt, FnAbi, FnPointer, FnSig, Interner, OpaqueTy, ProjectionTyExt, Substitution, Ty, | ||||||
|     TyExt, WhereClause, |     TyExt, WhereClause, | ||||||
|     db::{HirDatabase, InternedClosure}, |     db::{HirDatabase, InternedClosure}, | ||||||
|     error_lifetime, from_chalk_trait_id, from_placeholder_idx, |     error_lifetime, from_assoc_type_id, from_chalk_trait_id, from_placeholder_idx, | ||||||
|     generics::Generics, |     generics::Generics, | ||||||
|     infer::coerce::CoerceNever, |     infer::coerce::CoerceNever, | ||||||
|     make_binders, |     make_binders, | ||||||
|  | @ -153,7 +153,8 @@ impl InferenceContext<'_> { | ||||||
|             if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) = |             if let WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection), ty }) = | ||||||
|                 bound.skip_binders() |                 bound.skip_binders() | ||||||
|             { |             { | ||||||
|                 let assoc_data = self.db.associated_ty_data(projection.associated_ty_id); |                 let assoc_data = | ||||||
|  |                     self.db.associated_ty_data(from_assoc_type_id(projection.associated_ty_id)); | ||||||
|                 if !fn_traits.contains(&assoc_data.trait_id) { |                 if !fn_traits.contains(&assoc_data.trait_id) { | ||||||
|                     return None; |                     return None; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  | @ -1560,6 +1560,20 @@ fn type_for_enum_variant_constructor( | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #[salsa::tracked(recovery_fn = type_for_adt_recovery)] | ||||||
|  | fn type_for_adt_tracked(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> { | ||||||
|  |     type_for_adt(db, adt) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | pub(crate) fn type_for_adt_recovery( | ||||||
|  |     db: &dyn HirDatabase, | ||||||
|  |     _cycle: &salsa::Cycle, | ||||||
|  |     adt: AdtId, | ||||||
|  | ) -> Binders<Ty> { | ||||||
|  |     let generics = generics(db.upcast(), adt.into()); | ||||||
|  |     make_binders(db, &generics, TyKind::Error.intern(Interner)) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| fn type_for_adt(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> { | fn type_for_adt(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> { | ||||||
|     let generics = generics(db.upcast(), adt.into()); |     let generics = generics(db.upcast(), adt.into()); | ||||||
|     let subst = generics.bound_vars_subst(db, DebruijnIndex::INNERMOST); |     let subst = generics.bound_vars_subst(db, DebruijnIndex::INNERMOST); | ||||||
|  | @ -1589,6 +1603,15 @@ pub(crate) fn type_for_type_alias_with_diagnostics_query( | ||||||
|     (make_binders(db, &generics, inner), create_diagnostics(ctx.diagnostics)) |     (make_binders(db, &generics, inner), create_diagnostics(ctx.diagnostics)) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | pub(crate) fn type_for_type_alias_with_diagnostics_query_recover( | ||||||
|  |     db: &dyn HirDatabase, | ||||||
|  |     _cycle: &salsa::Cycle, | ||||||
|  |     adt: TypeAliasId, | ||||||
|  | ) -> (Binders<Ty>, Diagnostics) { | ||||||
|  |     let generics = generics(db.upcast(), adt.into()); | ||||||
|  |     (make_binders(db, &generics, TyKind::Error.intern(Interner)), None) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||||||
| pub enum TyDefId { | pub enum TyDefId { | ||||||
|     BuiltinType(BuiltinType), |     BuiltinType(BuiltinType), | ||||||
|  | @ -1628,25 +1651,11 @@ impl ValueTyDefId { | ||||||
| pub(crate) fn ty_query(db: &dyn HirDatabase, def: TyDefId) -> Binders<Ty> { | pub(crate) fn ty_query(db: &dyn HirDatabase, def: TyDefId) -> Binders<Ty> { | ||||||
|     match def { |     match def { | ||||||
|         TyDefId::BuiltinType(it) => Binders::empty(Interner, TyBuilder::builtin(it)), |         TyDefId::BuiltinType(it) => Binders::empty(Interner, TyBuilder::builtin(it)), | ||||||
|         TyDefId::AdtId(it) => type_for_adt(db, it), |         TyDefId::AdtId(it) => type_for_adt_tracked(db, it), | ||||||
|         TyDefId::TypeAliasId(it) => db.type_for_type_alias_with_diagnostics(it).0, |         TyDefId::TypeAliasId(it) => db.type_for_type_alias_with_diagnostics(it).0, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub(crate) fn ty_recover( |  | ||||||
|     db: &dyn HirDatabase, |  | ||||||
|     _cycle: &salsa::Cycle, |  | ||||||
|     _: HirDatabaseData, |  | ||||||
|     def: TyDefId, |  | ||||||
| ) -> Binders<Ty> { |  | ||||||
|     let generics = match def { |  | ||||||
|         TyDefId::BuiltinType(_) => return Binders::empty(Interner, TyKind::Error.intern(Interner)), |  | ||||||
|         TyDefId::AdtId(it) => generics(db.upcast(), it.into()), |  | ||||||
|         TyDefId::TypeAliasId(it) => generics(db.upcast(), it.into()), |  | ||||||
|     }; |  | ||||||
|     make_binders(db, &generics, TyKind::Error.intern(Interner)) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| pub(crate) fn value_ty_query(db: &dyn HirDatabase, def: ValueTyDefId) -> Option<Binders<Ty>> { | pub(crate) fn value_ty_query(db: &dyn HirDatabase, def: ValueTyDefId) -> Option<Binders<Ty>> { | ||||||
|     match def { |     match def { | ||||||
|         ValueTyDefId::FunctionId(it) => Some(type_for_fn(db, it)), |         ValueTyDefId::FunctionId(it) => Some(type_for_fn(db, it)), | ||||||
|  |  | ||||||
|  | @ -71,7 +71,7 @@ fn all_mir_bodies( | ||||||
|         c: ClosureId, |         c: ClosureId, | ||||||
|         cb: &mut impl FnMut(Arc<MirBody>), |         cb: &mut impl FnMut(Arc<MirBody>), | ||||||
|     ) -> Result<(), MirLowerError> { |     ) -> Result<(), MirLowerError> { | ||||||
|         match db.mir_body_for_closure(c) { |         match db.mir_body_for_closure(c.into()) { | ||||||
|             Ok(body) => { |             Ok(body) => { | ||||||
|                 cb(body.clone()); |                 cb(body.clone()); | ||||||
|                 body.closures.iter().try_for_each(|&it| for_closure(db, it, cb)) |                 body.closures.iter().try_for_each(|&it| for_closure(db, it, cb)) | ||||||
|  |  | ||||||
|  | @ -2452,7 +2452,7 @@ impl Evaluator<'_> { | ||||||
|         let mir_body = self |         let mir_body = self | ||||||
|             .db |             .db | ||||||
|             .monomorphized_mir_body_for_closure( |             .monomorphized_mir_body_for_closure( | ||||||
|                 closure, |                 closure.into(), | ||||||
|                 generic_args.clone(), |                 generic_args.clone(), | ||||||
|                 self.trait_env.clone(), |                 self.trait_env.clone(), | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ use triomphe::Arc; | ||||||
| use crate::{ | use crate::{ | ||||||
|     Adjust, Adjustment, AutoBorrow, CallableDefId, TyBuilder, TyExt, |     Adjust, Adjustment, AutoBorrow, CallableDefId, TyBuilder, TyExt, | ||||||
|     consteval::ConstEvalError, |     consteval::ConstEvalError, | ||||||
|     db::{HirDatabase, InternedClosure}, |     db::{HirDatabase, InternedClosure, InternedClosureId}, | ||||||
|     display::{DisplayTarget, HirDisplay, hir_display_with_types_map}, |     display::{DisplayTarget, HirDisplay, hir_display_with_types_map}, | ||||||
|     error_lifetime, |     error_lifetime, | ||||||
|     generics::generics, |     generics::generics, | ||||||
|  | @ -38,12 +38,12 @@ use crate::{ | ||||||
|     layout::LayoutError, |     layout::LayoutError, | ||||||
|     mapping::ToChalk, |     mapping::ToChalk, | ||||||
|     mir::{ |     mir::{ | ||||||
|         AggregateKind, Arena, BasicBlock, BasicBlockId, BinOp, BorrowKind, CastKind, ClosureId, |         AggregateKind, Arena, BasicBlock, BasicBlockId, BinOp, BorrowKind, CastKind, ConstScalar, | ||||||
|         ConstScalar, Either, Expr, FieldId, Idx, InferenceResult, Interner, Local, LocalId, |         Either, Expr, FieldId, Idx, InferenceResult, Interner, Local, LocalId, MemoryMap, MirBody, | ||||||
|         MemoryMap, MirBody, MirSpan, Mutability, Operand, Place, PlaceElem, PointerCast, |         MirSpan, Mutability, Operand, Place, PlaceElem, PointerCast, ProjectionElem, | ||||||
|         ProjectionElem, ProjectionStore, RawIdx, Rvalue, Statement, StatementKind, Substitution, |         ProjectionStore, RawIdx, Rvalue, Statement, StatementKind, Substitution, SwitchTargets, | ||||||
|         SwitchTargets, Terminator, TerminatorKind, TupleFieldId, Ty, UnOp, VariantId, |         Terminator, TerminatorKind, TupleFieldId, Ty, UnOp, VariantId, intern_const_scalar, | ||||||
|         intern_const_scalar, return_slot, |         return_slot, | ||||||
|     }, |     }, | ||||||
|     static_lifetime, |     static_lifetime, | ||||||
|     traits::FnTrait, |     traits::FnTrait, | ||||||
|  | @ -2017,9 +2017,9 @@ fn cast_kind(table: &mut InferenceTable<'_>, source_ty: &Ty, target_ty: &Ty) -> | ||||||
| 
 | 
 | ||||||
| pub fn mir_body_for_closure_query( | pub fn mir_body_for_closure_query( | ||||||
|     db: &dyn HirDatabase, |     db: &dyn HirDatabase, | ||||||
|     closure: ClosureId, |     closure: InternedClosureId, | ||||||
| ) -> Result<Arc<MirBody>> { | ) -> Result<Arc<MirBody>> { | ||||||
|     let InternedClosure(owner, expr) = db.lookup_intern_closure(closure.into()); |     let InternedClosure(owner, expr) = db.lookup_intern_closure(closure); | ||||||
|     let body = db.body(owner); |     let body = db.body(owner); | ||||||
|     let infer = db.infer(owner); |     let infer = db.infer(owner); | ||||||
|     let Expr::Closure { args, body: root, .. } = &body[expr] else { |     let Expr::Closure { args, body: root, .. } = &body[expr] else { | ||||||
|  | @ -2028,7 +2028,7 @@ pub fn mir_body_for_closure_query( | ||||||
|     let TyKind::Closure(_, substs) = &infer[expr].kind(Interner) else { |     let TyKind::Closure(_, substs) = &infer[expr].kind(Interner) else { | ||||||
|         implementation_error!("closure expression is not closure"); |         implementation_error!("closure expression is not closure"); | ||||||
|     }; |     }; | ||||||
|     let (captures, kind) = infer.closure_info(&closure); |     let (captures, kind) = infer.closure_info(&closure.into()); | ||||||
|     let mut ctx = MirLowerCtx::new(db, owner, &body, &infer); |     let mut ctx = MirLowerCtx::new(db, owner, &body, &infer); | ||||||
|     // 0 is return local
 |     // 0 is return local
 | ||||||
|     ctx.result.locals.alloc(Local { ty: infer[*root].clone() }); |     ctx.result.locals.alloc(Local { ty: infer[*root].clone() }); | ||||||
|  |  | ||||||
|  | @ -17,9 +17,9 @@ use hir_def::DefWithBodyId; | ||||||
| use triomphe::Arc; | use triomphe::Arc; | ||||||
| 
 | 
 | ||||||
| use crate::{ | use crate::{ | ||||||
|     ClosureId, Const, Interner, ProjectionTy, Substitution, TraitEnvironment, Ty, TyKind, |     Const, Interner, ProjectionTy, Substitution, TraitEnvironment, Ty, TyKind, | ||||||
|     consteval::{intern_const_scalar, unknown_const}, |     consteval::{intern_const_scalar, unknown_const}, | ||||||
|     db::{HirDatabase, HirDatabaseData, InternedClosure}, |     db::{HirDatabase, HirDatabaseData, InternedClosure, InternedClosureId}, | ||||||
|     from_placeholder_idx, |     from_placeholder_idx, | ||||||
|     generics::{Generics, generics}, |     generics::{Generics, generics}, | ||||||
|     infer::normalize, |     infer::normalize, | ||||||
|  | @ -326,11 +326,11 @@ pub(crate) fn monomorphized_mir_body_recover( | ||||||
| 
 | 
 | ||||||
| pub fn monomorphized_mir_body_for_closure_query( | pub fn monomorphized_mir_body_for_closure_query( | ||||||
|     db: &dyn HirDatabase, |     db: &dyn HirDatabase, | ||||||
|     closure: ClosureId, |     closure: InternedClosureId, | ||||||
|     subst: Substitution, |     subst: Substitution, | ||||||
|     trait_env: Arc<crate::TraitEnvironment>, |     trait_env: Arc<crate::TraitEnvironment>, | ||||||
| ) -> Result<Arc<MirBody>, MirLowerError> { | ) -> Result<Arc<MirBody>, MirLowerError> { | ||||||
|     let InternedClosure(owner, _) = db.lookup_intern_closure(closure.into()); |     let InternedClosure(owner, _) = db.lookup_intern_closure(closure); | ||||||
|     let generics = owner.as_generic_def_id(db.upcast()).map(|g_def| generics(db.upcast(), g_def)); |     let generics = owner.as_generic_def_id(db.upcast()).map(|g_def| generics(db.upcast(), g_def)); | ||||||
|     let filler = &mut Filler { db, subst: &subst, trait_env, generics, owner }; |     let filler = &mut Filler { db, subst: &subst, trait_env, generics, owner }; | ||||||
|     let body = db.mir_body_for_closure(closure)?; |     let body = db.mir_body_for_closure(closure)?; | ||||||
|  |  | ||||||
|  | @ -154,7 +154,7 @@ impl<'a> MirPrettyCtx<'a> { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn for_closure(&mut self, closure: ClosureId) { |     fn for_closure(&mut self, closure: ClosureId) { | ||||||
|         let body = match self.db.mir_body_for_closure(closure) { |         let body = match self.db.mir_body_for_closure(closure.into()) { | ||||||
|             Ok(it) => it, |             Ok(it) => it, | ||||||
|             Err(e) => { |             Err(e) => { | ||||||
|                 wln!(self, "// error in {closure:?}: {e:?}"); |                 wln!(self, "// error in {closure:?}: {e:?}"); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Wirth
						Lukas Wirth