mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 19:33:16 +00:00
Auto merge of #12336 - bitgaoshu:mismatch, r=flodiebold
fix: #12267 type-mismatch when using equals w/ a trait bound
This commit is contained in:
commit
c2099fe941
@ -410,8 +410,10 @@ pub(crate) fn associated_ty_data_query(
|
|||||||
let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast());
|
let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast());
|
||||||
let ctx = crate::TyLoweringContext::new(db, &resolver)
|
let ctx = crate::TyLoweringContext::new(db, &resolver)
|
||||||
.with_type_param_mode(crate::lower::ParamLoweringMode::Variable);
|
.with_type_param_mode(crate::lower::ParamLoweringMode::Variable);
|
||||||
let self_ty =
|
let pro_ty = TyBuilder::assoc_type_projection(db, type_alias)
|
||||||
TyKind::BoundVar(BoundVar::new(crate::DebruijnIndex::INNERMOST, 0)).intern(Interner);
|
.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
|
let mut bounds: Vec<_> = type_alias_data
|
||||||
.bounds
|
.bounds
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use cov_mark::check;
|
use cov_mark::check;
|
||||||
use expect_test::expect;
|
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]
|
#[test]
|
||||||
fn infer_await() {
|
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]
|
#[test]
|
||||||
fn bin_op_adt_with_rhs_primitive() {
|
fn bin_op_adt_with_rhs_primitive() {
|
||||||
check_infer_with_mismatches(
|
check_infer_with_mismatches(
|
||||||
|
Loading…
Reference in New Issue
Block a user