mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add EarlyBinder to fn_sig in metadata
This commit is contained in:
parent
e982971ff2
commit
c2414dfaa4
@ -2599,7 +2599,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
match ty.kind() {
|
||||
ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig(
|
||||
self.mir_def_id(),
|
||||
self.infcx.tcx.bound_fn_sig(self.mir_def_id().into()).subst_identity(),
|
||||
self.infcx.tcx.fn_sig(self.mir_def_id()).subst_identity(),
|
||||
),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&& let self_ty = infcx.replace_bound_vars_with_fresh_vars(
|
||||
fn_call_span,
|
||||
LateBoundRegionConversionTime::FnCall,
|
||||
tcx.bound_fn_sig(method_did).subst_identity().input(0),
|
||||
tcx.fn_sig(method_did).subst_identity().input(0),
|
||||
)
|
||||
&& infcx.can_eq(self.param_env, ty, self_ty).is_ok()
|
||||
{
|
||||
|
@ -472,7 +472,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
||||
// C-variadic fns also have a `VaList` input that's not listed in the signature
|
||||
// (as it's created inside the body itself, not passed in from outside).
|
||||
if let DefiningTy::FnDef(def_id, _) = defining_ty {
|
||||
if self.infcx.tcx.bound_fn_sig(def_id).skip_binder().c_variadic() {
|
||||
if self.infcx.tcx.fn_sig(def_id).skip_binder().c_variadic() {
|
||||
let va_list_did = self.infcx.tcx.require_lang_item(
|
||||
LangItem::VaList,
|
||||
Some(self.infcx.tcx.def_span(self.mir_def.did)),
|
||||
@ -665,7 +665,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
DefiningTy::FnDef(def_id, _) => {
|
||||
let sig = tcx.bound_fn_sig(def_id).subst_identity();
|
||||
let sig = tcx.fn_sig(def_id).subst_identity();
|
||||
let sig = indices.fold_to_region_vids(tcx, sig);
|
||||
sig.inputs_and_output()
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
is_main_fn: bool,
|
||||
sigpipe: u8,
|
||||
) {
|
||||
let main_ret_ty = tcx.bound_fn_sig(rust_main_def_id).subst_identity().output();
|
||||
let main_ret_ty = tcx.fn_sig(rust_main_def_id).subst_identity().output();
|
||||
// Given that `main()` has no arguments,
|
||||
// then its return type cannot have
|
||||
// late-bound regions, since late-bound
|
||||
|
@ -441,7 +441,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
|
||||
// the WebAssembly specification, which has this feature. This won't be
|
||||
// needed when LLVM enables this `multivalue` feature by default.
|
||||
if !cx.tcx.is_closure(instance.def_id()) {
|
||||
let abi = cx.tcx.bound_fn_sig(instance.def_id()).skip_binder().abi();
|
||||
let abi = cx.tcx.fn_sig(instance.def_id()).skip_binder().abi();
|
||||
if abi == Abi::Wasm {
|
||||
function_features.push("+multivalue".to_string());
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
cx.type_func(&[], cx.type_int())
|
||||
};
|
||||
|
||||
let main_ret_ty = cx.tcx().fn_sig(rust_main_def_id).output();
|
||||
let main_ret_ty = cx.tcx().fn_sig(rust_main_def_id).subst_identity().output();
|
||||
// Given that `main()` has no arguments,
|
||||
// then its return type cannot have
|
||||
// late-bound regions, since late-bound
|
||||
|
@ -214,7 +214,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
|
||||
}
|
||||
} else if attr.has_name(sym::cmse_nonsecure_entry) {
|
||||
if validate_fn_only_attr(attr.span)
|
||||
&& !matches!(tcx.bound_fn_sig(did.into()).skip_binder().abi(), abi::Abi::C { .. })
|
||||
&& !matches!(tcx.fn_sig(did).skip_binder().abi(), abi::Abi::C { .. })
|
||||
{
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
@ -234,7 +234,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
|
||||
} else if attr.has_name(sym::track_caller) {
|
||||
if !tcx.is_closure(did.to_def_id())
|
||||
&& validate_fn_only_attr(attr.span)
|
||||
&& tcx.bound_fn_sig(did.into()).skip_binder().abi() != abi::Abi::Rust
|
||||
&& tcx.fn_sig(did).skip_binder().abi() != abi::Abi::Rust
|
||||
{
|
||||
struct_span_err!(tcx.sess, attr.span, E0737, "`#[track_caller]` requires Rust ABI")
|
||||
.emit();
|
||||
@ -266,7 +266,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
|
||||
}
|
||||
} else if attr.has_name(sym::target_feature) {
|
||||
if !tcx.is_closure(did.to_def_id())
|
||||
&& tcx.bound_fn_sig(did.into()).skip_binder().unsafety() == hir::Unsafety::Normal
|
||||
&& tcx.fn_sig(did).skip_binder().unsafety() == hir::Unsafety::Normal
|
||||
{
|
||||
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
|
||||
// The `#[target_feature]` attribute is allowed on
|
||||
|
@ -64,7 +64,7 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
&& match tcx.lookup_const_stability(def_id) {
|
||||
Some(stab) => {
|
||||
if cfg!(debug_assertions) && stab.promotable {
|
||||
let sig = tcx.bound_fn_sig(def_id);
|
||||
let sig = tcx.fn_sig(def_id);
|
||||
assert_eq!(
|
||||
sig.skip_binder().unsafety(),
|
||||
hir::Unsafety::Normal,
|
||||
|
@ -72,7 +72,7 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
|
||||
let ty::Closure(_, substs) = ty.kind() else { bug!("type_of closure not ty::Closure") };
|
||||
substs.as_closure().sig()
|
||||
} else {
|
||||
self.tcx.bound_fn_sig(did).subst_identity()
|
||||
self.tcx.fn_sig(did).subst_identity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3140,7 +3140,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
trait_ref.def_id,
|
||||
)?;
|
||||
|
||||
let fn_sig = tcx.bound_fn_sig(assoc.def_id).subst(
|
||||
let fn_sig = tcx.fn_sig(assoc.def_id).subst(
|
||||
tcx,
|
||||
trait_ref.substs.extend_to(tcx, assoc.def_id, |param, _| tcx.mk_param_from_def(param)),
|
||||
);
|
||||
|
@ -249,7 +249,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||
let unnormalized_impl_sig = infcx.replace_bound_vars_with_fresh_vars(
|
||||
impl_m_span,
|
||||
infer::HigherRankedType,
|
||||
tcx.bound_fn_sig(impl_m.def_id).subst_identity(),
|
||||
tcx.fn_sig(impl_m.def_id).subst_identity(),
|
||||
);
|
||||
let unnormalized_impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(unnormalized_impl_sig));
|
||||
|
||||
@ -257,7 +257,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
||||
let impl_sig = ocx.normalize(&norm_cause, param_env, unnormalized_impl_sig);
|
||||
debug!("compare_impl_method: impl_fty={:?}", impl_sig);
|
||||
|
||||
let trait_sig = tcx.bound_fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs);
|
||||
let trait_sig = tcx.fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs);
|
||||
let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, trait_sig);
|
||||
|
||||
// Next, add all inputs and output as well-formed tys. Importantly,
|
||||
@ -422,8 +422,8 @@ fn extract_bad_args_for_implies_lint<'tcx>(
|
||||
|
||||
// Map late-bound regions from trait to impl, so the names are right.
|
||||
let mapping = std::iter::zip(
|
||||
tcx.bound_fn_sig(trait_m.def_id).subst_identity().bound_vars(),
|
||||
tcx.bound_fn_sig(impl_m.def_id).subst_identity().bound_vars(),
|
||||
tcx.fn_sig(trait_m.def_id).subst_identity().bound_vars(),
|
||||
tcx.fn_sig(impl_m.def_id).subst_identity().bound_vars(),
|
||||
)
|
||||
.filter_map(|(impl_bv, trait_bv)| {
|
||||
if let ty::BoundVariableKind::Region(impl_bv) = impl_bv
|
||||
@ -540,7 +540,7 @@ fn compare_asyncness<'tcx>(
|
||||
trait_item_span: Option<Span>,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
if tcx.asyncness(trait_m.def_id) == hir::IsAsync::Async {
|
||||
match tcx.bound_fn_sig(impl_m.def_id).subst_identity().skip_binder().output().kind() {
|
||||
match tcx.fn_sig(impl_m.def_id).subst_identity().skip_binder().output().kind() {
|
||||
ty::Alias(ty::Opaque, ..) => {
|
||||
// allow both `async fn foo()` and `fn foo() -> impl Future`
|
||||
}
|
||||
@ -643,7 +643,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
infcx.replace_bound_vars_with_fresh_vars(
|
||||
return_span,
|
||||
infer::HigherRankedType,
|
||||
tcx.bound_fn_sig(impl_m.def_id).subst_identity(),
|
||||
tcx.fn_sig(impl_m.def_id).subst_identity(),
|
||||
),
|
||||
);
|
||||
impl_sig.error_reported()?;
|
||||
@ -657,7 +657,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||
let unnormalized_trait_sig = tcx
|
||||
.liberate_late_bound_regions(
|
||||
impl_m.def_id,
|
||||
tcx.bound_fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs),
|
||||
tcx.fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs),
|
||||
)
|
||||
.fold_with(&mut collector);
|
||||
let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig);
|
||||
@ -1117,7 +1117,7 @@ fn compare_self_type<'tcx>(
|
||||
ty::ImplContainer => impl_trait_ref.self_ty(),
|
||||
ty::TraitContainer => tcx.types.self_param,
|
||||
};
|
||||
let self_arg_ty = tcx.bound_fn_sig(method.def_id).subst_identity().input(0);
|
||||
let self_arg_ty = tcx.fn_sig(method.def_id).subst_identity().input(0);
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
@ -1348,8 +1348,8 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
trait_m: &ty::AssocItem,
|
||||
trait_item_span: Option<Span>,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let impl_m_fty = tcx.bound_fn_sig(impl_m.def_id);
|
||||
let trait_m_fty = tcx.bound_fn_sig(trait_m.def_id);
|
||||
let impl_m_fty = tcx.fn_sig(impl_m.def_id);
|
||||
let trait_m_fty = tcx.fn_sig(trait_m.def_id);
|
||||
let trait_number_args = trait_m_fty.skip_binder().inputs().skip_binder().len();
|
||||
let impl_number_args = impl_m_fty.skip_binder().inputs().skip_binder().len();
|
||||
|
||||
|
@ -58,7 +58,12 @@ fn equate_intrinsic_type<'tcx>(
|
||||
let fty = tcx.mk_fn_ptr(sig);
|
||||
let it_def_id = it.owner_id.def_id;
|
||||
let cause = ObligationCause::new(it.span, it_def_id, ObligationCauseCode::IntrinsicType);
|
||||
require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.bound_fn_sig(it.owner_id.to_def_id()).subst_identity()), fty);
|
||||
require_same_types(
|
||||
tcx,
|
||||
&cause,
|
||||
tcx.mk_fn_ptr(tcx.fn_sig(it.owner_id).subst_identity()),
|
||||
fty,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ fn suggestion_signature(assoc: &ty::AssocItem, tcx: TyCtxt<'_>) -> String {
|
||||
// regions just fine, showing `fn(&MyType)`.
|
||||
fn_sig_suggestion(
|
||||
tcx,
|
||||
tcx.bound_fn_sig(assoc.def_id).subst_identity().skip_binder(),
|
||||
tcx.fn_sig(assoc.def_id).subst_identity().skip_binder(),
|
||||
assoc.ident(tcx),
|
||||
tcx.predicates_of(assoc.def_id),
|
||||
assoc,
|
||||
|
@ -386,7 +386,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
|
||||
// `Self::Iter<'a>` is a GAT we want to gather any potential missing bounds from.
|
||||
let sig: ty::FnSig<'_> = tcx.liberate_late_bound_regions(
|
||||
item_def_id.to_def_id(),
|
||||
tcx.bound_fn_sig(item_def_id.to_def_id()).subst_identity(),
|
||||
tcx.fn_sig(item_def_id).subst_identity(),
|
||||
);
|
||||
gather_gat_bounds(
|
||||
tcx,
|
||||
@ -1018,7 +1018,7 @@ fn check_associated_item(
|
||||
wfcx.register_wf_obligation(span, loc, ty.into());
|
||||
}
|
||||
ty::AssocKind::Fn => {
|
||||
let sig = tcx.bound_fn_sig(item.def_id).subst_identity();
|
||||
let sig = tcx.fn_sig(item.def_id).subst_identity();
|
||||
let hir_sig = sig_if_method.expect("bad signature for method");
|
||||
check_fn_or_method(
|
||||
wfcx,
|
||||
@ -1203,7 +1203,7 @@ fn check_item_fn(
|
||||
decl: &hir::FnDecl<'_>,
|
||||
) {
|
||||
enter_wf_checking_ctxt(tcx, span, def_id, |wfcx| {
|
||||
let sig = tcx.bound_fn_sig(def_id.into()).subst_identity();
|
||||
let sig = tcx.fn_sig(def_id).subst_identity();
|
||||
check_fn_or_method(wfcx, ident.span, sig, decl, def_id);
|
||||
})
|
||||
}
|
||||
@ -1638,7 +1638,7 @@ fn check_method_receiver<'tcx>(
|
||||
|
||||
let span = fn_sig.decl.inputs[0].span;
|
||||
|
||||
let sig = tcx.bound_fn_sig(method.def_id).subst_identity();
|
||||
let sig = tcx.fn_sig(method.def_id).subst_identity();
|
||||
let sig = tcx.liberate_late_bound_regions(method.def_id, sig);
|
||||
let sig = wfcx.normalize(span, None, sig);
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ pub fn get_infer_ret_ty<'hir>(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(tcx))]
|
||||
fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<ty::PolyFnSig<'_>> {
|
||||
use rustc_hir::Node::*;
|
||||
use rustc_hir::*;
|
||||
|
||||
@ -1096,7 +1096,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
|
||||
let icx = ItemCtxt::new(tcx, def_id.to_def_id());
|
||||
|
||||
match tcx.hir().get(hir_id) {
|
||||
let output = match tcx.hir().get(hir_id) {
|
||||
TraitItem(hir::TraitItem {
|
||||
kind: TraitItemKind::Fn(sig, TraitFn::Provided(_)),
|
||||
generics,
|
||||
@ -1169,7 +1169,8 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
|
||||
x => {
|
||||
bug!("unexpected sort of node in fn_sig(): {:?}", x);
|
||||
}
|
||||
}
|
||||
};
|
||||
ty::EarlyBinder(output)
|
||||
}
|
||||
|
||||
fn infer_return_ty_for_fn_sig<'tcx>(
|
||||
|
@ -868,7 +868,7 @@ fn infer_placeholder_type<'a>(
|
||||
|
||||
match ty.kind() {
|
||||
ty::FnDef(def_id, _) => {
|
||||
self.tcx.mk_fn_ptr(self.tcx.bound_fn_sig(*def_id).subst_identity())
|
||||
self.tcx.mk_fn_ptr(self.tcx.fn_sig(*def_id).subst_identity())
|
||||
}
|
||||
// FIXME: non-capturing closures should also suggest a function pointer
|
||||
ty::Closure(..) | ty::Generator(..) => {
|
||||
|
@ -182,7 +182,7 @@ fn require_same_types<'tcx>(
|
||||
}
|
||||
|
||||
fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
|
||||
let main_fnsig = tcx.bound_fn_sig(main_def_id).subst_identity();
|
||||
let main_fnsig = tcx.fn_sig(main_def_id).subst_identity();
|
||||
let main_span = tcx.def_span(main_def_id);
|
||||
|
||||
fn main_fn_diagnostics_def_id(tcx: TyCtxt<'_>, def_id: DefId, sp: Span) -> LocalDefId {
|
||||
@ -449,7 +449,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
|
||||
ObligationCauseCode::StartFunctionType,
|
||||
),
|
||||
se_ty,
|
||||
tcx.mk_fn_ptr(tcx.bound_fn_sig(start_def_id.into()).subst_identity()),
|
||||
tcx.mk_fn_ptr(tcx.fn_sig(start_def_id).subst_identity()),
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
|
@ -121,7 +121,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
ty::FnDef(..) => {
|
||||
self.add_constraints_from_sig(
|
||||
current_item,
|
||||
tcx.bound_fn_sig(def_id.into()).subst_identity(),
|
||||
tcx.fn_sig(def_id).subst_identity(),
|
||||
self.covariant,
|
||||
);
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
) -> Ty<'tcx> {
|
||||
let (fn_sig, def_id) = match *callee_ty.kind() {
|
||||
ty::FnDef(def_id, subst) => {
|
||||
let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, subst);
|
||||
let fn_sig = self.tcx.fn_sig(def_id).subst(self.tcx, subst);
|
||||
|
||||
// Unit testing: function items annotated with
|
||||
// `#[rustc_evaluate_where_clauses]` trigger special output
|
||||
|
@ -299,7 +299,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
{
|
||||
// We special case methods, because they can influence inference through the
|
||||
// call's arguments and we can provide a more explicit span.
|
||||
let sig = self.tcx.bound_fn_sig(def_id).subst_identity();
|
||||
let sig = self.tcx.fn_sig(def_id).subst_identity();
|
||||
let def_self_ty = sig.input(0).skip_binder();
|
||||
let rcvr_ty = self.node_ty(rcvr.hir_id);
|
||||
// Get the evaluated type *after* calling the method call, so that the influence
|
||||
@ -613,7 +613,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
),
|
||||
match self
|
||||
.tcx
|
||||
.bound_fn_sig(m.def_id)
|
||||
.fn_sig(m.def_id)
|
||||
.subst_identity()
|
||||
.input(0)
|
||||
.skip_binder()
|
||||
@ -1043,13 +1043,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
match method.kind {
|
||||
ty::AssocKind::Fn => {
|
||||
method.fn_has_self_parameter
|
||||
&& self
|
||||
.tcx
|
||||
.bound_fn_sig(method.def_id)
|
||||
.skip_binder()
|
||||
.inputs()
|
||||
.skip_binder()
|
||||
.len()
|
||||
&& self.tcx.fn_sig(method.def_id).skip_binder().inputs().skip_binder().len()
|
||||
== 1
|
||||
}
|
||||
_ => false,
|
||||
|
@ -542,7 +542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
if let ty::FnDef(did, ..) = *ty.kind() {
|
||||
let fn_sig = ty.fn_sig(tcx);
|
||||
if tcx.bound_fn_sig(did).skip_binder().abi() == RustIntrinsic
|
||||
if tcx.fn_sig(did).skip_binder().abi() == RustIntrinsic
|
||||
&& tcx.item_name(did) == sym::transmute
|
||||
{
|
||||
let from = fn_sig.inputs().skip_binder()[0];
|
||||
|
@ -207,7 +207,7 @@ fn typeck_with_fallback<'tcx>(
|
||||
let fn_sig = if rustc_hir_analysis::collect::get_infer_ret_ty(&decl.output).is_some() {
|
||||
fcx.astconv().ty_of_fn(id, header.unsafety, header.abi, decl, None, None)
|
||||
} else {
|
||||
tcx.bound_fn_sig(def_id.into()).subst_identity()
|
||||
tcx.fn_sig(def_id).subst_identity()
|
||||
};
|
||||
|
||||
check_abi(tcx, id, span, fn_sig.abi());
|
||||
|
@ -503,7 +503,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||
|
||||
debug!("method_predicates after subst = {:?}", method_predicates);
|
||||
|
||||
let sig = self.tcx.bound_fn_sig(def_id);
|
||||
let sig = self.tcx.fn_sig(def_id);
|
||||
|
||||
let sig = sig.subst(self.tcx, all_substs);
|
||||
debug!("type scheme substituted, sig={:?}", sig);
|
||||
|
@ -144,7 +144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
None,
|
||||
)
|
||||
.map(|pick| {
|
||||
let sig = self.tcx.bound_fn_sig(pick.item.def_id);
|
||||
let sig = self.tcx.fn_sig(pick.item.def_id);
|
||||
sig.skip_binder().inputs().skip_binder().len().saturating_sub(1)
|
||||
})
|
||||
.unwrap_or(0);
|
||||
@ -399,7 +399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// N.B., instantiate late-bound regions before normalizing the
|
||||
// function signature so that normalization does not need to deal
|
||||
// with bound regions.
|
||||
let fn_sig = tcx.bound_fn_sig(def_id);
|
||||
let fn_sig = tcx.fn_sig(def_id);
|
||||
let fn_sig = fn_sig.subst(self.tcx, substs);
|
||||
let fn_sig =
|
||||
self.replace_bound_vars_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig);
|
||||
|
@ -922,7 +922,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
) -> bool {
|
||||
match method.kind {
|
||||
ty::AssocKind::Fn => {
|
||||
let fty = self.tcx.bound_fn_sig(method.def_id);
|
||||
let fty = self.tcx.fn_sig(method.def_id);
|
||||
self.probe(|_| {
|
||||
let substs = self.fresh_substs_for_item(self.span, method.def_id);
|
||||
let fty = fty.subst(self.tcx, substs);
|
||||
@ -1887,7 +1887,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn xform_method_sig(&self, method: DefId, substs: SubstsRef<'tcx>) -> ty::FnSig<'tcx> {
|
||||
let fn_sig = self.tcx.bound_fn_sig(method);
|
||||
let fn_sig = self.tcx.fn_sig(method);
|
||||
debug!(?fn_sig);
|
||||
|
||||
assert!(!substs.has_escaping_bound_vars());
|
||||
|
@ -1127,7 +1127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
ty::AssocKind::Const | ty::AssocKind::Type => rcvr_ty,
|
||||
ty::AssocKind::Fn => self
|
||||
.tcx
|
||||
.bound_fn_sig(item.def_id)
|
||||
.fn_sig(item.def_id)
|
||||
.subst_identity()
|
||||
.inputs()
|
||||
.skip_binder()
|
||||
@ -1265,7 +1265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&& let Some(assoc) = self.associated_value(*impl_did, item_name)
|
||||
&& assoc.kind == ty::AssocKind::Fn
|
||||
{
|
||||
let sig = self.tcx.bound_fn_sig(assoc.def_id).subst_identity();
|
||||
let sig = self.tcx.fn_sig(assoc.def_id).subst_identity();
|
||||
sig.inputs().skip_binder().get(0).and_then(|first| if first.peel_refs() == rcvr_ty.peel_refs() {
|
||||
None
|
||||
} else {
|
||||
@ -2099,7 +2099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// just changing the path.
|
||||
&& pick.item.fn_has_self_parameter
|
||||
&& let Some(self_ty) =
|
||||
self.tcx.bound_fn_sig(pick.item.def_id).subst_identity().inputs().skip_binder().get(0)
|
||||
self.tcx.fn_sig(pick.item.def_id).subst_identity().inputs().skip_binder().get(0)
|
||||
&& self_ty.is_ref()
|
||||
{
|
||||
let suggested_path = match deref_ty.kind() {
|
||||
@ -2352,7 +2352,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// implement the `AsRef` trait.
|
||||
let skip = skippable.contains(&did)
|
||||
|| (("Pin::new" == *pre) && (sym::as_ref == item_name.name))
|
||||
|| inputs_len.map_or(false, |inputs_len| pick.item.kind == ty::AssocKind::Fn && self.tcx.bound_fn_sig(pick.item.def_id).skip_binder().skip_binder().inputs().len() != inputs_len);
|
||||
|| inputs_len.map_or(false, |inputs_len| pick.item.kind == ty::AssocKind::Fn && self.tcx.fn_sig(pick.item.def_id).skip_binder().skip_binder().inputs().len() != inputs_len);
|
||||
// Make sure the method is defined for the *actual* receiver: we don't
|
||||
// want to treat `Box<Self>` as a receiver if it only works because of
|
||||
// an autoderef to `&self`
|
||||
@ -2731,7 +2731,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
// check the method arguments number
|
||||
if let Ok(pick) = probe &&
|
||||
let fn_sig = self.tcx.bound_fn_sig(pick.item.def_id) &&
|
||||
let fn_sig = self.tcx.fn_sig(pick.item.def_id) &&
|
||||
let fn_args = fn_sig.skip_binder().skip_binder().inputs() &&
|
||||
fn_args.len() == args.len() + 1 {
|
||||
err.span_suggestion_verbose(
|
||||
|
@ -1345,8 +1345,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
(ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => {
|
||||
let sig1 = self.tcx.bound_fn_sig(*did1).subst(self.tcx, substs1);
|
||||
let sig2 = self.tcx.bound_fn_sig(*did2).subst(self.tcx, substs2);
|
||||
let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1);
|
||||
let sig2 = self.tcx.fn_sig(*did2).subst(self.tcx, substs2);
|
||||
let mut values = self.cmp_fn_sig(&sig1, &sig2);
|
||||
let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did1, substs1));
|
||||
let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did2, substs2));
|
||||
@ -1357,7 +1357,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
(ty::FnDef(did1, substs1), ty::FnPtr(sig2)) => {
|
||||
let sig1 = self.tcx.bound_fn_sig(*did1).subst(self.tcx, substs1);
|
||||
let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1);
|
||||
let mut values = self.cmp_fn_sig(&sig1, sig2);
|
||||
values.0.push_highlighted(format!(
|
||||
" {{{}}}",
|
||||
@ -1367,7 +1367,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
(ty::FnPtr(sig1), ty::FnDef(did2, substs2)) => {
|
||||
let sig2 = self.tcx.bound_fn_sig(*did2).subst(self.tcx, substs2);
|
||||
let sig2 = self.tcx.fn_sig(*did2).subst(self.tcx, substs2);
|
||||
let mut values = self.cmp_fn_sig(sig1, &sig2);
|
||||
values.1.push_normal(format!(
|
||||
" {{{}}}",
|
||||
|
@ -65,7 +65,7 @@ pub fn find_param_with_region<'tcx>(
|
||||
|
||||
let owner_id = hir.body_owner(body_id);
|
||||
let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap();
|
||||
let poly_fn_sig = tcx.bound_fn_sig(id).subst_identity();
|
||||
let poly_fn_sig = tcx.fn_sig(id).subst_identity();
|
||||
|
||||
let fn_sig = tcx.liberate_late_bound_regions(id, poly_fn_sig);
|
||||
let body = hir.body(body_id);
|
||||
|
@ -1225,7 +1225,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
|
||||
fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl<'_>) {
|
||||
let def_id = self.cx.tcx.hir().local_def_id(id);
|
||||
let sig = self.cx.tcx.bound_fn_sig(def_id.into()).subst_identity();
|
||||
let sig = self.cx.tcx.fn_sig(def_id).subst_identity();
|
||||
let sig = self.cx.tcx.erase_late_bound_regions(sig);
|
||||
|
||||
for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) {
|
||||
|
@ -1093,7 +1093,7 @@ fn should_encode_trait_impl_trait_tys(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
// of the trait fn to look for any RPITITs, but that's kinda doing a lot
|
||||
// of work. We can probably remove this when we refactor RPITITs to be
|
||||
// associated types.
|
||||
tcx.bound_fn_sig(trait_item_def_id).subst_identity().skip_binder().output().walk().any(|arg| {
|
||||
tcx.fn_sig(trait_item_def_id).subst_identity().skip_binder().output().walk().any(|arg| {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
&& let ty::Alias(ty::Projection, data) = ty.kind()
|
||||
&& tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder
|
||||
@ -1628,7 +1628,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
ty::Closure(_, substs) => {
|
||||
let constness = self.tcx.constness(def_id.to_def_id());
|
||||
self.tables.constness.set(def_id.to_def_id().index, constness);
|
||||
record!(self.tables.fn_sig[def_id.to_def_id()] <- substs.as_closure().sig());
|
||||
record!(self.tables.fn_sig[def_id.to_def_id()] <- ty::EarlyBinder(substs.as_closure().sig()));
|
||||
}
|
||||
|
||||
_ => bug!("closure that is neither generator nor closure"),
|
||||
|
@ -369,7 +369,7 @@ define_tables! {
|
||||
super_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>,
|
||||
type_of: Table<DefIndex, LazyValue<Ty<'static>>>,
|
||||
variances_of: Table<DefIndex, LazyArray<ty::Variance>>,
|
||||
fn_sig: Table<DefIndex, LazyValue<ty::PolyFnSig<'static>>>,
|
||||
fn_sig: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::PolyFnSig<'static>>>>,
|
||||
codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>,
|
||||
impl_trait_ref: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::TraitRef<'static>>>>,
|
||||
const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>,
|
||||
|
@ -814,7 +814,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
/// Computes the signature of the function.
|
||||
query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> {
|
||||
query fn_sig(key: DefId) -> ty::EarlyBinder<ty::PolyFnSig<'tcx>> {
|
||||
desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { key.is_local() }
|
||||
separate_provide_extern
|
||||
|
@ -79,7 +79,7 @@ impl AssocItem {
|
||||
// late-bound regions, and we don't want method signatures to show up
|
||||
// `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound
|
||||
// regions just fine, showing `fn(&MyType)`.
|
||||
tcx.bound_fn_sig(self.def_id).subst_identity().skip_binder().to_string()
|
||||
tcx.fn_sig(self.def_id).subst_identity().skip_binder().to_string()
|
||||
}
|
||||
ty::AssocKind::Type => format!("type {};", self.name),
|
||||
ty::AssocKind::Const => {
|
||||
|
@ -459,7 +459,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> Option<Instance<'tcx>> {
|
||||
debug!("resolve_for_vtable(def_id={:?}, substs={:?})", def_id, substs);
|
||||
let fn_sig = tcx.bound_fn_sig(def_id).subst_identity();
|
||||
let fn_sig = tcx.fn_sig(def_id).subst_identity();
|
||||
let is_vtable_shim = !fn_sig.inputs().skip_binder().is_empty()
|
||||
&& fn_sig.input(0).skip_binder().is_param(0)
|
||||
&& tcx.generics_of(def_id).has_self;
|
||||
|
@ -675,7 +675,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
p!(")")
|
||||
}
|
||||
ty::FnDef(def_id, substs) => {
|
||||
let sig = self.tcx().bound_fn_sig(def_id).subst(self.tcx(), substs);
|
||||
let sig = self.tcx().fn_sig(def_id).subst(self.tcx(), substs);
|
||||
p!(print(sig), " {{", print_value_path(def_id, substs), "}}");
|
||||
}
|
||||
ty::FnPtr(ref bare_fn) => p!(print(bare_fn)),
|
||||
|
@ -2059,7 +2059,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
|
||||
pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
|
||||
match self.kind() {
|
||||
FnDef(def_id, substs) => tcx.bound_fn_sig(*def_id).subst(tcx, substs),
|
||||
FnDef(def_id, substs) => tcx.fn_sig(*def_id).subst(tcx, substs),
|
||||
FnPtr(f) => *f,
|
||||
Error(_) => {
|
||||
// ignore errors (#54954)
|
||||
|
@ -643,10 +643,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
ty::EarlyBinder(self.collect_return_position_impl_trait_in_trait_tys(def_id))
|
||||
}
|
||||
|
||||
pub fn bound_fn_sig(self, def_id: DefId) -> ty::EarlyBinder<ty::PolyFnSig<'tcx>> {
|
||||
ty::EarlyBinder(self.fn_sig(def_id))
|
||||
}
|
||||
|
||||
pub fn bound_explicit_item_bounds(
|
||||
self,
|
||||
def_id: DefId,
|
||||
@ -1315,10 +1311,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
|
||||
/// Determines whether an item is an intrinsic by Abi.
|
||||
pub fn is_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
matches!(
|
||||
tcx.bound_fn_sig(def_id).skip_binder().abi(),
|
||||
Abi::RustIntrinsic | Abi::PlatformIntrinsic
|
||||
)
|
||||
matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut ty::query::Providers) {
|
||||
|
@ -637,9 +637,7 @@ fn construct_error(
|
||||
|
||||
let ty = tcx.ty_error();
|
||||
let num_params = match body_owner_kind {
|
||||
hir::BodyOwnerKind::Fn => {
|
||||
tcx.bound_fn_sig(def.into()).skip_binder().inputs().skip_binder().len()
|
||||
}
|
||||
hir::BodyOwnerKind::Fn => tcx.fn_sig(def).skip_binder().inputs().skip_binder().len(),
|
||||
hir::BodyOwnerKind::Closure => {
|
||||
let ty = tcx.type_of(def);
|
||||
match ty.kind() {
|
||||
|
@ -79,8 +79,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
|
||||
for bound in bounds {
|
||||
if let Some(bound_ty) = self.is_pointer_trait(&bound.kind().skip_binder()) {
|
||||
// Get the argument types as they appear in the function signature.
|
||||
let arg_defs =
|
||||
self.tcx.bound_fn_sig(def_id).subst_identity().skip_binder().inputs();
|
||||
let arg_defs = self.tcx.fn_sig(def_id).subst_identity().skip_binder().inputs();
|
||||
for (arg_num, arg_def) in arg_defs.iter().enumerate() {
|
||||
// For all types reachable from the argument type in the fn sig
|
||||
for generic_inner_ty in arg_def.walk() {
|
||||
@ -162,7 +161,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.lint_root;
|
||||
let fn_sig = self.tcx.bound_fn_sig(fn_id).skip_binder();
|
||||
let fn_sig = self.tcx.fn_sig(fn_id).skip_binder();
|
||||
let unsafety = fn_sig.unsafety().prefix_str();
|
||||
let abi = match fn_sig.abi() {
|
||||
Abi::Rust => String::from(""),
|
||||
|
@ -331,7 +331,7 @@ impl<'tcx> Inliner<'tcx> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, substs);
|
||||
let fn_sig = self.tcx.fn_sig(def_id).subst(self.tcx, substs);
|
||||
let source_info = SourceInfo { span: fn_span, ..terminator.source_info };
|
||||
|
||||
return Some(CallSite { callee, fn_sig, block: bb, target, source_info });
|
||||
|
@ -152,7 +152,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
|
||||
} else {
|
||||
InternalSubsts::identity_for_item(tcx, def_id)
|
||||
};
|
||||
let sig = tcx.bound_fn_sig(def_id).subst(tcx, substs);
|
||||
let sig = tcx.fn_sig(def_id).subst(tcx, substs);
|
||||
let sig = tcx.erase_late_bound_regions(sig);
|
||||
let span = tcx.def_span(def_id);
|
||||
|
||||
@ -363,7 +363,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
|
||||
// we must subst the self_ty because it's
|
||||
// otherwise going to be TySelf and we can't index
|
||||
// or access fields of a Place of type TySelf.
|
||||
let sig = tcx.bound_fn_sig(def_id).subst(tcx, &[self_ty.into()]);
|
||||
let sig = tcx.fn_sig(def_id).subst(tcx, &[self_ty.into()]);
|
||||
let sig = tcx.erase_late_bound_regions(sig);
|
||||
let span = tcx.def_span(def_id);
|
||||
|
||||
@ -606,7 +606,7 @@ fn build_call_shim<'tcx>(
|
||||
};
|
||||
|
||||
let def_id = instance.def_id();
|
||||
let sig = tcx.bound_fn_sig(def_id);
|
||||
let sig = tcx.fn_sig(def_id);
|
||||
let sig = sig.map_bound(|sig| tcx.erase_late_bound_regions(sig));
|
||||
|
||||
assert_eq!(sig_substs.is_some(), !instance.has_polymorphic_mir_body());
|
||||
@ -799,7 +799,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> {
|
||||
|
||||
// Normalize the sig.
|
||||
let sig = tcx
|
||||
.bound_fn_sig(ctor_id)
|
||||
.fn_sig(ctor_id)
|
||||
.subst_identity()
|
||||
.no_bound_vars()
|
||||
.expect("LBR in ADT constructor signature");
|
||||
|
@ -1296,7 +1296,7 @@ impl<'v> RootCollector<'_, 'v> {
|
||||
};
|
||||
|
||||
let start_def_id = self.tcx.require_lang_item(LangItem::Start, None);
|
||||
let main_ret_ty = self.tcx.bound_fn_sig(main_def_id).subst_identity().output();
|
||||
let main_ret_ty = self.tcx.fn_sig(main_def_id).subst_identity().output();
|
||||
|
||||
// Given that `main()` has no arguments,
|
||||
// then its return type cannot have
|
||||
|
@ -198,7 +198,7 @@ where
|
||||
// Something like `fn() -> Priv {my_func}` is considered a private type even if
|
||||
// `my_func` is public, so we need to visit signatures.
|
||||
if let ty::FnDef(..) = ty.kind() {
|
||||
tcx.bound_fn_sig(def_id).subst_identity().visit_with(self)?;
|
||||
tcx.fn_sig(def_id).subst_identity().visit_with(self)?;
|
||||
}
|
||||
// Inherent static methods don't have self type in substs.
|
||||
// Something like `fn() {my_method}` type of the method
|
||||
|
@ -395,7 +395,7 @@ fn virtual_call_violation_for_method<'tcx>(
|
||||
trait_def_id: DefId,
|
||||
method: &ty::AssocItem,
|
||||
) -> Option<MethodViolationCode> {
|
||||
let sig = tcx.bound_fn_sig(method.def_id).subst_identity();
|
||||
let sig = tcx.fn_sig(method.def_id).subst_identity();
|
||||
|
||||
// The method's first parameter must be named `self`
|
||||
if !method.fn_has_self_parameter {
|
||||
|
@ -269,7 +269,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
|
||||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
|
||||
let sig = self.interner.tcx.bound_fn_sig(def_id);
|
||||
let sig = self.interner.tcx.fn_sig(def_id);
|
||||
let (inputs_and_output, iobinders, _) = crate::chalk::lowering::collect_bound_vars(
|
||||
self.interner,
|
||||
self.interner.tcx,
|
||||
|
@ -41,7 +41,7 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
// We normalize the `fn_sig` again after substituting at a later point.
|
||||
let mut sig = match *ty.kind() {
|
||||
ty::FnDef(def_id, substs) => tcx
|
||||
.bound_fn_sig(def_id)
|
||||
.fn_sig(def_id)
|
||||
.map_bound(|fn_sig| {
|
||||
tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig)
|
||||
})
|
||||
|
@ -9,12 +9,12 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
||||
fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> {
|
||||
match tcx.def_kind(def_id) {
|
||||
DefKind::Fn => {
|
||||
let sig = tcx.bound_fn_sig(def_id).skip_binder();
|
||||
let sig = tcx.fn_sig(def_id).skip_binder();
|
||||
let liberated_sig = tcx.liberate_late_bound_regions(def_id, sig);
|
||||
liberated_sig.inputs_and_output
|
||||
}
|
||||
DefKind::AssocFn => {
|
||||
let sig = tcx.bound_fn_sig(def_id).skip_binder();
|
||||
let sig = tcx.fn_sig(def_id).skip_binder();
|
||||
let liberated_sig = tcx.liberate_late_bound_regions(def_id, sig);
|
||||
let mut assumed_wf_types: Vec<_> =
|
||||
tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into();
|
||||
|
@ -299,7 +299,7 @@ fn well_formed_types_in_env(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Predica
|
||||
// In an fn, we assume that the arguments and all their constituents are
|
||||
// well-formed.
|
||||
NodeKind::Fn => {
|
||||
let fn_sig = tcx.bound_fn_sig(def_id).subst_identity();
|
||||
let fn_sig = tcx.fn_sig(def_id).subst_identity();
|
||||
let fn_sig = tcx.liberate_late_bound_regions(def_id, fn_sig);
|
||||
|
||||
inputs.extend(fn_sig.inputs().iter().flat_map(|ty| ty.walk()));
|
||||
|
@ -251,7 +251,7 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
|
||||
}
|
||||
|
||||
fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> Box<clean::Function> {
|
||||
let sig = cx.tcx.bound_fn_sig(did).subst_identity();
|
||||
let sig = cx.tcx.fn_sig(did).subst_identity();
|
||||
|
||||
let late_bound_regions = sig.bound_vars().into_iter().filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(_, name)) if name != kw::UnderscoreLifetime => {
|
||||
|
@ -1230,7 +1230,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
|
||||
}
|
||||
}
|
||||
ty::AssocKind::Fn => {
|
||||
let sig = tcx.bound_fn_sig(assoc_item.def_id).subst_identity();
|
||||
let sig = tcx.fn_sig(assoc_item.def_id).subst_identity();
|
||||
|
||||
let late_bound_regions = sig.bound_vars().into_iter().filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(_, name))
|
||||
|
@ -665,7 +665,7 @@ impl Item {
|
||||
tcx: TyCtxt<'_>,
|
||||
asyncness: hir::IsAsync,
|
||||
) -> hir::FnHeader {
|
||||
let sig = tcx.bound_fn_sig(def_id).skip_binder();
|
||||
let sig = tcx.fn_sig(def_id).skip_binder();
|
||||
let constness =
|
||||
if tcx.is_const_fn(def_id) && is_unstable_const_fn(tcx, def_id).is_none() {
|
||||
hir::Constness::Const
|
||||
@ -677,7 +677,7 @@ impl Item {
|
||||
let header = match *self.kind {
|
||||
ItemKind::ForeignFunctionItem(_) => {
|
||||
let def_id = self.item_id.as_def_id().unwrap();
|
||||
let abi = tcx.bound_fn_sig(def_id).skip_binder().abi();
|
||||
let abi = tcx.fn_sig(def_id).skip_binder().abi();
|
||||
hir::FnHeader {
|
||||
unsafety: if abi == Abi::RustIntrinsic {
|
||||
intrinsic_operation_unsafety(tcx, self.item_id.as_def_id().unwrap())
|
||||
|
@ -17,7 +17,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
|
||||
&& let ExprKind::MethodCall(method_name, receiver, [], _) = cast_expr.peel_blocks().kind
|
||||
&& method_name.ident.name == rustc_span::sym::as_ptr
|
||||
&& let Some(as_ptr_did) = cx.typeck_results().type_dependent_def_id(cast_expr.peel_blocks().hir_id)
|
||||
&& let as_ptr_sig = cx.tcx.bound_fn_sig(as_ptr_did).subst_identity()
|
||||
&& let as_ptr_sig = cx.tcx.fn_sig(as_ptr_did).subst_identity()
|
||||
&& let Some(first_param_ty) = as_ptr_sig.skip_binder().inputs().iter().next()
|
||||
&& let ty::Ref(_, _, Mutability::Not) = first_param_ty.kind()
|
||||
&& let Some(recv) = snippet_opt(cx, receiver.span)
|
||||
|
@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
|
||||
|
||||
ExprKind::MethodCall(_, receiver, args, _) => {
|
||||
if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) {
|
||||
let fn_sig = self.cx.tcx.bound_fn_sig(def_id).subst_identity().skip_binder();
|
||||
let fn_sig = self.cx.tcx.fn_sig(def_id).subst_identity().skip_binder();
|
||||
for (expr, bound) in iter::zip(std::iter::once(*receiver).chain(args.iter()), fn_sig.inputs()) {
|
||||
self.ty_bounds.push((*bound).into());
|
||||
self.visit_expr(expr);
|
||||
@ -215,7 +215,7 @@ fn fn_sig_opt<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<PolyFnSig<'
|
||||
let node_ty = cx.typeck_results().node_type_opt(hir_id)?;
|
||||
// We can't use `Ty::fn_sig` because it automatically performs substs, this may result in FNs.
|
||||
match node_ty.kind() {
|
||||
ty::FnDef(def_id, _) => Some(cx.tcx.bound_fn_sig(*def_id).subst_identity()),
|
||||
ty::FnDef(def_id, _) => Some(cx.tcx.fn_sig(*def_id).subst_identity()),
|
||||
ty::FnPtr(fn_sig) => Some(*fn_sig),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ fn walk_parents<'tcx>(
|
||||
}) if span.ctxt() == ctxt => {
|
||||
let output = cx
|
||||
.tcx
|
||||
.erase_late_bound_regions(cx.tcx.bound_fn_sig(owner_id.to_def_id()).subst_identity().output());
|
||||
.erase_late_bound_regions(cx.tcx.fn_sig(owner_id).subst_identity().output());
|
||||
Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
|
||||
},
|
||||
|
||||
@ -791,7 +791,7 @@ fn walk_parents<'tcx>(
|
||||
} else {
|
||||
let output = cx
|
||||
.tcx
|
||||
.erase_late_bound_regions(cx.tcx.bound_fn_sig(cx.tcx.hir().local_def_id(owner_id).into()).subst_identity().output());
|
||||
.erase_late_bound_regions(cx.tcx.fn_sig(cx.tcx.hir().local_def_id(owner_id)).subst_identity().output());
|
||||
ty_auto_deref_stability(cx, output, precedence).position_for_result(cx)
|
||||
},
|
||||
)
|
||||
@ -858,7 +858,7 @@ fn walk_parents<'tcx>(
|
||||
&& let subs = cx
|
||||
.typeck_results()
|
||||
.node_substs_opt(parent.hir_id).map(|subs| &subs[1..]).unwrap_or_default()
|
||||
&& let impl_ty = if cx.tcx.bound_fn_sig(id).subst_identity().skip_binder().inputs()[0].is_ref() {
|
||||
&& let impl_ty = if cx.tcx.fn_sig(id).subst_identity().skip_binder().inputs()[0].is_ref() {
|
||||
// Trait methods taking `&self`
|
||||
sub_ty
|
||||
} else {
|
||||
@ -879,7 +879,7 @@ fn walk_parents<'tcx>(
|
||||
return Some(Position::MethodReceiver);
|
||||
}
|
||||
args.iter().position(|arg| arg.hir_id == child_id).map(|i| {
|
||||
let ty = cx.tcx.bound_fn_sig(id).subst_identity().skip_binder().inputs()[i + 1];
|
||||
let ty = cx.tcx.fn_sig(id).subst_identity().skip_binder().inputs()[i + 1];
|
||||
// `e.hir_id == child_id` for https://github.com/rust-lang/rust-clippy/issues/9739
|
||||
// `method.args.is_none()` for https://github.com/rust-lang/rust-clippy/issues/9782
|
||||
if e.hir_id == child_id && method.args.is_none() && let ty::Param(param_ty) = ty.kind() {
|
||||
@ -896,7 +896,7 @@ fn walk_parents<'tcx>(
|
||||
} else {
|
||||
ty_auto_deref_stability(
|
||||
cx,
|
||||
cx.tcx.erase_late_bound_regions(cx.tcx.bound_fn_sig(id).subst_identity().input(i + 1)),
|
||||
cx.tcx.erase_late_bound_regions(cx.tcx.fn_sig(id).subst_identity().input(i + 1)),
|
||||
precedence,
|
||||
)
|
||||
.position_for_arg()
|
||||
@ -1093,7 +1093,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
|
||||
let sized_trait_def_id = cx.tcx.lang_items().sized_trait();
|
||||
|
||||
let Some(callee_def_id) = fn_def_id(cx, parent) else { return Position::Other(precedence) };
|
||||
let fn_sig = cx.tcx.bound_fn_sig(callee_def_id).subst_identity().skip_binder();
|
||||
let fn_sig = cx.tcx.fn_sig(callee_def_id).subst_identity().skip_binder();
|
||||
let substs_with_expr_ty = cx
|
||||
.typeck_results()
|
||||
.node_substs(if let ExprKind::Call(callee, _) = parent.kind {
|
||||
@ -1221,7 +1221,7 @@ fn has_ref_mut_self_method(cx: &LateContext<'_>, trait_def_id: DefId) -> bool {
|
||||
.in_definition_order()
|
||||
.any(|assoc_item| {
|
||||
if assoc_item.fn_has_self_parameter {
|
||||
let self_ty = cx.tcx.bound_fn_sig(assoc_item.def_id).subst_identity().skip_binder().inputs()[0];
|
||||
let self_ty = cx.tcx.fn_sig(assoc_item.def_id).subst_identity().skip_binder().inputs()[0];
|
||||
matches!(self_ty.kind(), ty::Ref(_, _, Mutability::Mut))
|
||||
} else {
|
||||
false
|
||||
|
@ -58,7 +58,7 @@ fn check_raw_ptr<'tcx>(
|
||||
},
|
||||
hir::ExprKind::MethodCall(_, recv, args, _) => {
|
||||
let def_id = typeck.type_dependent_def_id(e.hir_id).unwrap();
|
||||
if cx.tcx.bound_fn_sig(def_id).skip_binder().skip_binder().unsafety == hir::Unsafety::Unsafe {
|
||||
if cx.tcx.fn_sig(def_id).skip_binder().skip_binder().unsafety == hir::Unsafety::Unsafe {
|
||||
check_arg(cx, &raw_ptrs, recv);
|
||||
for arg in args {
|
||||
check_arg(cx, &raw_ptrs, arg);
|
||||
|
@ -21,7 +21,7 @@ fn result_err_ty<'tcx>(
|
||||
) -> Option<(&'tcx hir::Ty<'tcx>, Ty<'tcx>)> {
|
||||
if !in_external_macro(cx.sess(), item_span)
|
||||
&& let hir::FnRetTy::Return(hir_ty) = decl.output
|
||||
&& let ty = cx.tcx.erase_late_bound_regions(cx.tcx.bound_fn_sig(id.into()).subst_identity().output())
|
||||
&& let ty = cx.tcx.erase_late_bound_regions(cx.tcx.fn_sig(id).subst_identity().output())
|
||||
&& is_type_diagnostic_item(cx, ty, sym::Result)
|
||||
&& let ty::Adt(_, substs) = ty.kind()
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
|
||||
.expect("Failed to get trait ID of `Display`!");
|
||||
|
||||
// Get the real type of 'self'
|
||||
let self_type = cx.tcx.bound_fn_sig(item.owner_id.to_def_id()).skip_binder().input(0);
|
||||
let self_type = cx.tcx.fn_sig(item.owner_id).skip_binder().input(0);
|
||||
let self_type = self_type.skip_binder().peel_refs();
|
||||
|
||||
// Emit either a warning or an error
|
||||
|
@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator {
|
||||
|
||||
fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefId) {
|
||||
if sig.decl.implicit_self.has_implicit_self() {
|
||||
let ret_ty = cx.tcx.erase_late_bound_regions(cx.tcx.bound_fn_sig(fn_id.into()).subst_identity().output());
|
||||
let ret_ty = cx.tcx.erase_late_bound_regions(cx.tcx.fn_sig(fn_id).subst_identity().output());
|
||||
let ret_ty = cx
|
||||
.tcx
|
||||
.try_normalize_erasing_regions(cx.param_env, ret_ty)
|
||||
|
@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
|
||||
if let Some(local_id) = ty_id.as_local();
|
||||
let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id);
|
||||
if !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id);
|
||||
if let Some(output) = parse_len_output(cx, cx.tcx.bound_fn_sig(item.owner_id.to_def_id()).subst_identity().skip_binder());
|
||||
if let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).subst_identity().skip_binder());
|
||||
then {
|
||||
let (name, kind) = match cx.tcx.hir().find(ty_hir_id) {
|
||||
Some(Node::ForeignItem(x)) => (x.ident.name, "extern type"),
|
||||
@ -196,7 +196,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
|
||||
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: Symbol) -> bool {
|
||||
item.ident.name == name
|
||||
&& if let AssocItemKind::Fn { has_self } = item.kind {
|
||||
has_self && { cx.tcx.bound_fn_sig(item.id.owner_id.to_def_id()).skip_binder().inputs().skip_binder().len() == 1 }
|
||||
has_self && { cx.tcx.fn_sig(item.id.owner_id).skip_binder().inputs().skip_binder().len() == 1 }
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@ -224,7 +224,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
|
||||
.any(|i| {
|
||||
i.kind == ty::AssocKind::Fn
|
||||
&& i.fn_has_self_parameter
|
||||
&& cx.tcx.bound_fn_sig(i.def_id).skip_binder().inputs().skip_binder().len() == 1
|
||||
&& cx.tcx.fn_sig(i.def_id).skip_binder().inputs().skip_binder().len() == 1
|
||||
});
|
||||
|
||||
if !is_empty_method_found {
|
||||
@ -342,7 +342,7 @@ fn check_for_is_empty<'tcx>(
|
||||
),
|
||||
Some(is_empty)
|
||||
if !(is_empty.fn_has_self_parameter
|
||||
&& check_is_empty_sig(cx.tcx.bound_fn_sig(is_empty.def_id).subst_identity().skip_binder(), self_kind, output)) =>
|
||||
&& check_is_empty_sig(cx.tcx.fn_sig(is_empty.def_id).subst_identity().skip_binder(), self_kind, output)) =>
|
||||
{
|
||||
(
|
||||
format!(
|
||||
@ -473,7 +473,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
/// Gets an `AssocItem` and return true if it matches `is_empty(self)`.
|
||||
fn is_is_empty(cx: &LateContext<'_>, item: &ty::AssocItem) -> bool {
|
||||
if item.kind == ty::AssocKind::Fn {
|
||||
let sig = cx.tcx.bound_fn_sig(item.def_id).skip_binder();
|
||||
let sig = cx.tcx.fn_sig(item.def_id).skip_binder();
|
||||
let ty = sig.skip_binder();
|
||||
ty.inputs().len() == 1
|
||||
} else {
|
||||
|
@ -370,7 +370,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
|
||||
ExprKind::MethodCall(_, receiver, args, _) => {
|
||||
let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
|
||||
for (ty, expr) in iter::zip(
|
||||
self.cx.tcx.bound_fn_sig(def_id).subst_identity().inputs().skip_binder(),
|
||||
self.cx.tcx.fn_sig(def_id).subst_identity().inputs().skip_binder(),
|
||||
std::iter::once(receiver).chain(args.iter()),
|
||||
) {
|
||||
self.prefer_mutable = false;
|
||||
|
@ -104,7 +104,7 @@ fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
|
||||
let ty = cx.typeck_results().expr_ty(expr);
|
||||
|
||||
if let ty::FnDef(id, _) = *ty.kind() {
|
||||
if let Some(fn_type) = cx.tcx.bound_fn_sig(id).subst_identity().no_bound_vars() {
|
||||
if let Some(fn_type) = cx.tcx.fn_sig(id).subst_identity().no_bound_vars() {
|
||||
return is_unit_type(fn_type.output());
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ pub(super) fn check<'tcx>(
|
||||
if let hir::ExprKind::Path(ref p) = fun.kind {
|
||||
match cx.qpath_res(p, fun.hir_id) {
|
||||
hir::def::Res::Def(hir::def::DefKind::Fn | hir::def::DefKind::AssocFn, def_id) => matches!(
|
||||
cx.tcx.bound_fn_sig(def_id).subst_identity().output().skip_binder().kind(),
|
||||
cx.tcx.fn_sig(def_id).subst_identity().output().skip_binder().kind(),
|
||||
ty::Ref(re, ..) if re.is_static(),
|
||||
),
|
||||
_ => false,
|
||||
@ -84,7 +84,7 @@ pub(super) fn check<'tcx>(
|
||||
.type_dependent_def_id(arg.hir_id)
|
||||
.map_or(false, |method_id| {
|
||||
matches!(
|
||||
cx.tcx.bound_fn_sig(method_id).subst_identity().output().skip_binder().kind(),
|
||||
cx.tcx.fn_sig(method_id).subst_identity().output().skip_binder().kind(),
|
||||
ty::Ref(re, ..) if re.is_static()
|
||||
)
|
||||
})
|
||||
|
@ -3352,7 +3352,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
|
||||
let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }));
|
||||
if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind {
|
||||
let method_sig = cx.tcx.bound_fn_sig(impl_item.owner_id.to_def_id()).subst_identity();
|
||||
let method_sig = cx.tcx.fn_sig(impl_item.owner_id).subst_identity();
|
||||
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
|
||||
let first_arg_ty_opt = method_sig.inputs().iter().next().copied();
|
||||
// if this impl block implements a trait, lint in trait definition instead
|
||||
|
@ -137,7 +137,7 @@ pub(super) fn check<'tcx>(
|
||||
/// Checks if the given method call matches the expected signature of `([&[mut]] self) -> bool`
|
||||
fn is_is_empty_sig(cx: &LateContext<'_>, call_id: HirId) -> bool {
|
||||
cx.typeck_results().type_dependent_def_id(call_id).map_or(false, |id| {
|
||||
let sig = cx.tcx.bound_fn_sig(id).subst_identity().skip_binder();
|
||||
let sig = cx.tcx.fn_sig(id).subst_identity().skip_binder();
|
||||
sig.inputs().len() == 1 && sig.output().is_bool()
|
||||
})
|
||||
}
|
||||
@ -165,7 +165,7 @@ fn iterates_same_ty<'tcx>(cx: &LateContext<'tcx>, iter_ty: Ty<'tcx>, collect_ty:
|
||||
fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -> bool {
|
||||
let typeck = cx.typeck_results();
|
||||
if let Some(id) = typeck.type_dependent_def_id(call_id)
|
||||
&& let sig = cx.tcx.bound_fn_sig(id).subst_identity()
|
||||
&& let sig = cx.tcx.fn_sig(id).subst_identity()
|
||||
&& sig.skip_binder().output().is_bool()
|
||||
&& let [_, search_ty] = *sig.skip_binder().inputs()
|
||||
&& let ty::Ref(_, search_ty, Mutability::Not) = *cx.tcx.erase_late_bound_regions(sig.rebind(search_ty)).kind()
|
||||
|
@ -246,7 +246,7 @@ fn check_other_call_arg<'tcx>(
|
||||
if_chain! {
|
||||
if let Some((maybe_call, maybe_arg)) = skip_addr_of_ancestors(cx, expr);
|
||||
if let Some((callee_def_id, _, recv, call_args)) = get_callee_substs_and_args(cx, maybe_call);
|
||||
let fn_sig = cx.tcx.bound_fn_sig(callee_def_id).subst_identity().skip_binder();
|
||||
let fn_sig = cx.tcx.fn_sig(callee_def_id).subst_identity().skip_binder();
|
||||
if let Some(i) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == maybe_arg.hir_id);
|
||||
if let Some(input) = fn_sig.inputs().get(i);
|
||||
let (input, n_refs) = peel_mid_ty_refs(*input);
|
||||
@ -386,7 +386,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
|
||||
Node::Expr(parent_expr) => {
|
||||
if let Some((callee_def_id, call_substs, recv, call_args)) = get_callee_substs_and_args(cx, parent_expr)
|
||||
{
|
||||
let fn_sig = cx.tcx.bound_fn_sig(callee_def_id).subst_identity().skip_binder();
|
||||
let fn_sig = cx.tcx.fn_sig(callee_def_id).subst_identity().skip_binder();
|
||||
if let Some(arg_index) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == expr.hir_id)
|
||||
&& let Some(param_ty) = fn_sig.inputs().get(arg_index)
|
||||
&& let ty::Param(ParamTy { index: param_index , ..}) = param_ty.kind()
|
||||
|
@ -138,7 +138,7 @@ impl MutableKeyType {
|
||||
|
||||
fn check_sig(&self, cx: &LateContext<'_>, item_hir_id: hir::HirId, decl: &hir::FnDecl<'_>) {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(item_hir_id);
|
||||
let fn_sig = cx.tcx.bound_fn_sig(fn_def_id.into()).subst_identity();
|
||||
let fn_sig = cx.tcx.fn_sig(fn_def_id).subst_identity();
|
||||
for (hir_ty, ty) in iter::zip(decl.inputs, fn_sig.inputs().skip_binder()) {
|
||||
self.check_ty_(cx, hir_ty.span, *ty);
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||
ctx
|
||||
};
|
||||
|
||||
let fn_sig = cx.tcx.bound_fn_sig(fn_def_id.into()).subst_identity();
|
||||
let fn_sig = cx.tcx.fn_sig(fn_def_id).subst_identity();
|
||||
let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig);
|
||||
|
||||
for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() {
|
||||
|
@ -143,7 +143,7 @@ impl<'tcx> PassByRefOrValue {
|
||||
return;
|
||||
}
|
||||
|
||||
let fn_sig = cx.tcx.bound_fn_sig(def_id.into()).subst_identity();
|
||||
let fn_sig = cx.tcx.fn_sig(def_id).subst_identity();
|
||||
let fn_body = cx.enclosing_body.map(|id| cx.tcx.hir().body(id));
|
||||
|
||||
// Gather all the lifetimes found in the output type which may affect whether
|
||||
|
@ -164,7 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||
check_mut_from_ref(cx, sig, None);
|
||||
for arg in check_fn_args(
|
||||
cx,
|
||||
cx.tcx.bound_fn_sig(item.owner_id.to_def_id()).subst_identity().skip_binder().inputs(),
|
||||
cx.tcx.fn_sig(item.owner_id).subst_identity().skip_binder().inputs(),
|
||||
sig.decl.inputs,
|
||||
&[],
|
||||
)
|
||||
@ -217,7 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||
|
||||
check_mut_from_ref(cx, sig, Some(body));
|
||||
let decl = sig.decl;
|
||||
let sig = cx.tcx.bound_fn_sig(item_id.to_def_id()).subst_identity().skip_binder();
|
||||
let sig = cx.tcx.fn_sig(item_id).subst_identity().skip_binder();
|
||||
let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, body.params)
|
||||
.filter(|arg| !is_trait_item || arg.mutability() == Mutability::Not)
|
||||
.collect();
|
||||
@ -624,7 +624,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
|
||||
return;
|
||||
};
|
||||
|
||||
match *self.cx.tcx.bound_fn_sig(id).subst_identity().skip_binder().inputs()[i].peel_refs().kind() {
|
||||
match *self.cx.tcx.fn_sig(id).subst_identity().skip_binder().inputs()[i].peel_refs().kind() {
|
||||
ty::Dynamic(preds, _, _) if !matches_preds(self.cx, args.deref_ty.ty(self.cx), preds) => {
|
||||
set_skip_flag();
|
||||
},
|
||||
|
@ -287,7 +287,7 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
|
||||
if let Some(def_id) = fn_def_id(cx, e)
|
||||
&& cx
|
||||
.tcx
|
||||
.bound_fn_sig(def_id)
|
||||
.fn_sig(def_id)
|
||||
.subst_identity()
|
||||
.skip_binder()
|
||||
.output()
|
||||
|
@ -76,7 +76,7 @@ fn get_projection_pred<'tcx>(
|
||||
fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Vec<(usize, String)> {
|
||||
let mut args_to_check = Vec::new();
|
||||
if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) {
|
||||
let fn_sig = cx.tcx.bound_fn_sig(def_id).subst_identity();
|
||||
let fn_sig = cx.tcx.fn_sig(def_id).subst_identity();
|
||||
let generics = cx.tcx.predicates_of(def_id);
|
||||
let fn_mut_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().fn_mut_trait());
|
||||
let ord_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.get_diagnostic_item(sym::Ord));
|
||||
|
@ -156,7 +156,7 @@ fn needs_inferred_result_ty(
|
||||
},
|
||||
_ => return false,
|
||||
};
|
||||
let sig = cx.tcx.bound_fn_sig(id).subst_identity().skip_binder();
|
||||
let sig = cx.tcx.fn_sig(id).subst_identity().skip_binder();
|
||||
if let ty::Param(output_ty) = *sig.output().kind() {
|
||||
let args: Vec<&Expr<'_>> = if let Some(receiver) = receiver {
|
||||
std::iter::once(receiver).chain(args.iter()).collect()
|
||||
|
@ -146,7 +146,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||
.associated_item(impl_item.owner_id)
|
||||
.trait_item_def_id
|
||||
.expect("impl method matches a trait method");
|
||||
let trait_method_sig = cx.tcx.bound_fn_sig(trait_method).subst_identity();
|
||||
let trait_method_sig = cx.tcx.fn_sig(trait_method).subst_identity();
|
||||
let trait_method_sig = cx.tcx.erase_late_bound_regions(trait_method_sig);
|
||||
|
||||
// `impl_inputs_outputs` is an iterator over the types (`hir::Ty`) declared in the
|
||||
|
@ -79,7 +79,7 @@ fn fn_eagerness(cx: &LateContext<'_>, fn_id: DefId, name: Symbol, have_one_arg:
|
||||
&& subs.types().all(|x| matches!(x.peel_refs().kind(), ty::Param(_)))
|
||||
{
|
||||
// Limit the function to either `(self) -> bool` or `(&self) -> bool`
|
||||
match &**cx.tcx.bound_fn_sig(fn_id).subst_identity().skip_binder().inputs_and_output {
|
||||
match &**cx.tcx.fn_sig(fn_id).subst_identity().skip_binder().inputs_and_output {
|
||||
[arg, res] if !arg.is_mutable_ptr() && arg.peel_refs() == ty && res.is_bool() => NoChange,
|
||||
_ => Lazy,
|
||||
}
|
||||
|
@ -1379,7 +1379,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>(
|
||||
.chain(args.iter())
|
||||
.position(|arg| arg.hir_id == id)?;
|
||||
let id = cx.typeck_results().type_dependent_def_id(e.hir_id)?;
|
||||
let ty = cx.tcx.bound_fn_sig(id).subst_identity().skip_binder().inputs()[i];
|
||||
let ty = cx.tcx.fn_sig(id).subst_identity().skip_binder().inputs()[i];
|
||||
ty_is_fn_once_param(cx.tcx, ty, cx.tcx.param_env(id).caller_bounds()).then_some(())
|
||||
},
|
||||
_ => None,
|
||||
@ -1580,14 +1580,14 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
|
||||
/// Convenience function to get the return type of a function.
|
||||
pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
|
||||
let ret_ty = cx.tcx.bound_fn_sig(fn_def_id.into()).subst_identity().output();
|
||||
let ret_ty = cx.tcx.fn_sig(fn_def_id).subst_identity().output();
|
||||
cx.tcx.erase_late_bound_regions(ret_ty)
|
||||
}
|
||||
|
||||
/// Convenience function to get the nth argument type of a function.
|
||||
pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId, nth: usize) -> Ty<'tcx> {
|
||||
let fn_def_id = cx.tcx.hir().local_def_id(fn_item);
|
||||
let arg = cx.tcx.bound_fn_sig(fn_def_id.into()).subst_identity().input(nth);
|
||||
let arg = cx.tcx.fn_sig(fn_def_id).subst_identity().input(nth);
|
||||
cx.tcx.erase_late_bound_regions(arg)
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub fn is_min_const_fn<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, msrv: &Msrv)
|
||||
// impl trait is gone in MIR, so check the return type manually
|
||||
check_ty(
|
||||
tcx,
|
||||
tcx.bound_fn_sig(def_id).subst_identity().output().skip_binder(),
|
||||
tcx.fn_sig(def_id).subst_identity().output().skip_binder(),
|
||||
body.local_decls.iter().next().unwrap().source_info.span,
|
||||
)?;
|
||||
|
||||
|
@ -885,7 +885,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> {
|
||||
.cx
|
||||
.typeck_results()
|
||||
.type_dependent_def_id(parent_expr.hir_id)
|
||||
.map(|did| self.cx.tcx.bound_fn_sig(did).subst_identity().skip_binder())
|
||||
.map(|did| self.cx.tcx.fn_sig(did).subst_identity().skip_binder())
|
||||
{
|
||||
std::iter::once(receiver)
|
||||
.chain(call_args.iter())
|
||||
|
@ -628,7 +628,7 @@ impl<'tcx> ExprFnSig<'tcx> {
|
||||
/// If the expression is function like, get the signature for it.
|
||||
pub fn expr_sig<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<ExprFnSig<'tcx>> {
|
||||
if let Res::Def(DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::AssocFn, id) = path_res(cx, expr) {
|
||||
Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst_identity(), Some(id)))
|
||||
Some(ExprFnSig::Sig(cx.tcx.fn_sig(id).subst_identity(), Some(id)))
|
||||
} else {
|
||||
ty_sig(cx, cx.typeck_results().expr_ty_adjusted(expr).peel_refs())
|
||||
}
|
||||
@ -646,7 +646,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
|
||||
.and_then(|id| cx.tcx.hir().fn_decl_by_hir_id(cx.tcx.hir().local_def_id_to_hir_id(id)));
|
||||
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
|
||||
},
|
||||
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst(cx.tcx, subs), Some(id))),
|
||||
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.fn_sig(id).subst(cx.tcx, subs), Some(id))),
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
|
||||
sig_from_bounds(cx, ty, cx.tcx.item_bounds(def_id).subst(cx.tcx, substs), cx.tcx.opt_parent(def_id))
|
||||
},
|
||||
|
@ -392,12 +392,12 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
|
||||
.cx
|
||||
.typeck_results()
|
||||
.type_dependent_def_id(e.hir_id)
|
||||
.map_or(false, |id| self.cx.tcx.bound_fn_sig(id).skip_binder().unsafety() == Unsafety::Unsafe) =>
|
||||
.map_or(false, |id| self.cx.tcx.fn_sig(id).skip_binder().unsafety() == Unsafety::Unsafe) =>
|
||||
{
|
||||
self.is_unsafe = true;
|
||||
},
|
||||
ExprKind::Call(func, _) => match *self.cx.typeck_results().expr_ty(func).peel_refs().kind() {
|
||||
ty::FnDef(id, _) if self.cx.tcx.bound_fn_sig(id).skip_binder().unsafety() == Unsafety::Unsafe => self.is_unsafe = true,
|
||||
ty::FnDef(id, _) if self.cx.tcx.fn_sig(id).skip_binder().unsafety() == Unsafety::Unsafe => self.is_unsafe = true,
|
||||
ty::FnPtr(sig) if sig.unsafety() == Unsafety::Unsafe => self.is_unsafe = true,
|
||||
_ => walk_expr(self, e),
|
||||
},
|
||||
|
@ -357,7 +357,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
|
||||
match entry_type {
|
||||
EntryFnType::Main { .. } => {
|
||||
let start_id = tcx.lang_items().start_fn().unwrap();
|
||||
let main_ret_ty = tcx.bound_fn_sig(entry_id).subst_identity().output();
|
||||
let main_ret_ty = tcx.fn_sig(entry_id).subst_identity().output();
|
||||
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
|
||||
let start_instance = ty::Instance::resolve(
|
||||
tcx,
|
||||
|
Loading…
Reference in New Issue
Block a user