This commit is contained in:
bitgaoshu 2022-05-21 13:49:48 +08:00
parent d5ab27a0bf
commit 7c5e97221f
2 changed files with 41 additions and 3 deletions

View File

@ -410,8 +410,10 @@ pub(crate) fn associated_ty_data_query(
let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast());
let ctx = crate::TyLoweringContext::new(db, &resolver)
.with_type_param_mode(crate::lower::ParamLoweringMode::Variable);
let self_ty =
TyKind::BoundVar(BoundVar::new(crate::DebruijnIndex::INNERMOST, 0)).intern(Interner);
let pro_ty = TyBuilder::assoc_type_projection(db, type_alias)
.fill_with_bound_vars(crate::DebruijnIndex::INNERMOST, 0)
.build();
let self_ty = TyKind::Alias(AliasTy::Projection(pro_ty)).intern(Interner);
let mut bounds: Vec<_> = type_alias_data
.bounds
.iter()

View File

@ -1,7 +1,7 @@
use cov_mark::check;
use expect_test::expect;
use super::{check, check_infer, check_infer_with_mismatches, check_types};
use super::{check, check_infer, check_infer_with_mismatches, check_no_mismatches, check_types};
#[test]
fn infer_await() {
@ -3316,6 +3316,42 @@ pub trait Deserialize {
);
}
#[test]
fn bin_op_with_rhs_is_self_for_assoc_bound() {
check_no_mismatches(
r#"//- minicore: eq
fn repro<T>(t: T) -> bool
where
T: Request,
T::Output: Convertable,
{
let a = execute(&t).convert();
let b = execute(&t).convert();
a.eq(&b);
let a = execute(&t).convert2();
let b = execute(&t).convert2();
a.eq(&b)
}
fn execute<T>(t: &T) -> T::Output
where
T: Request,
{
<T as Request>::output()
}
trait Convertable {
type TraitSelf: PartialEq<Self::TraitSelf>;
type AssocAsDefaultSelf: PartialEq;
fn convert(self) -> Self::AssocAsDefaultSelf;
fn convert2(self) -> Self::TraitSelf;
}
trait Request {
type Output;
fn output() -> Self::Output;
}
"#,
);
}
#[test]
fn bin_op_adt_with_rhs_primitive() {
check_infer_with_mismatches(