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
|
@ -32,7 +32,7 @@ use rustc_middle::bug;
|
|||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypingMode, Upcast, VariantDef};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Upcast, VariantDef};
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
// hardwired lints from rustc_lint_defs
|
||||
pub use rustc_session::lint::builtin::*;
|
||||
|
@ -586,10 +586,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if ty.is_copy_modulo_regions(cx.tcx, cx.param_env) {
|
||||
if ty.is_copy_modulo_regions(cx.tcx, cx.typing_env()) {
|
||||
return;
|
||||
}
|
||||
if type_implements_negative_copy_modulo_regions(cx.tcx, ty, cx.param_env) {
|
||||
if type_implements_negative_copy_modulo_regions(cx.tcx, ty, cx.typing_env()) {
|
||||
return;
|
||||
}
|
||||
if def.is_variant_list_non_exhaustive()
|
||||
|
@ -637,8 +637,9 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
|
|||
fn type_implements_negative_copy_modulo_regions<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
) -> bool {
|
||||
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env);
|
||||
let trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(hir::LangItem::Copy, None), [ty]);
|
||||
let pred = ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Negative };
|
||||
let obligation = traits::Obligation {
|
||||
|
@ -647,10 +648,7 @@ fn type_implements_negative_copy_modulo_regions<'tcx>(
|
|||
recursion_depth: 0,
|
||||
predicate: pred.upcast(tcx),
|
||||
};
|
||||
|
||||
tcx.infer_ctxt()
|
||||
.build(TypingMode::non_body_analysis())
|
||||
.predicate_must_hold_modulo_regions(&obligation)
|
||||
infcx.predicate_must_hold_modulo_regions(&obligation)
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
|
|
|
@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
|
|||
&& let Some(fn_name) = cx.tcx.get_diagnostic_name(def_id)
|
||||
{
|
||||
let arg_ty = cx.typeck_results().expr_ty(arg);
|
||||
let is_copy = arg_ty.is_copy_modulo_regions(cx.tcx, cx.param_env);
|
||||
let is_copy = arg_ty.is_copy_modulo_regions(cx.tcx, cx.typing_env());
|
||||
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
|
||||
let let_underscore_ignore_sugg = || {
|
||||
if let Some((_, node)) = cx.tcx.hir().parent_iter(expr.hir_id).nth(0)
|
||||
|
|
|
@ -168,7 +168,7 @@ fn is_cast_from_ref_to_mut_ptr<'tcx>(
|
|||
// Except on the presence of non concrete skeleton types (ie generics)
|
||||
// since there is no way to make it safe for arbitrary types.
|
||||
let inner_ty_has_interior_mutability =
|
||||
!inner_ty.is_freeze(cx.tcx, cx.param_env) && inner_ty.has_concrete_skeleton();
|
||||
!inner_ty.is_freeze(cx.tcx, cx.typing_env()) && inner_ty.has_concrete_skeleton();
|
||||
(!need_check_freeze || !inner_ty_has_interior_mutability)
|
||||
.then_some(inner_ty_has_interior_mutability)
|
||||
} else {
|
||||
|
|
|
@ -292,7 +292,7 @@ fn lint_wide_pointer<'tcx>(
|
|||
_ => return None,
|
||||
};
|
||||
|
||||
(!ty.is_sized(cx.tcx, cx.param_env))
|
||||
(!ty.is_sized(cx.tcx, cx.typing_env()))
|
||||
.then(|| (refs, modifiers, matches!(ty.kind(), ty::Dynamic(_, _, ty::Dyn))))
|
||||
};
|
||||
|
||||
|
@ -904,7 +904,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
if let Some(boxed) = ty.boxed_ty()
|
||||
&& matches!(self.mode, CItemKind::Definition)
|
||||
{
|
||||
if boxed.is_sized(tcx, self.cx.param_env) {
|
||||
if boxed.is_sized(tcx, self.cx.typing_env()) {
|
||||
return FfiSafe;
|
||||
} else {
|
||||
return FfiUnsafe {
|
||||
|
@ -1069,7 +1069,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
ty::RawPtr(ty, _) | ty::Ref(_, ty, _)
|
||||
if {
|
||||
matches!(self.mode, CItemKind::Definition)
|
||||
&& ty.is_sized(self.cx.tcx, self.cx.param_env)
|
||||
&& ty.is_sized(self.cx.tcx, self.cx.typing_env())
|
||||
} =>
|
||||
{
|
||||
FfiSafe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue