Skip to content

Commit 950bbe7

Browse files
committed
self review
1 parent 3fb166f commit 950bbe7

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,18 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
490490
}
491491
trace!(?curr_projected_ty);
492492

493-
// Need to renormalize `a` as typecheck may have failed to normalize
494-
// higher-ranked aliases if normalization was ambiguous due to inference.
495-
let a = self.normalize(ty::Unnormalized::new_wip(a), locations);
496-
let ty = self.normalize(ty::Unnormalized::new_wip(curr_projected_ty.ty), locations);
493+
// Need to renormalize `a` in the old solver as typecheck may have failed
494+
// to normalize higher-ranked aliases if normalization was ambiguous due
495+
// to inference.
496+
//
497+
// We properly normalize higher-ranked aliases during writeback with the
498+
// new solver, so this is no longer necessary.
499+
let mut a = a;
500+
let mut ty = curr_projected_ty.ty;
501+
if !self.infcx.next_trait_solver() {
502+
a = self.normalize(ty::Unnormalized::new_wip(a), locations);
503+
ty = self.normalize(ty::Unnormalized::new_wip(ty), locations);
504+
}
497505
self.relate_types(ty, v.xform(ty::Contravariant), a, locations, category)?;
498506

499507
Ok(())

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,12 @@ fn reconstruct_place_meta<'tcx>(
199199

200200
let mut last_valtree = valtree;
201201
// Traverse the type, and update `last_valtree` as we go.
202+
//
203+
// FIXME(#155345): Missing normalization call
202204
let tail = tcx.struct_tail_raw(
203205
layout.ty,
204206
&ObligationCause::dummy(),
205-
|ty| ty.skip_normalization(),
207+
|ty| ty.skip_norm_wip(),
206208
|| {
207209
let branches = last_valtree.to_branch();
208210
last_valtree = branches.last().unwrap().to_value().valtree;

compiler/rustc_hir_analysis/src/collect/dump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub(crate) fn vtables<'tcx>(tcx: TyCtxt<'tcx>) {
155155
}
156156
hir::ItemKind::TyAlias(..) => {
157157
let ty = tcx.type_of(def_id).instantiate_identity();
158-
if ty.skip_normalization().has_non_region_param() {
158+
if ty.has_non_region_param() {
159159
tcx.dcx().span_err(
160160
attr_span,
161161
"`rustc_dump_vtable` must be applied to non-generic type",

compiler/rustc_hir_typeck/src/expectation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'a, 'tcx> Expectation<'tcx> {
8080
};
8181
let cause = ObligationCause::misc(span, fcx.body_id);
8282

83-
// FIXME: This is not right, even in the old solver...
83+
// FIXME(#155345): Missing normalization call
8484
match fcx.tcx.struct_tail_raw(ty, &cause, |ty| ty.skip_normalization(), || {}).kind() {
8585
ty::Slice(_) | ty::Str | ty::Dynamic(..) => ExpectRvalueLikeUnsized(ty),
8686
_ => ExpectHasType(ty),

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ impl<'tcx> Ty<'tcx> {
18181818
if pointee_ty.has_trivial_sizedness(tcx, SizedTraitKind::Sized) {
18191819
tcx.types.unit
18201820
} else {
1821-
match pointee_ty.ptr_metadata_ty_or_tail(tcx, |x| x.skip_normalization()) {
1821+
match pointee_ty.ptr_metadata_ty_or_tail(tcx, |x| x.skip_norm_wip()) {
18221822
Ok(metadata_ty) => metadata_ty,
18231823
Err(tail_ty) => {
18241824
let metadata_def_id = tcx.require_lang_item(LangItem::Metadata, DUMMY_SP);

0 commit comments

Comments
 (0)