Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/layout/tests.rs')
| -rw-r--r-- | crates/hir-ty/src/layout/tests.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/crates/hir-ty/src/layout/tests.rs b/crates/hir-ty/src/layout/tests.rs index 878813a696..be6a76478a 100644 --- a/crates/hir-ty/src/layout/tests.rs +++ b/crates/hir-ty/src/layout/tests.rs @@ -1,6 +1,6 @@ use base_db::target::TargetData; use either::Either; -use hir_def::db::DefDatabase; +use hir_def::{HasModule, db::DefDatabase}; use project_model::{Sysroot, toolchain_info::QueryConfig}; use rustc_hash::FxHashMap; use rustc_type_ir::inherent::GenericArgs as _; @@ -9,7 +9,7 @@ use test_fixture::WithFixture; use triomphe::Arc; use crate::{ - InferenceResult, + InferenceResult, ParamEnvAndCrate, db::HirDatabase, layout::{Layout, LayoutError}, next_solver::{DbInterner, GenericArgs}, @@ -45,7 +45,7 @@ fn eval_goal( .find_map(|file_id| { let module_id = db.module_for_file(file_id.file_id(&db)); let def_map = module_id.def_map(&db); - let scope = &def_map[module_id.local_id].scope; + let scope = &def_map[module_id].scope; let adt_or_type_alias_id = scope.declarations().find_map(|x| match x { hir_def::ModuleDefId::AdtId(x) => { let name = match x { @@ -90,13 +90,15 @@ fn eval_goal( ), Either::Right(ty_id) => db.ty(ty_id.into()).instantiate_identity(), }; - db.layout_of_ty( - goal_ty, - db.trait_environment(match adt_or_type_alias_id { - Either::Left(adt) => hir_def::GenericDefId::AdtId(adt), - Either::Right(ty) => hir_def::GenericDefId::TypeAliasId(ty), - }), - ) + let param_env = db.trait_environment(match adt_or_type_alias_id { + Either::Left(adt) => hir_def::GenericDefId::AdtId(adt), + Either::Right(ty) => hir_def::GenericDefId::TypeAliasId(ty), + }); + let krate = match adt_or_type_alias_id { + Either::Left(it) => it.krate(&db), + Either::Right(it) => it.krate(&db), + }; + db.layout_of_ty(goal_ty, ParamEnvAndCrate { param_env, krate }) }) } @@ -116,7 +118,7 @@ fn eval_expr( crate::attach_db(&db, || { let module_id = db.module_for_file(file_id.file_id(&db)); let def_map = module_id.def_map(&db); - let scope = &def_map[module_id.local_id].scope; + let scope = &def_map[module_id].scope; let function_id = scope .declarations() .find_map(|x| match x { @@ -139,7 +141,9 @@ fn eval_expr( .0; let infer = InferenceResult::for_body(&db, function_id.into()); let goal_ty = infer.type_of_binding[b]; - db.layout_of_ty(goal_ty, db.trait_environment(function_id.into())) + let param_env = db.trait_environment(function_id.into()); + let krate = function_id.krate(&db); + db.layout_of_ty(goal_ty, ParamEnvAndCrate { param_env, krate }) }) } |