mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
update tools
This commit is contained in:
parent
ce22ccb552
commit
4f3a73a42c
@ -1,7 +1,7 @@
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::infer::{DefineOpaqueTypes, InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits;
|
||||
use rustc_middle::ty::{self, Upcast};
|
||||
use rustc_middle::ty::{self, TypingMode, Upcast};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
@ -38,7 +38,7 @@ pub(crate) fn synthesize_blanket_impls(
|
||||
if !matches!(trait_ref.skip_binder().self_ty().kind(), ty::Param(_)) {
|
||||
continue;
|
||||
}
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
|
||||
let args = infcx.fresh_args_for_item(DUMMY_SP, item_def_id);
|
||||
let impl_ty = ty.instantiate(tcx, args);
|
||||
let param_env = ty::ParamEnv::empty();
|
||||
|
@ -45,7 +45,7 @@ use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE, LocalDefId};
|
||||
use rustc_hir_analysis::lower_ty;
|
||||
use rustc_middle::metadata::Reexport;
|
||||
use rustc_middle::middle::resolve_bound_vars as rbv;
|
||||
use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt, TypingMode};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::ExpnKind;
|
||||
use rustc_span::hygiene::{AstPass, MacroKind};
|
||||
@ -1863,7 +1863,7 @@ fn normalize<'tcx>(
|
||||
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
|
||||
|
||||
// Try to normalize `<X as Y>::T` to a type
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(TypingMode::non_body_analysis());
|
||||
let normalized = infcx
|
||||
.at(&ObligationCause::dummy(), cx.param_env)
|
||||
.query_normalize(ty)
|
||||
@ -2399,7 +2399,7 @@ pub(crate) fn clean_variant_def_with_args<'tcx>(
|
||||
use rustc_trait_selection::infer::TyCtxtInferExt;
|
||||
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
|
||||
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(TypingMode::non_body_analysis());
|
||||
let kind = match variant.ctor_kind() {
|
||||
Some(CtorKind::Const) => VariantKind::CLike,
|
||||
Some(CtorKind::Fn) => VariantKind::Tuple(
|
||||
|
@ -20,8 +20,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_metadata::creader::{CStore, LoadedMacro};
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_middle::ty::{self, TyCtxt, TypingMode};
|
||||
use rustc_span::symbol::kw;
|
||||
use rustc_span::{Symbol, sym};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
@ -613,7 +612,7 @@ fn generate_item_def_id_path(
|
||||
// No need to try to infer the actual parent item if it's not an associated item from the `impl`
|
||||
// block.
|
||||
if def_id != original_def_id && matches!(tcx.def_kind(def_id), DefKind::Impl { .. }) {
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
|
||||
def_id = infcx
|
||||
.at(&ObligationCause::dummy(), tcx.param_env(def_id))
|
||||
.query_normalize(ty::Binder::dummy(tcx.type_of(def_id).instantiate_identity()))
|
||||
|
@ -9,7 +9,8 @@ use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, Saf
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::{
|
||||
self, Binder, ClosureKind, FnSig, GenericArg, GenericArgKind, List, Region, Ty, TypeVisitableExt, TypeckResults,
|
||||
self, Binder, ClosureKind, FnSig, GenericArg, GenericArgKind, List, Region, Ty, TypeVisitableExt,
|
||||
TypeckResults,
|
||||
};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::symbol::sym;
|
||||
@ -203,7 +204,7 @@ fn check_clousure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tc
|
||||
// 'cuz currently nothing changes after deleting this check.
|
||||
local_used_in(cx, l, args) || local_used_after_expr(cx, l, expr)
|
||||
}) {
|
||||
match cx.tcx.infer_ctxt().build().err_ctxt().type_implements_fn_trait(
|
||||
match cx.tcx.infer_ctxt().build(cx.typing_mode()).err_ctxt().type_implements_fn_trait(
|
||||
cx.param_env,
|
||||
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
|
||||
ty::PredicatePolarity::Positive,
|
||||
|
@ -117,7 +117,7 @@ fn check_needless_must_use(
|
||||
} else if attr.value_str().is_none() && is_must_use_ty(cx, return_ty(cx, item_id)) {
|
||||
// Ignore async functions unless Future::Output type is a must_use type
|
||||
if sig.header.is_async() {
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(cx.typing_mode());
|
||||
if let Some(future_ty) = infcx.err_ctxt().get_impl_future_output_ty(return_ty(cx, item_id))
|
||||
&& !is_must_use_ty(cx, future_ty)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
|
||||
if is_future {
|
||||
let send_trait = cx.tcx.get_diagnostic_item(sym::Send).unwrap();
|
||||
let span = decl.output.span();
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(cx.typing_mode());
|
||||
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
|
||||
let cause = traits::ObligationCause::misc(span, fn_def_id);
|
||||
ocx.register_bound(cause, cx.param_env, ret_ty, send_trait);
|
||||
|
@ -568,7 +568,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
|
||||
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
|
||||
!cx.tcx
|
||||
.infer_ctxt()
|
||||
.build()
|
||||
.build(cx.typing_mode())
|
||||
.predicate_must_hold_modulo_regions(&obligation)
|
||||
}) {
|
||||
return false;
|
||||
|
@ -278,7 +278,7 @@ fn needless_borrow_count<'tcx>(
|
||||
|
||||
let predicate = EarlyBinder::bind(predicate).instantiate(cx.tcx, &args_with_referent_ty[..]);
|
||||
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(cx.typing_mode());
|
||||
infcx.predicate_must_hold_modulo_regions(&obligation)
|
||||
})
|
||||
};
|
||||
|
@ -160,7 +160,7 @@ impl NoEffect {
|
||||
// Remove `impl Future<Output = T>` to get `T`
|
||||
if cx.tcx.ty_is_opaque_future(ret_ty)
|
||||
&& let Some(true_ret_ty) =
|
||||
cx.tcx.infer_ctxt().build().err_ctxt().get_impl_future_output_ty(ret_ty)
|
||||
cx.tcx.infer_ctxt().build(cx.typing_mode()).err_ctxt().get_impl_future_output_ty(ret_ty)
|
||||
{
|
||||
ret_ty = true_ret_ty;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ fn matches_preds<'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
preds: &'tcx [ty::PolyExistentialPredicate<'tcx>],
|
||||
) -> bool {
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(cx.typing_mode());
|
||||
preds
|
||||
.iter()
|
||||
.all(|&p| match cx.tcx.instantiate_bound_regions_with_erased(p) {
|
||||
|
@ -114,7 +114,7 @@ fn into_iter_bound<'tcx>(
|
||||
if !cx
|
||||
.tcx
|
||||
.infer_ctxt()
|
||||
.build()
|
||||
.build(cx.typing_mode())
|
||||
.predicate_must_hold_modulo_regions(&obligation)
|
||||
{
|
||||
return None;
|
||||
|
@ -17,7 +17,7 @@ use rustc_middle::mir::{
|
||||
};
|
||||
use rustc_middle::traits::{BuiltinImplSource, ImplSource, ObligationCause};
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
use rustc_middle::ty::{self, GenericArgKind, TraitRef, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, GenericArgKind, TraitRef, Ty, TyCtxt, TypingMode};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_trait_selection::traits::{ObligationCtxt, SelectionContext};
|
||||
@ -420,7 +420,7 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>
|
||||
TraitRef::new(tcx, tcx.require_lang_item(LangItem::Destruct, Some(body.span)), [ty]),
|
||||
);
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let infcx = tcx.infer_ctxt().build(TypingMode::from_param_env(obligation.param_env));
|
||||
let mut selcx = SelectionContext::new(&infcx);
|
||||
let Some(impl_src) = selcx.select(&obligation).ok().flatten() else {
|
||||
return false;
|
||||
|
@ -19,7 +19,7 @@ use rustc_middle::ty::layout::ValidityRequirement;
|
||||
use rustc_middle::ty::{
|
||||
self, AdtDef, AliasTy, AssocItem, AssocKind, Binder, BoundRegion, FnSig, GenericArg, GenericArgKind,
|
||||
GenericArgsRef, GenericParamDefKind, IntTy, ParamEnv, Region, RegionKind, TraitRef, Ty, TyCtxt, TypeSuperVisitable,
|
||||
TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, Upcast, VariantDef, VariantDiscr,
|
||||
TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, Upcast, VariantDef, VariantDiscr, TypingMode,
|
||||
};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
|
||||
@ -268,7 +268,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
||||
return false;
|
||||
}
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let infcx = tcx.infer_ctxt().build(TypingMode::from_param_env(param_env));
|
||||
let args = args
|
||||
.into_iter()
|
||||
.map(|arg| arg.into().unwrap_or_else(|| infcx.next_ty_var(DUMMY_SP).into()))
|
||||
@ -362,7 +362,7 @@ fn is_normalizable_helper<'tcx>(
|
||||
}
|
||||
// prevent recursive loops, false-negative is better than endless loop leading to stack overflow
|
||||
cache.insert(ty, false);
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
let infcx = cx.tcx.infer_ctxt().build(TypingMode::from_param_env(param_env));
|
||||
let cause = ObligationCause::dummy();
|
||||
let result = if infcx.at(&cause, param_env).query_normalize(ty).is_ok() {
|
||||
match ty.kind() {
|
||||
@ -1268,7 +1268,7 @@ pub fn make_normalized_projection_with_regions<'tcx>(
|
||||
let cause = ObligationCause::dummy();
|
||||
match tcx
|
||||
.infer_ctxt()
|
||||
.build()
|
||||
.build(TypingMode::from_param_env(param_env))
|
||||
.at(&cause, param_env)
|
||||
.query_normalize(Ty::new_projection_from_args(tcx, ty.def_id, ty.args))
|
||||
{
|
||||
@ -1284,7 +1284,7 @@ pub fn make_normalized_projection_with_regions<'tcx>(
|
||||
|
||||
pub fn normalize_with_regions<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
let cause = ObligationCause::dummy();
|
||||
match tcx.infer_ctxt().build().at(&cause, param_env).query_normalize(ty) {
|
||||
match tcx.infer_ctxt().build(TypingMode::from_param_env(param_env)).at(&cause, param_env).query_normalize(ty) {
|
||||
Ok(ty) => ty.value,
|
||||
Err(_) => ty,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user