Skip to content

Commit 10a7405

Browse files
authored
Rollup merge of rust-lang#134574 - lcnr:opaque-ty-hack-yeet, r=compiler-errors
next-solver: disable unnecessary hack the new solver never constrains inference variables to normalizeable aliases, so this is no longer necessary.
2 parents 0b1834d + 6bc1fe1 commit 10a7405

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
134134
// the hidden type becomes the opaque type itself. In this case, this was an opaque
135135
// usage of the opaque type and we can ignore it. This check is mirrored in typeck's
136136
// writeback.
137-
// FIXME(-Znext-solver): This should be unnecessary with the new solver.
138-
if let ty::Alias(ty::Opaque, alias_ty) = ty.kind()
139-
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
140-
&& alias_ty.args == opaque_type_key.args
141-
{
142-
continue;
137+
if !infcx.next_trait_solver() {
138+
if let ty::Alias(ty::Opaque, alias_ty) = ty.kind()
139+
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
140+
&& alias_ty.args == opaque_type_key.args
141+
{
142+
continue;
143+
}
143144
}
144145
// Sometimes two opaque types are the same only after we remap the generic parameters
145146
// back to the opaque type definition. E.g. we may have `OpaqueType<X, Y>` mapped to

compiler/rustc_hir_typeck/src/writeback.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,13 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
554554
let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
555555
let opaque_type_key = self.resolve(opaque_type_key, &decl.hidden_type.span);
556556

557-
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
558-
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
559-
&& alias_ty.args == opaque_type_key.args
560-
{
561-
continue;
557+
if !self.fcx.next_trait_solver() {
558+
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
559+
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
560+
&& alias_ty.args == opaque_type_key.args
561+
{
562+
continue;
563+
}
562564
}
563565

564566
// Here we only detect impl trait definition conflicts when they

0 commit comments

Comments
 (0)