1
Fork 0

change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add EarlyBinder to fn_sig in metadata

This commit is contained in:
Kyle Matsuda 2023-01-18 16:52:47 -07:00
parent e982971ff2
commit c2414dfaa4
80 changed files with 142 additions and 152 deletions

View file

@ -2599,7 +2599,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
match ty.kind() { match ty.kind() {
ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig( ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig(
self.mir_def_id(), 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, _ => None,
} }

View file

@ -1136,7 +1136,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&& let self_ty = infcx.replace_bound_vars_with_fresh_vars( && let self_ty = infcx.replace_bound_vars_with_fresh_vars(
fn_call_span, fn_call_span,
LateBoundRegionConversionTime::FnCall, 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() && infcx.can_eq(self.param_env, ty, self_ty).is_ok()
{ {

View file

@ -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 // 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). // (as it's created inside the body itself, not passed in from outside).
if let DefiningTy::FnDef(def_id, _) = defining_ty { 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( let va_list_did = self.infcx.tcx.require_lang_item(
LangItem::VaList, LangItem::VaList,
Some(self.infcx.tcx.def_span(self.mir_def.did)), Some(self.infcx.tcx.def_span(self.mir_def.did)),
@ -665,7 +665,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
} }
DefiningTy::FnDef(def_id, _) => { 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); let sig = indices.fold_to_region_vids(tcx, sig);
sig.inputs_and_output() sig.inputs_and_output()
} }

View file

@ -46,7 +46,7 @@ pub(crate) fn maybe_create_entry_wrapper(
is_main_fn: bool, is_main_fn: bool,
sigpipe: u8, 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, // Given that `main()` has no arguments,
// then its return type cannot have // then its return type cannot have
// late-bound regions, since late-bound // late-bound regions, since late-bound

View file

@ -441,7 +441,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
// the WebAssembly specification, which has this feature. This won't be // the WebAssembly specification, which has this feature. This won't be
// needed when LLVM enables this `multivalue` feature by default. // needed when LLVM enables this `multivalue` feature by default.
if !cx.tcx.is_closure(instance.def_id()) { 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 { if abi == Abi::Wasm {
function_features.push("+multivalue".to_string()); function_features.push("+multivalue".to_string());
} }

View file

@ -436,7 +436,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
cx.type_func(&[], cx.type_int()) 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, // Given that `main()` has no arguments,
// then its return type cannot have // then its return type cannot have
// late-bound regions, since late-bound // late-bound regions, since late-bound

View file

@ -214,7 +214,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
} }
} else if attr.has_name(sym::cmse_nonsecure_entry) { } else if attr.has_name(sym::cmse_nonsecure_entry) {
if validate_fn_only_attr(attr.span) 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!( struct_span_err!(
tcx.sess, tcx.sess,
@ -234,7 +234,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
} else if attr.has_name(sym::track_caller) { } else if attr.has_name(sym::track_caller) {
if !tcx.is_closure(did.to_def_id()) if !tcx.is_closure(did.to_def_id())
&& validate_fn_only_attr(attr.span) && 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") struct_span_err!(tcx.sess, attr.span, E0737, "`#[track_caller]` requires Rust ABI")
.emit(); .emit();
@ -266,7 +266,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
} }
} else if attr.has_name(sym::target_feature) { } else if attr.has_name(sym::target_feature) {
if !tcx.is_closure(did.to_def_id()) 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 { if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
// The `#[target_feature]` attribute is allowed on // The `#[target_feature]` attribute is allowed on

View file

@ -64,7 +64,7 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
&& match tcx.lookup_const_stability(def_id) { && match tcx.lookup_const_stability(def_id) {
Some(stab) => { Some(stab) => {
if cfg!(debug_assertions) && stab.promotable { if cfg!(debug_assertions) && stab.promotable {
let sig = tcx.bound_fn_sig(def_id); let sig = tcx.fn_sig(def_id);
assert_eq!( assert_eq!(
sig.skip_binder().unsafety(), sig.skip_binder().unsafety(),
hir::Unsafety::Normal, hir::Unsafety::Normal,

View file

@ -72,7 +72,7 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
let ty::Closure(_, substs) = ty.kind() else { bug!("type_of closure not ty::Closure") }; let ty::Closure(_, substs) = ty.kind() else { bug!("type_of closure not ty::Closure") };
substs.as_closure().sig() substs.as_closure().sig()
} else { } else {
self.tcx.bound_fn_sig(did).subst_identity() self.tcx.fn_sig(did).subst_identity()
} }
} }
} }

View file

@ -3140,7 +3140,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
trait_ref.def_id, 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, tcx,
trait_ref.substs.extend_to(tcx, assoc.def_id, |param, _| tcx.mk_param_from_def(param)), trait_ref.substs.extend_to(tcx, assoc.def_id, |param, _| tcx.mk_param_from_def(param)),
); );

View file

@ -249,7 +249,7 @@ fn compare_method_predicate_entailment<'tcx>(
let unnormalized_impl_sig = infcx.replace_bound_vars_with_fresh_vars( let unnormalized_impl_sig = infcx.replace_bound_vars_with_fresh_vars(
impl_m_span, impl_m_span,
infer::HigherRankedType, 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)); 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); let impl_sig = ocx.normalize(&norm_cause, param_env, unnormalized_impl_sig);
debug!("compare_impl_method: impl_fty={:?}", 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); 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, // 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. // Map late-bound regions from trait to impl, so the names are right.
let mapping = std::iter::zip( let mapping = std::iter::zip(
tcx.bound_fn_sig(trait_m.def_id).subst_identity().bound_vars(), tcx.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(impl_m.def_id).subst_identity().bound_vars(),
) )
.filter_map(|(impl_bv, trait_bv)| { .filter_map(|(impl_bv, trait_bv)| {
if let ty::BoundVariableKind::Region(impl_bv) = impl_bv if let ty::BoundVariableKind::Region(impl_bv) = impl_bv
@ -540,7 +540,7 @@ fn compare_asyncness<'tcx>(
trait_item_span: Option<Span>, trait_item_span: Option<Span>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
if tcx.asyncness(trait_m.def_id) == hir::IsAsync::Async { 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, ..) => { ty::Alias(ty::Opaque, ..) => {
// allow both `async fn foo()` and `fn foo() -> impl Future` // 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( infcx.replace_bound_vars_with_fresh_vars(
return_span, return_span,
infer::HigherRankedType, 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()?; 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 let unnormalized_trait_sig = tcx
.liberate_late_bound_regions( .liberate_late_bound_regions(
impl_m.def_id, 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); .fold_with(&mut collector);
let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig); 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::ImplContainer => impl_trait_ref.self_ty(),
ty::TraitContainer => tcx.types.self_param, 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 param_env = ty::ParamEnv::reveal_all();
let infcx = tcx.infer_ctxt().build(); let infcx = tcx.infer_ctxt().build();
@ -1348,8 +1348,8 @@ fn compare_number_of_method_arguments<'tcx>(
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
trait_item_span: Option<Span>, trait_item_span: Option<Span>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
let impl_m_fty = tcx.bound_fn_sig(impl_m.def_id); let impl_m_fty = tcx.fn_sig(impl_m.def_id);
let trait_m_fty = tcx.bound_fn_sig(trait_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 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(); let impl_number_args = impl_m_fty.skip_binder().inputs().skip_binder().len();

View file

@ -58,7 +58,12 @@ fn equate_intrinsic_type<'tcx>(
let fty = tcx.mk_fn_ptr(sig); let fty = tcx.mk_fn_ptr(sig);
let it_def_id = it.owner_id.def_id; let it_def_id = it.owner_id.def_id;
let cause = ObligationCause::new(it.span, it_def_id, ObligationCauseCode::IntrinsicType); 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,
);
} }
} }

View file

@ -445,7 +445,7 @@ fn suggestion_signature(assoc: &ty::AssocItem, tcx: TyCtxt<'_>) -> String {
// regions just fine, showing `fn(&MyType)`. // regions just fine, showing `fn(&MyType)`.
fn_sig_suggestion( fn_sig_suggestion(
tcx, 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), assoc.ident(tcx),
tcx.predicates_of(assoc.def_id), tcx.predicates_of(assoc.def_id),
assoc, assoc,

View file

@ -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. // `Self::Iter<'a>` is a GAT we want to gather any potential missing bounds from.
let sig: ty::FnSig<'_> = tcx.liberate_late_bound_regions( let sig: ty::FnSig<'_> = tcx.liberate_late_bound_regions(
item_def_id.to_def_id(), 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( gather_gat_bounds(
tcx, tcx,
@ -1018,7 +1018,7 @@ fn check_associated_item(
wfcx.register_wf_obligation(span, loc, ty.into()); wfcx.register_wf_obligation(span, loc, ty.into());
} }
ty::AssocKind::Fn => { 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"); let hir_sig = sig_if_method.expect("bad signature for method");
check_fn_or_method( check_fn_or_method(
wfcx, wfcx,
@ -1203,7 +1203,7 @@ fn check_item_fn(
decl: &hir::FnDecl<'_>, decl: &hir::FnDecl<'_>,
) { ) {
enter_wf_checking_ctxt(tcx, span, def_id, |wfcx| { 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); 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 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 = tcx.liberate_late_bound_regions(method.def_id, sig);
let sig = wfcx.normalize(span, None, sig); let sig = wfcx.normalize(span, None, sig);

View file

@ -1087,7 +1087,7 @@ pub fn get_infer_ret_ty<'hir>(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir
} }
#[instrument(level = "debug", skip(tcx))] #[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::Node::*;
use rustc_hir::*; 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()); 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 { TraitItem(hir::TraitItem {
kind: TraitItemKind::Fn(sig, TraitFn::Provided(_)), kind: TraitItemKind::Fn(sig, TraitFn::Provided(_)),
generics, generics,
@ -1169,7 +1169,8 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
x => { x => {
bug!("unexpected sort of node in fn_sig(): {:?}", x); bug!("unexpected sort of node in fn_sig(): {:?}", x);
} }
} };
ty::EarlyBinder(output)
} }
fn infer_return_ty_for_fn_sig<'tcx>( fn infer_return_ty_for_fn_sig<'tcx>(

View file

@ -868,7 +868,7 @@ fn infer_placeholder_type<'a>(
match ty.kind() { match ty.kind() {
ty::FnDef(def_id, _) => { 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 // FIXME: non-capturing closures should also suggest a function pointer
ty::Closure(..) | ty::Generator(..) => { ty::Closure(..) | ty::Generator(..) => {

View file

@ -182,7 +182,7 @@ fn require_same_types<'tcx>(
} }
fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { 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); let main_span = tcx.def_span(main_def_id);
fn main_fn_diagnostics_def_id(tcx: TyCtxt<'_>, def_id: DefId, sp: Span) -> LocalDefId { 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, ObligationCauseCode::StartFunctionType,
), ),
se_ty, 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()),
); );
} }
_ => { _ => {

View file

@ -121,7 +121,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
ty::FnDef(..) => { ty::FnDef(..) => {
self.add_constraints_from_sig( self.add_constraints_from_sig(
current_item, current_item,
tcx.bound_fn_sig(def_id.into()).subst_identity(), tcx.fn_sig(def_id).subst_identity(),
self.covariant, self.covariant,
); );
} }

View file

@ -367,7 +367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> Ty<'tcx> { ) -> Ty<'tcx> {
let (fn_sig, def_id) = match *callee_ty.kind() { let (fn_sig, def_id) = match *callee_ty.kind() {
ty::FnDef(def_id, subst) => { 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 // Unit testing: function items annotated with
// `#[rustc_evaluate_where_clauses]` trigger special output // `#[rustc_evaluate_where_clauses]` trigger special output

View file

@ -299,7 +299,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{ {
// We special case methods, because they can influence inference through the // We special case methods, because they can influence inference through the
// call's arguments and we can provide a more explicit span. // 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 def_self_ty = sig.input(0).skip_binder();
let rcvr_ty = self.node_ty(rcvr.hir_id); let rcvr_ty = self.node_ty(rcvr.hir_id);
// Get the evaluated type *after* calling the method call, so that the influence // 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 match self
.tcx .tcx
.bound_fn_sig(m.def_id) .fn_sig(m.def_id)
.subst_identity() .subst_identity()
.input(0) .input(0)
.skip_binder() .skip_binder()
@ -1043,13 +1043,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
match method.kind { match method.kind {
ty::AssocKind::Fn => { ty::AssocKind::Fn => {
method.fn_has_self_parameter method.fn_has_self_parameter
&& self && self.tcx.fn_sig(method.def_id).skip_binder().inputs().skip_binder().len()
.tcx
.bound_fn_sig(method.def_id)
.skip_binder()
.inputs()
.skip_binder()
.len()
== 1 == 1
} }
_ => false, _ => false,

View file

@ -542,7 +542,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::FnDef(did, ..) = *ty.kind() { if let ty::FnDef(did, ..) = *ty.kind() {
let fn_sig = ty.fn_sig(tcx); 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 && tcx.item_name(did) == sym::transmute
{ {
let from = fn_sig.inputs().skip_binder()[0]; let from = fn_sig.inputs().skip_binder()[0];

View file

@ -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() { 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) fcx.astconv().ty_of_fn(id, header.unsafety, header.abi, decl, None, None)
} else { } 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()); check_abi(tcx, id, span, fn_sig.abi());

View file

@ -503,7 +503,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
debug!("method_predicates after subst = {:?}", method_predicates); 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); let sig = sig.subst(self.tcx, all_substs);
debug!("type scheme substituted, sig={:?}", sig); debug!("type scheme substituted, sig={:?}", sig);

View file

@ -144,7 +144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None, None,
) )
.map(|pick| { .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) sig.skip_binder().inputs().skip_binder().len().saturating_sub(1)
}) })
.unwrap_or(0); .unwrap_or(0);
@ -399,7 +399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// N.B., instantiate late-bound regions before normalizing the // N.B., instantiate late-bound regions before normalizing the
// function signature so that normalization does not need to deal // function signature so that normalization does not need to deal
// with bound regions. // 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 = fn_sig.subst(self.tcx, substs);
let fn_sig = let fn_sig =
self.replace_bound_vars_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig); self.replace_bound_vars_with_fresh_vars(obligation.cause.span, infer::FnCall, fn_sig);

View file

@ -922,7 +922,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
) -> bool { ) -> bool {
match method.kind { match method.kind {
ty::AssocKind::Fn => { ty::AssocKind::Fn => {
let fty = self.tcx.bound_fn_sig(method.def_id); let fty = self.tcx.fn_sig(method.def_id);
self.probe(|_| { self.probe(|_| {
let substs = self.fresh_substs_for_item(self.span, method.def_id); let substs = self.fresh_substs_for_item(self.span, method.def_id);
let fty = fty.subst(self.tcx, substs); let fty = fty.subst(self.tcx, substs);
@ -1887,7 +1887,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
#[instrument(level = "debug", skip(self))] #[instrument(level = "debug", skip(self))]
fn xform_method_sig(&self, method: DefId, substs: SubstsRef<'tcx>) -> ty::FnSig<'tcx> { 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); debug!(?fn_sig);
assert!(!substs.has_escaping_bound_vars()); assert!(!substs.has_escaping_bound_vars());

View file

@ -1127,7 +1127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::AssocKind::Const | ty::AssocKind::Type => rcvr_ty, ty::AssocKind::Const | ty::AssocKind::Type => rcvr_ty,
ty::AssocKind::Fn => self ty::AssocKind::Fn => self
.tcx .tcx
.bound_fn_sig(item.def_id) .fn_sig(item.def_id)
.subst_identity() .subst_identity()
.inputs() .inputs()
.skip_binder() .skip_binder()
@ -1265,7 +1265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& let Some(assoc) = self.associated_value(*impl_did, item_name) && let Some(assoc) = self.associated_value(*impl_did, item_name)
&& assoc.kind == ty::AssocKind::Fn && 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() { sig.inputs().skip_binder().get(0).and_then(|first| if first.peel_refs() == rcvr_ty.peel_refs() {
None None
} else { } else {
@ -2099,7 +2099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// just changing the path. // just changing the path.
&& pick.item.fn_has_self_parameter && pick.item.fn_has_self_parameter
&& let Some(self_ty) = && 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() && self_ty.is_ref()
{ {
let suggested_path = match deref_ty.kind() { let suggested_path = match deref_ty.kind() {
@ -2352,7 +2352,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// implement the `AsRef` trait. // implement the `AsRef` trait.
let skip = skippable.contains(&did) let skip = skippable.contains(&did)
|| (("Pin::new" == *pre) && (sym::as_ref == item_name.name)) || (("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 // 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 // want to treat `Box<Self>` as a receiver if it only works because of
// an autoderef to `&self` // an autoderef to `&self`
@ -2731,7 +2731,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// check the method arguments number // check the method arguments number
if let Ok(pick) = probe && 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() && let fn_args = fn_sig.skip_binder().skip_binder().inputs() &&
fn_args.len() == args.len() + 1 { fn_args.len() == args.len() + 1 {
err.span_suggestion_verbose( err.span_suggestion_verbose(

View file

@ -1345,8 +1345,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
} }
(ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => { (ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => {
let sig1 = self.tcx.bound_fn_sig(*did1).subst(self.tcx, substs1); let sig1 = self.tcx.fn_sig(*did1).subst(self.tcx, substs1);
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); let mut values = self.cmp_fn_sig(&sig1, &sig2);
let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did1, substs1)); let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did1, substs1));
let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did2, substs2)); 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)) => { (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); let mut values = self.cmp_fn_sig(&sig1, sig2);
values.0.push_highlighted(format!( values.0.push_highlighted(format!(
" {{{}}}", " {{{}}}",
@ -1367,7 +1367,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
} }
(ty::FnPtr(sig1), ty::FnDef(did2, substs2)) => { (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); let mut values = self.cmp_fn_sig(sig1, &sig2);
values.1.push_normal(format!( values.1.push_normal(format!(
" {{{}}}", " {{{}}}",

View file

@ -65,7 +65,7 @@ pub fn find_param_with_region<'tcx>(
let owner_id = hir.body_owner(body_id); let owner_id = hir.body_owner(body_id);
let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap(); 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 fn_sig = tcx.liberate_late_bound_regions(id, poly_fn_sig);
let body = hir.body(body_id); let body = hir.body(body_id);

View file

@ -1225,7 +1225,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl<'_>) { fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl<'_>) {
let def_id = self.cx.tcx.hir().local_def_id(id); 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); let sig = self.cx.tcx.erase_late_bound_regions(sig);
for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) { for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) {

View file

@ -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 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 // of work. We can probably remove this when we refactor RPITITs to be
// associated types. // 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() if let ty::GenericArgKind::Type(ty) = arg.unpack()
&& let ty::Alias(ty::Projection, data) = ty.kind() && let ty::Alias(ty::Projection, data) = ty.kind()
&& tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder && tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder
@ -1628,7 +1628,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
ty::Closure(_, substs) => { ty::Closure(_, substs) => {
let constness = self.tcx.constness(def_id.to_def_id()); let constness = self.tcx.constness(def_id.to_def_id());
self.tables.constness.set(def_id.to_def_id().index, constness); 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"), _ => bug!("closure that is neither generator nor closure"),

View file

@ -369,7 +369,7 @@ define_tables! {
super_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>, super_predicates_of: Table<DefIndex, LazyValue<ty::GenericPredicates<'static>>>,
type_of: Table<DefIndex, LazyValue<Ty<'static>>>, type_of: Table<DefIndex, LazyValue<Ty<'static>>>,
variances_of: Table<DefIndex, LazyArray<ty::Variance>>, 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>>, codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>,
impl_trait_ref: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::TraitRef<'static>>>>, impl_trait_ref: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::TraitRef<'static>>>>,
const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>, const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>,

View file

@ -814,7 +814,7 @@ rustc_queries! {
} }
/// Computes the signature of the function. /// 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) } desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
cache_on_disk_if { key.is_local() } cache_on_disk_if { key.is_local() }
separate_provide_extern separate_provide_extern

View file

@ -79,7 +79,7 @@ impl AssocItem {
// late-bound regions, and we don't want method signatures to show up // late-bound regions, and we don't want method signatures to show up
// `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound // `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound
// regions just fine, showing `fn(&MyType)`. // 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::Type => format!("type {};", self.name),
ty::AssocKind::Const => { ty::AssocKind::Const => {

View file

@ -459,7 +459,7 @@ impl<'tcx> Instance<'tcx> {
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
) -> Option<Instance<'tcx>> { ) -> Option<Instance<'tcx>> {
debug!("resolve_for_vtable(def_id={:?}, substs={:?})", def_id, substs); 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() let is_vtable_shim = !fn_sig.inputs().skip_binder().is_empty()
&& fn_sig.input(0).skip_binder().is_param(0) && fn_sig.input(0).skip_binder().is_param(0)
&& tcx.generics_of(def_id).has_self; && tcx.generics_of(def_id).has_self;

View file

@ -675,7 +675,7 @@ pub trait PrettyPrinter<'tcx>:
p!(")") p!(")")
} }
ty::FnDef(def_id, substs) => { 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), "}}"); p!(print(sig), " {{", print_value_path(def_id, substs), "}}");
} }
ty::FnPtr(ref bare_fn) => p!(print(bare_fn)), ty::FnPtr(ref bare_fn) => p!(print(bare_fn)),

View file

@ -2059,7 +2059,7 @@ impl<'tcx> Ty<'tcx> {
pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
match self.kind() { 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, FnPtr(f) => *f,
Error(_) => { Error(_) => {
// ignore errors (#54954) // ignore errors (#54954)

View file

@ -643,10 +643,6 @@ impl<'tcx> TyCtxt<'tcx> {
ty::EarlyBinder(self.collect_return_position_impl_trait_in_trait_tys(def_id)) 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( pub fn bound_explicit_item_bounds(
self, self,
def_id: DefId, 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. /// Determines whether an item is an intrinsic by Abi.
pub fn is_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool { pub fn is_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
matches!( matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic)
tcx.bound_fn_sig(def_id).skip_binder().abi(),
Abi::RustIntrinsic | Abi::PlatformIntrinsic
)
} }
pub fn provide(providers: &mut ty::query::Providers) { pub fn provide(providers: &mut ty::query::Providers) {

View file

@ -637,9 +637,7 @@ fn construct_error(
let ty = tcx.ty_error(); let ty = tcx.ty_error();
let num_params = match body_owner_kind { let num_params = match body_owner_kind {
hir::BodyOwnerKind::Fn => { hir::BodyOwnerKind::Fn => tcx.fn_sig(def).skip_binder().inputs().skip_binder().len(),
tcx.bound_fn_sig(def.into()).skip_binder().inputs().skip_binder().len()
}
hir::BodyOwnerKind::Closure => { hir::BodyOwnerKind::Closure => {
let ty = tcx.type_of(def); let ty = tcx.type_of(def);
match ty.kind() { match ty.kind() {

View file

@ -79,8 +79,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
for bound in bounds { for bound in bounds {
if let Some(bound_ty) = self.is_pointer_trait(&bound.kind().skip_binder()) { if let Some(bound_ty) = self.is_pointer_trait(&bound.kind().skip_binder()) {
// Get the argument types as they appear in the function signature. // Get the argument types as they appear in the function signature.
let arg_defs = let arg_defs = self.tcx.fn_sig(def_id).subst_identity().skip_binder().inputs();
self.tcx.bound_fn_sig(def_id).subst_identity().skip_binder().inputs();
for (arg_num, arg_def) in arg_defs.iter().enumerate() { for (arg_num, arg_def) in arg_defs.iter().enumerate() {
// For all types reachable from the argument type in the fn sig // For all types reachable from the argument type in the fn sig
for generic_inner_ty in arg_def.walk() { for generic_inner_ty in arg_def.walk() {
@ -162,7 +161,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
.as_ref() .as_ref()
.assert_crate_local() .assert_crate_local()
.lint_root; .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 unsafety = fn_sig.unsafety().prefix_str();
let abi = match fn_sig.abi() { let abi = match fn_sig.abi() {
Abi::Rust => String::from(""), Abi::Rust => String::from(""),

View file

@ -331,7 +331,7 @@ impl<'tcx> Inliner<'tcx> {
return None; 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 }; let source_info = SourceInfo { span: fn_span, ..terminator.source_info };
return Some(CallSite { callee, fn_sig, block: bb, target, source_info }); return Some(CallSite { callee, fn_sig, block: bb, target, source_info });

View file

@ -152,7 +152,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
} else { } else {
InternalSubsts::identity_for_item(tcx, def_id) 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 sig = tcx.erase_late_bound_regions(sig);
let span = tcx.def_span(def_id); let span = tcx.def_span(def_id);
@ -363,7 +363,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
// we must subst the self_ty because it's // we must subst the self_ty because it's
// otherwise going to be TySelf and we can't index // otherwise going to be TySelf and we can't index
// or access fields of a Place of type TySelf. // 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 sig = tcx.erase_late_bound_regions(sig);
let span = tcx.def_span(def_id); let span = tcx.def_span(def_id);
@ -606,7 +606,7 @@ fn build_call_shim<'tcx>(
}; };
let def_id = instance.def_id(); 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)); let sig = sig.map_bound(|sig| tcx.erase_late_bound_regions(sig));
assert_eq!(sig_substs.is_some(), !instance.has_polymorphic_mir_body()); 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. // Normalize the sig.
let sig = tcx let sig = tcx
.bound_fn_sig(ctor_id) .fn_sig(ctor_id)
.subst_identity() .subst_identity()
.no_bound_vars() .no_bound_vars()
.expect("LBR in ADT constructor signature"); .expect("LBR in ADT constructor signature");

View file

@ -1296,7 +1296,7 @@ impl<'v> RootCollector<'_, 'v> {
}; };
let start_def_id = self.tcx.require_lang_item(LangItem::Start, None); 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, // Given that `main()` has no arguments,
// then its return type cannot have // then its return type cannot have

View file

@ -198,7 +198,7 @@ where
// Something like `fn() -> Priv {my_func}` is considered a private type even if // Something like `fn() -> Priv {my_func}` is considered a private type even if
// `my_func` is public, so we need to visit signatures. // `my_func` is public, so we need to visit signatures.
if let ty::FnDef(..) = ty.kind() { 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. // Inherent static methods don't have self type in substs.
// Something like `fn() {my_method}` type of the method // Something like `fn() {my_method}` type of the method

View file

@ -395,7 +395,7 @@ fn virtual_call_violation_for_method<'tcx>(
trait_def_id: DefId, trait_def_id: DefId,
method: &ty::AssocItem, method: &ty::AssocItem,
) -> Option<MethodViolationCode> { ) -> 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` // The method's first parameter must be named `self`
if !method.fn_has_self_parameter { if !method.fn_has_self_parameter {

View file

@ -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 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( let (inputs_and_output, iobinders, _) = crate::chalk::lowering::collect_bound_vars(
self.interner, self.interner,
self.interner.tcx, self.interner.tcx,

View file

@ -41,7 +41,7 @@ fn fn_sig_for_fn_abi<'tcx>(
// We normalize the `fn_sig` again after substituting at a later point. // We normalize the `fn_sig` again after substituting at a later point.
let mut sig = match *ty.kind() { let mut sig = match *ty.kind() {
ty::FnDef(def_id, substs) => tcx ty::FnDef(def_id, substs) => tcx
.bound_fn_sig(def_id) .fn_sig(def_id)
.map_bound(|fn_sig| { .map_bound(|fn_sig| {
tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig) tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig)
}) })

View file

@ -9,12 +9,12 @@ pub fn provide(providers: &mut ty::query::Providers) {
fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> { fn assumed_wf_types(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List<Ty<'_>> {
match tcx.def_kind(def_id) { match tcx.def_kind(def_id) {
DefKind::Fn => { 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); let liberated_sig = tcx.liberate_late_bound_regions(def_id, sig);
liberated_sig.inputs_and_output liberated_sig.inputs_and_output
} }
DefKind::AssocFn => { 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 liberated_sig = tcx.liberate_late_bound_regions(def_id, sig);
let mut assumed_wf_types: Vec<_> = let mut assumed_wf_types: Vec<_> =
tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into(); tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into();

View file

@ -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 // In an fn, we assume that the arguments and all their constituents are
// well-formed. // well-formed.
NodeKind::Fn => { 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); let fn_sig = tcx.liberate_late_bound_regions(def_id, fn_sig);
inputs.extend(fn_sig.inputs().iter().flat_map(|ty| ty.walk())); inputs.extend(fn_sig.inputs().iter().flat_map(|ty| ty.walk()));

View file

@ -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> { 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 { let late_bound_regions = sig.bound_vars().into_iter().filter_map(|var| match var {
ty::BoundVariableKind::Region(ty::BrNamed(_, name)) if name != kw::UnderscoreLifetime => { ty::BoundVariableKind::Region(ty::BrNamed(_, name)) if name != kw::UnderscoreLifetime => {

View file

@ -1230,7 +1230,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
} }
} }
ty::AssocKind::Fn => { 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 { let late_bound_regions = sig.bound_vars().into_iter().filter_map(|var| match var {
ty::BoundVariableKind::Region(ty::BrNamed(_, name)) ty::BoundVariableKind::Region(ty::BrNamed(_, name))

View file

@ -665,7 +665,7 @@ impl Item {
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
asyncness: hir::IsAsync, asyncness: hir::IsAsync,
) -> hir::FnHeader { ) -> hir::FnHeader {
let sig = tcx.bound_fn_sig(def_id).skip_binder(); let sig = tcx.fn_sig(def_id).skip_binder();
let constness = let constness =
if tcx.is_const_fn(def_id) && is_unstable_const_fn(tcx, def_id).is_none() { if tcx.is_const_fn(def_id) && is_unstable_const_fn(tcx, def_id).is_none() {
hir::Constness::Const hir::Constness::Const
@ -677,7 +677,7 @@ impl Item {
let header = match *self.kind { let header = match *self.kind {
ItemKind::ForeignFunctionItem(_) => { ItemKind::ForeignFunctionItem(_) => {
let def_id = self.item_id.as_def_id().unwrap(); 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 { hir::FnHeader {
unsafety: if abi == Abi::RustIntrinsic { unsafety: if abi == Abi::RustIntrinsic {
intrinsic_operation_unsafety(tcx, self.item_id.as_def_id().unwrap()) intrinsic_operation_unsafety(tcx, self.item_id.as_def_id().unwrap())

View file

@ -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 && let ExprKind::MethodCall(method_name, receiver, [], _) = cast_expr.peel_blocks().kind
&& method_name.ident.name == rustc_span::sym::as_ptr && 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 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 Some(first_param_ty) = as_ptr_sig.skip_binder().inputs().iter().next()
&& let ty::Ref(_, _, Mutability::Not) = first_param_ty.kind() && let ty::Ref(_, _, Mutability::Not) = first_param_ty.kind()
&& let Some(recv) = snippet_opt(cx, receiver.span) && let Some(recv) = snippet_opt(cx, receiver.span)

View file

@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
ExprKind::MethodCall(_, receiver, args, _) => { ExprKind::MethodCall(_, receiver, args, _) => {
if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) { 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()) { for (expr, bound) in iter::zip(std::iter::once(*receiver).chain(args.iter()), fn_sig.inputs()) {
self.ty_bounds.push((*bound).into()); self.ty_bounds.push((*bound).into());
self.visit_expr(expr); 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)?; 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. // We can't use `Ty::fn_sig` because it automatically performs substs, this may result in FNs.
match node_ty.kind() { 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), ty::FnPtr(fn_sig) => Some(*fn_sig),
_ => None, _ => None,
} }

View file

@ -759,7 +759,7 @@ fn walk_parents<'tcx>(
}) if span.ctxt() == ctxt => { }) if span.ctxt() == ctxt => {
let output = cx let output = cx
.tcx .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)) Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
}, },
@ -791,7 +791,7 @@ fn walk_parents<'tcx>(
} else { } else {
let output = cx let output = cx
.tcx .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) ty_auto_deref_stability(cx, output, precedence).position_for_result(cx)
}, },
) )
@ -858,7 +858,7 @@ fn walk_parents<'tcx>(
&& let subs = cx && let subs = cx
.typeck_results() .typeck_results()
.node_substs_opt(parent.hir_id).map(|subs| &subs[1..]).unwrap_or_default() .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` // Trait methods taking `&self`
sub_ty sub_ty
} else { } else {
@ -879,7 +879,7 @@ fn walk_parents<'tcx>(
return Some(Position::MethodReceiver); return Some(Position::MethodReceiver);
} }
args.iter().position(|arg| arg.hir_id == child_id).map(|i| { 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 // `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 // `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() { 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 { } else {
ty_auto_deref_stability( ty_auto_deref_stability(
cx, 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, precedence,
) )
.position_for_arg() .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 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 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 let substs_with_expr_ty = cx
.typeck_results() .typeck_results()
.node_substs(if let ExprKind::Call(callee, _) = parent.kind { .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() .in_definition_order()
.any(|assoc_item| { .any(|assoc_item| {
if assoc_item.fn_has_self_parameter { 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)) matches!(self_ty.kind(), ty::Ref(_, _, Mutability::Mut))
} else { } else {
false false

View file

@ -58,7 +58,7 @@ fn check_raw_ptr<'tcx>(
}, },
hir::ExprKind::MethodCall(_, recv, args, _) => { hir::ExprKind::MethodCall(_, recv, args, _) => {
let def_id = typeck.type_dependent_def_id(e.hir_id).unwrap(); 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); check_arg(cx, &raw_ptrs, recv);
for arg in args { for arg in args {
check_arg(cx, &raw_ptrs, arg); check_arg(cx, &raw_ptrs, arg);

View file

@ -21,7 +21,7 @@ fn result_err_ty<'tcx>(
) -> Option<(&'tcx hir::Ty<'tcx>, Ty<'tcx>)> { ) -> Option<(&'tcx hir::Ty<'tcx>, Ty<'tcx>)> {
if !in_external_macro(cx.sess(), item_span) if !in_external_macro(cx.sess(), item_span)
&& let hir::FnRetTy::Return(hir_ty) = decl.output && 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) && is_type_diagnostic_item(cx, ty, sym::Result)
&& let ty::Adt(_, substs) = ty.kind() && let ty::Adt(_, substs) = ty.kind()
{ {

View file

@ -124,7 +124,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
.expect("Failed to get trait ID of `Display`!"); .expect("Failed to get trait ID of `Display`!");
// Get the real type of 'self' // 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(); let self_type = self_type.skip_binder().peel_refs();
// Emit either a warning or an error // Emit either a warning or an error

View file

@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator {
fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefId) { fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefId) {
if sig.decl.implicit_self.has_implicit_self() { 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 let ret_ty = cx
.tcx .tcx
.try_normalize_erasing_regions(cx.param_env, ret_ty) .try_normalize_erasing_regions(cx.param_env, ret_ty)

View file

@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
if let Some(local_id) = ty_id.as_local(); if let Some(local_id) = ty_id.as_local();
let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id); 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 !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 { then {
let (name, kind) = match cx.tcx.hir().find(ty_hir_id) { let (name, kind) = match cx.tcx.hir().find(ty_hir_id) {
Some(Node::ForeignItem(x)) => (x.ident.name, "extern type"), 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 { fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: Symbol) -> bool {
item.ident.name == name item.ident.name == name
&& if let AssocItemKind::Fn { has_self } = item.kind { && 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 { } else {
false false
} }
@ -224,7 +224,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
.any(|i| { .any(|i| {
i.kind == ty::AssocKind::Fn i.kind == ty::AssocKind::Fn
&& i.fn_has_self_parameter && 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 { if !is_empty_method_found {
@ -342,7 +342,7 @@ fn check_for_is_empty<'tcx>(
), ),
Some(is_empty) Some(is_empty)
if !(is_empty.fn_has_self_parameter 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!( 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)`. /// Gets an `AssocItem` and return true if it matches `is_empty(self)`.
fn is_is_empty(cx: &LateContext<'_>, item: &ty::AssocItem) -> bool { fn is_is_empty(cx: &LateContext<'_>, item: &ty::AssocItem) -> bool {
if item.kind == ty::AssocKind::Fn { 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(); let ty = sig.skip_binder();
ty.inputs().len() == 1 ty.inputs().len() == 1
} else { } else {

View file

@ -370,7 +370,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
ExprKind::MethodCall(_, receiver, args, _) => { ExprKind::MethodCall(_, receiver, args, _) => {
let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap(); let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
for (ty, expr) in iter::zip( 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()), std::iter::once(receiver).chain(args.iter()),
) { ) {
self.prefer_mutable = false; self.prefer_mutable = false;

View file

@ -104,7 +104,7 @@ fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
let ty = cx.typeck_results().expr_ty(expr); let ty = cx.typeck_results().expr_ty(expr);
if let ty::FnDef(id, _) = *ty.kind() { 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()); return is_unit_type(fn_type.output());
} }
} }

View file

@ -70,7 +70,7 @@ pub(super) fn check<'tcx>(
if let hir::ExprKind::Path(ref p) = fun.kind { if let hir::ExprKind::Path(ref p) = fun.kind {
match cx.qpath_res(p, fun.hir_id) { match cx.qpath_res(p, fun.hir_id) {
hir::def::Res::Def(hir::def::DefKind::Fn | hir::def::DefKind::AssocFn, def_id) => matches!( 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(), ty::Ref(re, ..) if re.is_static(),
), ),
_ => false, _ => false,
@ -84,7 +84,7 @@ pub(super) fn check<'tcx>(
.type_dependent_def_id(arg.hir_id) .type_dependent_def_id(arg.hir_id)
.map_or(false, |method_id| { .map_or(false, |method_id| {
matches!( 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() ty::Ref(re, ..) if re.is_static()
) )
}) })

View file

@ -3352,7 +3352,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })); 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 { 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 method_sig = cx.tcx.erase_late_bound_regions(method_sig);
let first_arg_ty_opt = method_sig.inputs().iter().next().copied(); let first_arg_ty_opt = method_sig.inputs().iter().next().copied();
// if this impl block implements a trait, lint in trait definition instead // if this impl block implements a trait, lint in trait definition instead

View file

@ -137,7 +137,7 @@ pub(super) fn check<'tcx>(
/// Checks if the given method call matches the expected signature of `([&[mut]] self) -> bool` /// 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 { fn is_is_empty_sig(cx: &LateContext<'_>, call_id: HirId) -> bool {
cx.typeck_results().type_dependent_def_id(call_id).map_or(false, |id| { 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() 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 { fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -> bool {
let typeck = cx.typeck_results(); let typeck = cx.typeck_results();
if let Some(id) = typeck.type_dependent_def_id(call_id) 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() && sig.skip_binder().output().is_bool()
&& let [_, search_ty] = *sig.skip_binder().inputs() && 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() && let ty::Ref(_, search_ty, Mutability::Not) = *cx.tcx.erase_late_bound_regions(sig.rebind(search_ty)).kind()

View file

@ -246,7 +246,7 @@ fn check_other_call_arg<'tcx>(
if_chain! { if_chain! {
if let Some((maybe_call, maybe_arg)) = skip_addr_of_ancestors(cx, expr); 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); 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(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); if let Some(input) = fn_sig.inputs().get(i);
let (input, n_refs) = peel_mid_ty_refs(*input); 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) => { Node::Expr(parent_expr) => {
if let Some((callee_def_id, call_substs, recv, call_args)) = get_callee_substs_and_args(cx, 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) 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 Some(param_ty) = fn_sig.inputs().get(arg_index)
&& let ty::Param(ParamTy { index: param_index , ..}) = param_ty.kind() && let ty::Param(ParamTy { index: param_index , ..}) = param_ty.kind()

View file

@ -138,7 +138,7 @@ impl MutableKeyType {
fn check_sig(&self, cx: &LateContext<'_>, item_hir_id: hir::HirId, decl: &hir::FnDecl<'_>) { 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_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()) { for (hir_ty, ty) in iter::zip(decl.inputs, fn_sig.inputs().skip_binder()) {
self.check_ty_(cx, hir_ty.span, *ty); self.check_ty_(cx, hir_ty.span, *ty);
} }

View file

@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
ctx 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); 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() { for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() {

View file

@ -143,7 +143,7 @@ impl<'tcx> PassByRefOrValue {
return; 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)); 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 // Gather all the lifetimes found in the output type which may affect whether

View file

@ -164,7 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
check_mut_from_ref(cx, sig, None); check_mut_from_ref(cx, sig, None);
for arg in check_fn_args( for arg in check_fn_args(
cx, 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, sig.decl.inputs,
&[], &[],
) )
@ -217,7 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
check_mut_from_ref(cx, sig, Some(body)); check_mut_from_ref(cx, sig, Some(body));
let decl = sig.decl; 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) let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, body.params)
.filter(|arg| !is_trait_item || arg.mutability() == Mutability::Not) .filter(|arg| !is_trait_item || arg.mutability() == Mutability::Not)
.collect(); .collect();
@ -624,7 +624,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
return; 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) => { ty::Dynamic(preds, _, _) if !matches_preds(self.cx, args.deref_ty.ty(self.cx), preds) => {
set_skip_flag(); set_skip_flag();
}, },

View file

@ -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) if let Some(def_id) = fn_def_id(cx, e)
&& cx && cx
.tcx .tcx
.bound_fn_sig(def_id) .fn_sig(def_id)
.subst_identity() .subst_identity()
.skip_binder() .skip_binder()
.output() .output()

View file

@ -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)> { fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Vec<(usize, String)> {
let mut args_to_check = Vec::new(); let mut args_to_check = Vec::new();
if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { 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 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 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)); let ord_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.get_diagnostic_item(sym::Ord));

View file

@ -156,7 +156,7 @@ fn needs_inferred_result_ty(
}, },
_ => return false, _ => 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() { if let ty::Param(output_ty) = *sig.output().kind() {
let args: Vec<&Expr<'_>> = if let Some(receiver) = receiver { let args: Vec<&Expr<'_>> = if let Some(receiver) = receiver {
std::iter::once(receiver).chain(args.iter()).collect() std::iter::once(receiver).chain(args.iter()).collect()

View file

@ -146,7 +146,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
.associated_item(impl_item.owner_id) .associated_item(impl_item.owner_id)
.trait_item_def_id .trait_item_def_id
.expect("impl method matches a trait method"); .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); 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 // `impl_inputs_outputs` is an iterator over the types (`hir::Ty`) declared in the

View file

@ -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(_))) && subs.types().all(|x| matches!(x.peel_refs().kind(), ty::Param(_)))
{ {
// Limit the function to either `(self) -> bool` or `(&self) -> bool` // 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, [arg, res] if !arg.is_mutable_ptr() && arg.peel_refs() == ty && res.is_bool() => NoChange,
_ => Lazy, _ => Lazy,
} }

View file

@ -1379,7 +1379,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>(
.chain(args.iter()) .chain(args.iter())
.position(|arg| arg.hir_id == id)?; .position(|arg| arg.hir_id == id)?;
let id = cx.typeck_results().type_dependent_def_id(e.hir_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(()) ty_is_fn_once_param(cx.tcx, ty, cx.tcx.param_env(id).caller_bounds()).then_some(())
}, },
_ => None, _ => 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. /// Convenience function to get the return type of a function.
pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> { 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 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) cx.tcx.erase_late_bound_regions(ret_ty)
} }
/// Convenience function to get the nth argument type of a function. /// 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> { 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 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) cx.tcx.erase_late_bound_regions(arg)
} }

View file

@ -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 // impl trait is gone in MIR, so check the return type manually
check_ty( check_ty(
tcx, 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, body.local_decls.iter().next().unwrap().source_info.span,
)?; )?;

View file

@ -885,7 +885,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> {
.cx .cx
.typeck_results() .typeck_results()
.type_dependent_def_id(parent_expr.hir_id) .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) std::iter::once(receiver)
.chain(call_args.iter()) .chain(call_args.iter())

View file

@ -628,7 +628,7 @@ impl<'tcx> ExprFnSig<'tcx> {
/// If the expression is function like, get the signature for it. /// If the expression is function like, get the signature for it.
pub fn expr_sig<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<ExprFnSig<'tcx>> { 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) { 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 { } else {
ty_sig(cx, cx.typeck_results().expr_ty_adjusted(expr).peel_refs()) 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))); .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())) 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, .. }) => { 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)) sig_from_bounds(cx, ty, cx.tcx.item_bounds(def_id).subst(cx.tcx, substs), cx.tcx.opt_parent(def_id))
}, },

View file

@ -392,12 +392,12 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
.cx .cx
.typeck_results() .typeck_results()
.type_dependent_def_id(e.hir_id) .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; self.is_unsafe = true;
}, },
ExprKind::Call(func, _) => match *self.cx.typeck_results().expr_ty(func).peel_refs().kind() { 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, ty::FnPtr(sig) if sig.unsafety() == Unsafety::Unsafe => self.is_unsafe = true,
_ => walk_expr(self, e), _ => walk_expr(self, e),
}, },

View file

@ -357,7 +357,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
match entry_type { match entry_type {
EntryFnType::Main { .. } => { EntryFnType::Main { .. } => {
let start_id = tcx.lang_items().start_fn().unwrap(); 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 main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
let start_instance = ty::Instance::resolve( let start_instance = ty::Instance::resolve(
tcx, tcx,