move fn is_item_raw
to TypingEnv
This commit is contained in:
parent
89b6885529
commit
948cec0fad
60 changed files with 181 additions and 168 deletions
|
@ -397,7 +397,7 @@ fn adjust_for_rust_scalar<'tcx>(
|
|||
Some(kind)
|
||||
} else if let Some(pointee) = drop_target_pointee {
|
||||
// The argument to `drop_in_place` is semantically equivalent to a mutable reference.
|
||||
Some(PointerKind::MutableRef { unpin: pointee.is_unpin(tcx, cx.typing_env.param_env) })
|
||||
Some(PointerKind::MutableRef { unpin: pointee.is_unpin(tcx, cx.typing_env) })
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -3,34 +3,33 @@
|
|||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypingMode};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
|
||||
is_item_raw(tcx, query, LangItem::Copy)
|
||||
}
|
||||
|
||||
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
|
||||
is_item_raw(tcx, query, LangItem::Sized)
|
||||
}
|
||||
|
||||
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
|
||||
is_item_raw(tcx, query, LangItem::Freeze)
|
||||
}
|
||||
|
||||
fn is_unpin_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
fn is_unpin_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> bool {
|
||||
is_item_raw(tcx, query, LangItem::Unpin)
|
||||
}
|
||||
|
||||
fn is_item_raw<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
|
||||
item: LangItem,
|
||||
) -> bool {
|
||||
let (param_env, ty) = query.into_parts();
|
||||
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(query.typing_env);
|
||||
let trait_def_id = tcx.require_lang_item(item, None);
|
||||
let infcx = tcx.infer_ctxt().build(TypingMode::from_param_env(param_env));
|
||||
traits::type_known_to_meet_bound_modulo_regions(&infcx, param_env, ty, trait_def_id)
|
||||
traits::type_known_to_meet_bound_modulo_regions(&infcx, param_env, query.value, trait_def_id)
|
||||
}
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
|
|
|
@ -105,7 +105,7 @@ fn map_error<'tcx>(
|
|||
// This is sometimes not a compile error if there are trivially false where clauses.
|
||||
// See `tests/ui/layout/trivial-bounds-sized.rs` for an example.
|
||||
assert!(field.layout.is_unsized(), "invalid layout error {err:#?}");
|
||||
if !field.ty.is_sized(cx.tcx(), cx.typing_env.param_env) {
|
||||
if !field.ty.is_sized(cx.tcx(), cx.typing_env) {
|
||||
cx.tcx().dcx().delayed_bug(format!(
|
||||
"encountered unexpected unsized field in layout of {ty:?}: {field:#?}"
|
||||
));
|
||||
|
@ -236,7 +236,7 @@ fn layout_of_uncached<'tcx>(
|
|||
}
|
||||
|
||||
let pointee = tcx.normalize_erasing_regions(cx.typing_env, pointee);
|
||||
if pointee.is_sized(tcx, cx.typing_env.param_env) {
|
||||
if pointee.is_sized(tcx, cx.typing_env) {
|
||||
return Ok(tcx.mk_layout(LayoutData::scalar(cx, data_ptr)));
|
||||
}
|
||||
|
||||
|
@ -594,8 +594,8 @@ fn layout_of_uncached<'tcx>(
|
|||
|
||||
let maybe_unsized = def.is_struct()
|
||||
&& def.non_enum_variant().tail_opt().is_some_and(|last_field| {
|
||||
let param_env = tcx.param_env(def.did());
|
||||
!tcx.type_of(last_field.did).instantiate_identity().is_sized(tcx, param_env)
|
||||
let typing_env = ty::TypingEnv::post_analysis(tcx, def.did());
|
||||
!tcx.type_of(last_field.did).instantiate_identity().is_sized(tcx, typing_env)
|
||||
});
|
||||
|
||||
let layout = cx
|
||||
|
@ -620,11 +620,7 @@ fn layout_of_uncached<'tcx>(
|
|||
// If the struct tail is sized and can be unsized, check that unsizing doesn't move the fields around.
|
||||
if cfg!(debug_assertions)
|
||||
&& maybe_unsized
|
||||
&& def
|
||||
.non_enum_variant()
|
||||
.tail()
|
||||
.ty(tcx, args)
|
||||
.is_sized(tcx, cx.typing_env.param_env)
|
||||
&& def.non_enum_variant().tail().ty(tcx, args).is_sized(tcx, cx.typing_env)
|
||||
{
|
||||
let mut variants = variants;
|
||||
let tail_replacement = cx.layout_of(Ty::new_slice(tcx, tcx.types.u8)).unwrap();
|
||||
|
|
|
@ -186,7 +186,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
_ if component.is_copy_modulo_regions(tcx, self.typing_env.param_env) => (),
|
||||
_ if component.is_copy_modulo_regions(tcx, self.typing_env) => (),
|
||||
|
||||
ty::Closure(_, args) => {
|
||||
for upvar in args.as_closure().upvar_tys() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue