Rollup merge of #118269 - compiler-errors:poly, r=wesleywiser

Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`

I did this recently with `FnSigs` and `PolyFnSigs` but didn't think to do it with `TraitRefs` and `PolyTraitRefs`.
This commit is contained in:
Matthias Krüger 2023-11-29 04:23:22 +01:00 committed by GitHub
commit 68d31b1906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 22 deletions

View File

@ -448,7 +448,11 @@ fn to_trace(
) -> TypeTrace<'tcx> { ) -> TypeTrace<'tcx> {
TypeTrace { TypeTrace {
cause: cause.clone(), cause: cause.clone(),
values: TraitRefs(ExpectedFound::new(a_is_expected, a, b)), values: PolyTraitRefs(ExpectedFound::new(
a_is_expected,
ty::Binder::dummy(a),
ty::Binder::dummy(b),
)),
} }
} }
} }

View File

@ -1667,9 +1667,7 @@ enum Mismatch<'a> {
.report(diag); .report(diag);
(false, Mismatch::Fixed("signature")) (false, Mismatch::Fixed("signature"))
} }
ValuePairs::TraitRefs(_) | ValuePairs::PolyTraitRefs(_) => { ValuePairs::PolyTraitRefs(_) => (false, Mismatch::Fixed("trait")),
(false, Mismatch::Fixed("trait"))
}
ValuePairs::Aliases(infer::ExpectedFound { expected, .. }) => { ValuePairs::Aliases(infer::ExpectedFound { expected, .. }) => {
(false, Mismatch::Fixed(self.tcx.def_descr(expected.def_id))) (false, Mismatch::Fixed(self.tcx.def_descr(expected.def_id)))
} }
@ -2219,18 +2217,6 @@ fn values_str(
infer::Aliases(exp_found) => self.expected_found_str(exp_found), infer::Aliases(exp_found) => self.expected_found_str(exp_found),
infer::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found), infer::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found),
infer::ExistentialProjection(exp_found) => self.expected_found_str(exp_found), infer::ExistentialProjection(exp_found) => self.expected_found_str(exp_found),
infer::TraitRefs(exp_found) => {
let pretty_exp_found = ty::error::ExpectedFound {
expected: exp_found.expected.print_only_trait_path(),
found: exp_found.found.print_only_trait_path(),
};
match self.expected_found_str(pretty_exp_found) {
Some((expected, found, _, _)) if expected == found => {
self.expected_found_str(exp_found)
}
ret => ret,
}
}
infer::PolyTraitRefs(exp_found) => { infer::PolyTraitRefs(exp_found) => {
let pretty_exp_found = ty::error::ExpectedFound { let pretty_exp_found = ty::error::ExpectedFound {
expected: exp_found.expected.print_only_trait_path(), expected: exp_found.expected.print_only_trait_path(),

View File

@ -197,11 +197,6 @@ fn try_report_trait_placeholder_mismatch(
value_pairs: &ValuePairs<'tcx>, value_pairs: &ValuePairs<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
let (expected_args, found_args, trait_def_id) = match value_pairs { let (expected_args, found_args, trait_def_id) = match value_pairs {
ValuePairs::TraitRefs(ExpectedFound { expected, found })
if expected.def_id == found.def_id =>
{
(expected.args, found.args, expected.def_id)
}
ValuePairs::PolyTraitRefs(ExpectedFound { expected, found }) ValuePairs::PolyTraitRefs(ExpectedFound { expected, found })
if expected.def_id() == found.def_id() => if expected.def_id() == found.def_id() =>
{ {

View File

@ -384,7 +384,6 @@ pub enum ValuePairs<'tcx> {
Regions(ExpectedFound<ty::Region<'tcx>>), Regions(ExpectedFound<ty::Region<'tcx>>),
Terms(ExpectedFound<ty::Term<'tcx>>), Terms(ExpectedFound<ty::Term<'tcx>>),
Aliases(ExpectedFound<ty::AliasTy<'tcx>>), Aliases(ExpectedFound<ty::AliasTy<'tcx>>),
TraitRefs(ExpectedFound<ty::TraitRef<'tcx>>),
PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>), PolyTraitRefs(ExpectedFound<ty::PolyTraitRef<'tcx>>),
PolySigs(ExpectedFound<ty::PolyFnSig<'tcx>>), PolySigs(ExpectedFound<ty::PolyFnSig<'tcx>>),
ExistentialTraitRef(ExpectedFound<ty::PolyExistentialTraitRef<'tcx>>), ExistentialTraitRef(ExpectedFound<ty::PolyExistentialTraitRef<'tcx>>),