Skip to content

Commit 0bb2a6b

Browse files
committed
Now that inlining, mir validation and const eval all use reveal-all, we won't be constraining hidden types here anymore
1 parent c86974d commit 0bb2a6b

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

compiler/rustc_const_eval/src/util/compare_types.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! other areas of the compiler as well.
55
66
use rustc_infer::infer::TyCtxtInferExt;
7-
use rustc_middle::traits::{DefiningAnchor, ObligationCause};
7+
use rustc_middle::traits::ObligationCause;
88
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt, Variance};
99
use rustc_trait_selection::traits::ObligationCtxt;
1010

@@ -33,9 +33,6 @@ pub fn is_equal_up_to_subtyping<'tcx>(
3333
/// When validating assignments, the variance should be `Covariant`. When checking
3434
/// during `MirPhase` >= `MirPhase::Runtime(RuntimePhase::Initial)` variance should be `Invariant`
3535
/// because we want to check for type equality.
36-
///
37-
/// This mostly ignores opaque types as it can be used in constraining contexts
38-
/// while still computing the final underlying type.
3936
pub fn relate_types<'tcx>(
4037
tcx: TyCtxt<'tcx>,
4138
param_env: ParamEnv<'tcx>,
@@ -47,8 +44,7 @@ pub fn relate_types<'tcx>(
4744
return true;
4845
}
4946

50-
let mut builder =
51-
tcx.infer_ctxt().ignoring_regions().with_opaque_type_inference(DefiningAnchor::Bubble);
47+
let mut builder = tcx.infer_ctxt().ignoring_regions();
5248
let infcx = builder.build();
5349
let ocx = ObligationCtxt::new(&infcx);
5450
let cause = ObligationCause::dummy();
@@ -58,20 +54,5 @@ pub fn relate_types<'tcx>(
5854
Ok(()) => {}
5955
Err(_) => return false,
6056
};
61-
let errors = ocx.select_all_or_error();
62-
// With `Reveal::All`, opaque types get normalized away, with `Reveal::UserFacing`
63-
// we would get unification errors because we're unable to look into opaque types,
64-
// even if they're constrained in our current function.
65-
for (key, ty) in infcx.take_opaque_types() {
66-
let hidden_ty = tcx.type_of(key.def_id).instantiate(tcx, key.args);
67-
if hidden_ty != ty.hidden_type.ty {
68-
span_bug!(
69-
ty.hidden_type.span,
70-
"{}, {}",
71-
tcx.type_of(key.def_id).instantiate(tcx, key.args),
72-
ty.hidden_type.ty
73-
);
74-
}
75-
}
76-
errors.is_empty()
57+
ocx.select_all_or_error().is_empty()
7758
}

0 commit comments

Comments
 (0)