Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3458211

Browse files
committedMay 13, 2024
Auto merge of #125076 - compiler-errors:alias-term, r=lcnr
Split out `ty::AliasTerm` from `ty::AliasTy` Splitting out `AliasTerm` (for use in project and normalizes goals) and `AliasTy` (for use in `ty::Alias`) r? lcnr
2 parents ab14f94 + fa84018 commit 3458211

File tree

73 files changed

+695
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+695
-458
lines changed
 

‎compiler/rustc_hir_typeck/src/method/suggest.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ use std::borrow::Cow;
4747
use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope};
4848
use super::{CandidateSource, MethodError, NoMatchData};
4949
use rustc_hir::intravisit::Visitor;
50-
use std::iter;
5150

5251
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5352
fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool {
@@ -173,7 +172,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
173172
}
174173
}
175174
}
176-
ty::Slice(..) | ty::Adt(..) | ty::Alias(ty::AliasKind::Opaque, _) => {
175+
ty::Slice(..) | ty::Adt(..) | ty::Alias(ty::Opaque, _) => {
177176
for unsatisfied in unsatisfied_predicates.iter() {
178177
if is_iterator_predicate(unsatisfied.0, self.tcx) {
179178
return true;
@@ -788,26 +787,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
788787
ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred)) => {
789788
let pred = bound_predicate.rebind(pred);
790789
// `<Foo as Iterator>::Item = String`.
791-
let projection_ty = pred.skip_binder().projection_ty;
792-
793-
let args_with_infer_self = tcx.mk_args_from_iter(
794-
iter::once(Ty::new_var(tcx, ty::TyVid::ZERO).into())
795-
.chain(projection_ty.args.iter().skip(1)),
796-
);
797-
798-
let quiet_projection_ty =
799-
ty::AliasTy::new(tcx, projection_ty.def_id, args_with_infer_self);
790+
let projection_term = pred.skip_binder().projection_term;
791+
let quiet_projection_term =
792+
projection_term.with_self_ty(tcx, Ty::new_var(tcx, ty::TyVid::ZERO));
800793

801794
let term = pred.skip_binder().term;
802795

803-
let obligation = format!("{projection_ty} = {term}");
796+
let obligation = format!("{projection_term} = {term}");
804797
let quiet = with_forced_trimmed_paths!(format!(
805798
"{} = {}",
806-
quiet_projection_ty, term
799+
quiet_projection_term, term
807800
));
808801

809-
bound_span_label(projection_ty.self_ty(), &obligation, &quiet);
810-
Some((obligation, projection_ty.self_ty()))
802+
bound_span_label(projection_term.self_ty(), &obligation, &quiet);
803+
Some((obligation, projection_term.self_ty()))
811804
}
812805
ty::PredicateKind::Clause(ty::ClauseKind::Trait(poly_trait_ref)) => {
813806
let p = poly_trait_ref.trait_ref;

‎compiler/rustc_infer/src/infer/at.rs

+14
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,20 @@ impl<'tcx> ToTrace<'tcx> for ty::TraitRef<'tcx> {
431431
}
432432

433433
impl<'tcx> ToTrace<'tcx> for ty::AliasTy<'tcx> {
434+
fn to_trace(
435+
cause: &ObligationCause<'tcx>,
436+
a_is_expected: bool,
437+
a: Self,
438+
b: Self,
439+
) -> TypeTrace<'tcx> {
440+
TypeTrace {
441+
cause: cause.clone(),
442+
values: Aliases(ExpectedFound::new(a_is_expected, a.into(), b.into())),
443+
}
444+
}
445+
}
446+
447+
impl<'tcx> ToTrace<'tcx> for ty::AliasTerm<'tcx> {
434448
fn to_trace(
435449
cause: &ObligationCause<'tcx>,
436450
a_is_expected: bool,
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.