Rollup merge of #132403 - lcnr:typing-mode, r=compiler-errors
continue `TypingMode` refactor There are still quite a few places which (indirectly) rely on the `Reveal` of a `ParamEnv`, but we're slowly getting there r? `@compiler-errors`
This commit is contained in:
commit
c57b351d38
20 changed files with 155 additions and 105 deletions
|
@ -244,8 +244,13 @@ impl<'tcx> Inliner<'tcx> {
|
|||
// Normally, this shouldn't be required, but trait normalization failure can create a
|
||||
// validation ICE.
|
||||
let output_type = callee_body.return_ty();
|
||||
if !util::relate_types(self.tcx, self.param_env, ty::Covariant, output_type, destination_ty)
|
||||
{
|
||||
if !util::sub_types(
|
||||
self.tcx,
|
||||
caller_body.typing_mode(self.tcx),
|
||||
self.param_env,
|
||||
output_type,
|
||||
destination_ty,
|
||||
) {
|
||||
trace!(?output_type, ?destination_ty);
|
||||
return Err("failed to normalize return type");
|
||||
}
|
||||
|
@ -275,8 +280,13 @@ impl<'tcx> Inliner<'tcx> {
|
|||
self_arg_ty.into_iter().chain(arg_tuple_tys).zip(callee_body.args_iter())
|
||||
{
|
||||
let input_type = callee_body.local_decls[input].ty;
|
||||
if !util::relate_types(self.tcx, self.param_env, ty::Covariant, input_type, arg_ty)
|
||||
{
|
||||
if !util::sub_types(
|
||||
self.tcx,
|
||||
caller_body.typing_mode(self.tcx),
|
||||
self.param_env,
|
||||
input_type,
|
||||
arg_ty,
|
||||
) {
|
||||
trace!(?arg_ty, ?input_type);
|
||||
return Err("failed to normalize tuple argument type");
|
||||
}
|
||||
|
@ -285,8 +295,13 @@ impl<'tcx> Inliner<'tcx> {
|
|||
for (arg, input) in args.iter().zip(callee_body.args_iter()) {
|
||||
let input_type = callee_body.local_decls[input].ty;
|
||||
let arg_ty = arg.node.ty(&caller_body.local_decls, self.tcx);
|
||||
if !util::relate_types(self.tcx, self.param_env, ty::Covariant, input_type, arg_ty)
|
||||
{
|
||||
if !util::sub_types(
|
||||
self.tcx,
|
||||
caller_body.typing_mode(self.tcx),
|
||||
self.param_env,
|
||||
input_type,
|
||||
arg_ty,
|
||||
) {
|
||||
trace!(?arg_ty, ?input_type);
|
||||
return Err("failed to normalize argument type");
|
||||
}
|
||||
|
|
|
@ -5,14 +5,14 @@ use rustc_hir::LangItem;
|
|||
use rustc_index::IndexVec;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::traits::{Obligation, ObligationCause, Reveal};
|
||||
use rustc_infer::traits::{Obligation, ObligationCause};
|
||||
use rustc_middle::mir::coverage::CoverageKind;
|
||||
use rustc_middle::mir::visit::{NonUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
use rustc_middle::ty::{
|
||||
self, CoroutineArgsExt, InstanceKind, ParamEnv, ScalarInt, Ty, TyCtxt, TypeVisitableExt,
|
||||
TypingMode, Variance,
|
||||
Variance,
|
||||
};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_target::abi::{FIRST_VARIANT, Size};
|
||||
|
@ -20,7 +20,7 @@ use rustc_target::spec::abi::Abi;
|
|||
use rustc_trait_selection::traits::ObligationCtxt;
|
||||
use rustc_type_ir::Upcast;
|
||||
|
||||
use crate::util::{is_within_packed, relate_types};
|
||||
use crate::util::{self, is_within_packed};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
enum EdgeKind {
|
||||
|
@ -50,11 +50,7 @@ impl<'tcx> crate::MirPass<'tcx> for Validator {
|
|||
}
|
||||
let def_id = body.source.def_id();
|
||||
let mir_phase = self.mir_phase;
|
||||
let param_env = match mir_phase.reveal() {
|
||||
Reveal::UserFacing => tcx.param_env(def_id),
|
||||
Reveal::All => tcx.param_env_reveal_all_normalized(def_id),
|
||||
};
|
||||
|
||||
let param_env = mir_phase.param_env(tcx, def_id);
|
||||
let can_unwind = if mir_phase <= MirPhase::Runtime(RuntimePhase::Initial) {
|
||||
// In this case `AbortUnwindingCalls` haven't yet been executed.
|
||||
true
|
||||
|
@ -587,7 +583,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
Variance::Covariant
|
||||
};
|
||||
|
||||
crate::util::relate_types(self.tcx, self.param_env, variance, src, dest)
|
||||
crate::util::relate_types(
|
||||
self.tcx,
|
||||
self.body.typing_mode(self.tcx),
|
||||
self.param_env,
|
||||
variance,
|
||||
src,
|
||||
dest,
|
||||
)
|
||||
}
|
||||
|
||||
/// Check that the given predicate definitely holds in the param-env of this MIR body.
|
||||
|
@ -606,7 +609,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
return true;
|
||||
}
|
||||
|
||||
let infcx = self.tcx.infer_ctxt().build(TypingMode::from_param_env(self.param_env));
|
||||
let infcx = self.tcx.infer_ctxt().build(self.body.typing_mode(self.tcx));
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
ocx.register_obligation(Obligation::new(
|
||||
self.tcx,
|
||||
|
@ -798,10 +801,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
ProjectionElem::Subtype(ty) => {
|
||||
if !relate_types(
|
||||
if !util::sub_types(
|
||||
self.tcx,
|
||||
self.body.typing_mode(self.tcx),
|
||||
self.param_env,
|
||||
Variance::Covariant,
|
||||
ty,
|
||||
place_ref.ty(&self.body.local_decls, self.tcx).ty,
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue