Pass TraitEnvironment into layout_ty and const_eval

This commit is contained in:
hkalbasi 2023-07-20 13:08:38 +03:30
parent cc2f0ec32c
commit eb143383c3
14 changed files with 149 additions and 87 deletions

View file

@ -114,7 +114,7 @@ fn eval_goal(db: &TestDB, file_id: FileId) -> Result<Const, ConstEvalError> {
_ => None,
})
.expect("No const named GOAL found in the test");
db.const_eval(const_id.into(), Substitution::empty(Interner))
db.const_eval(const_id.into(), Substitution::empty(Interner), None)
}
#[test]
@ -2492,6 +2492,28 @@ fn const_trait_assoc() {
"#,
5,
);
check_number(
r#"
//- minicore: size_of
//- /a/lib.rs crate:a
use core::mem::size_of;
pub struct S<T>(T);
impl<T> S<T> {
pub const X: usize = core::mem::size_of::<T>();
}
//- /main.rs crate:main deps:a
use a::{S};
trait Tr {
type Ty;
}
impl Tr for i32 {
type Ty = u64;
}
struct K<T: Tr>(<T as Tr>::Ty);
const GOAL: usize = S::<K<i32>>::X;
"#,
8,
);
check_number(
r#"
struct S<T>(*mut T);