stop using ParamEnv::reveal while handling MIR
This commit is contained in:
@@ -8,24 +8,15 @@ use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt, TypingMode, Variance};
|
||||
use rustc_trait_selection::traits::ObligationCtxt;
|
||||
|
||||
/// Returns whether the two types are equal up to subtyping.
|
||||
///
|
||||
/// This is used in case we don't know the expected subtyping direction
|
||||
/// and still want to check whether anything is broken.
|
||||
pub fn is_equal_up_to_subtyping<'tcx>(
|
||||
/// Returns whether `src` is a subtype of `dest`, i.e. `src <: dest`.
|
||||
pub fn sub_types<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
typing_mode: TypingMode<'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
src: Ty<'tcx>,
|
||||
dest: Ty<'tcx>,
|
||||
) -> bool {
|
||||
// Fast path.
|
||||
if src == dest {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for subtyping in either direction.
|
||||
relate_types(tcx, param_env, Variance::Covariant, src, dest)
|
||||
|| relate_types(tcx, param_env, Variance::Covariant, dest, src)
|
||||
relate_types(tcx, typing_mode, param_env, Variance::Covariant, src, dest)
|
||||
}
|
||||
|
||||
/// Returns whether `src` is a subtype of `dest`, i.e. `src <: dest`.
|
||||
@@ -35,6 +26,7 @@ pub fn is_equal_up_to_subtyping<'tcx>(
|
||||
/// because we want to check for type equality.
|
||||
pub fn relate_types<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
typing_mode: TypingMode<'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
variance: Variance,
|
||||
src: Ty<'tcx>,
|
||||
@@ -45,8 +37,7 @@ pub fn relate_types<'tcx>(
|
||||
}
|
||||
|
||||
let mut builder = tcx.infer_ctxt().ignoring_regions();
|
||||
// FIXME(#132279): This should eventually use the already defined hidden types.
|
||||
let infcx = builder.build(TypingMode::from_param_env(param_env));
|
||||
let infcx = builder.build(typing_mode);
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
let cause = ObligationCause::dummy();
|
||||
let src = ocx.normalize(&cause, param_env, src);
|
||||
|
||||
@@ -8,7 +8,7 @@ mod type_name;
|
||||
|
||||
pub use self::alignment::{is_disaligned, is_within_packed};
|
||||
pub use self::check_validity_requirement::check_validity_requirement;
|
||||
pub use self::compare_types::{is_equal_up_to_subtyping, relate_types};
|
||||
pub use self::compare_types::{relate_types, sub_types};
|
||||
pub use self::type_name::type_name;
|
||||
|
||||
/// Classify whether an operator is "left-homogeneous", i.e., the LHS has the
|
||||
|
||||
Reference in New Issue
Block a user