Skip to content

Commit 2eb702b

Browse files
committed
Auto merge of #112365 - compiler-errors:mir-inline-check-better, r=<try>
[experiment] Use new solver in MIR validator subtyping checks Just to see what breaks in crater... r? `@ghost`
2 parents 3f28fe1 + 1c30b50 commit 2eb702b

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,14 @@ pub(super) fn mir_assign_valid_types<'tcx>(
387387
// all normal lifetimes are erased, higher-ranked types with their
388388
// late-bound lifetimes are still around and can lead to type
389389
// differences.
390-
if util::relate_types(tcx, param_env, Variance::Covariant, src.ty, dest.ty) {
390+
if util::relate_types(
391+
tcx,
392+
param_env,
393+
Variance::Covariant,
394+
src.ty,
395+
dest.ty,
396+
tcx.next_trait_solver_globally(),
397+
) {
391398
// Make sure the layout is equal, too -- just to be safe. Miri really
392399
// needs layout equality. For performance reason we skip this check when
393400
// the types are equal. Equal types *can* have different layouts when

compiler/rustc_const_eval/src/transform/validate.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
634634
Variance::Covariant
635635
};
636636

637-
crate::util::relate_types(self.tcx, self.param_env, variance, src, dest)
637+
crate::util::relate_types(self.tcx, self.param_env, variance, src, dest, true)
638638
}
639639
}
640640

@@ -792,6 +792,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
792792
Variance::Covariant,
793793
ty,
794794
place_ref.ty(&self.body.local_decls, self.tcx).ty,
795+
true,
795796
) {
796797
self.fail(
797798
location,

compiler/rustc_const_eval/src/util/compare_types.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ pub fn is_equal_up_to_subtyping<'tcx>(
1717
param_env: ParamEnv<'tcx>,
1818
src: Ty<'tcx>,
1919
dest: Ty<'tcx>,
20+
next_trait_solver: bool,
2021
) -> bool {
2122
// Fast path.
2223
if src == dest {
2324
return true;
2425
}
2526

2627
// Check for subtyping in either direction.
27-
relate_types(tcx, param_env, Variance::Covariant, src, dest)
28-
|| relate_types(tcx, param_env, Variance::Covariant, dest, src)
28+
relate_types(tcx, param_env, Variance::Covariant, src, dest, next_trait_solver)
29+
|| relate_types(tcx, param_env, Variance::Covariant, dest, src, next_trait_solver)
2930
}
3031

3132
/// Returns whether `src` is a subtype of `dest`, i.e. `src <: dest`.
@@ -42,13 +43,17 @@ pub fn relate_types<'tcx>(
4243
variance: Variance,
4344
src: Ty<'tcx>,
4445
dest: Ty<'tcx>,
46+
next_trait_solver: bool,
4547
) -> bool {
4648
if src == dest {
4749
return true;
4850
}
4951

50-
let mut builder =
51-
tcx.infer_ctxt().ignoring_regions().with_opaque_type_inference(DefiningAnchor::Bubble);
52+
let mut builder = tcx
53+
.infer_ctxt()
54+
.ignoring_regions()
55+
.with_next_trait_solver(next_trait_solver)
56+
.with_opaque_type_inference(DefiningAnchor::Bubble);
5257
let infcx = builder.build();
5358
let ocx = ObligationCtxt::new(&infcx);
5459
let cause = ObligationCause::dummy();

compiler/rustc_mir_transform/src/inline.rs

+3
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ impl<'tcx> Inliner<'tcx> {
220220
ty::Variance::Covariant,
221221
output_type,
222222
destination_ty,
223+
true,
223224
) {
224225
trace!(?output_type, ?destination_ty);
225226
return Err("failed to normalize return type");
@@ -256,6 +257,7 @@ impl<'tcx> Inliner<'tcx> {
256257
ty::Variance::Covariant,
257258
input_type,
258259
arg_ty,
260+
true,
259261
) {
260262
trace!(?arg_ty, ?input_type);
261263
return Err("failed to normalize tuple argument type");
@@ -271,6 +273,7 @@ impl<'tcx> Inliner<'tcx> {
271273
ty::Variance::Covariant,
272274
input_type,
273275
arg_ty,
276+
true,
274277
) {
275278
trace!(?arg_ty, ?input_type);
276279
return Err("failed to normalize argument type");

0 commit comments

Comments
 (0)