Skip to content

Commit e982971

Browse files
committed
replace usages of fn_sig query with bound_fn_sig
1 parent d7948c8 commit e982971

File tree

66 files changed

+147
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+147
-113
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25992599
match ty.kind() {
26002600
ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig(
26012601
self.mir_def_id(),
2602-
self.infcx.tcx.fn_sig(self.mir_def_id()),
2602+
self.infcx.tcx.bound_fn_sig(self.mir_def_id().into()).subst_identity(),
26032603
),
26042604
_ => None,
26052605
}

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11361136
&& let self_ty = infcx.replace_bound_vars_with_fresh_vars(
11371137
fn_call_span,
11381138
LateBoundRegionConversionTime::FnCall,
1139-
tcx.fn_sig(method_did).input(0),
1139+
tcx.bound_fn_sig(method_did).subst_identity().input(0),
11401140
)
11411141
&& infcx.can_eq(self.param_env, ty, self_ty).is_ok()
11421142
{

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
472472
// C-variadic fns also have a `VaList` input that's not listed in the signature
473473
// (as it's created inside the body itself, not passed in from outside).
474474
if let DefiningTy::FnDef(def_id, _) = defining_ty {
475-
if self.infcx.tcx.fn_sig(def_id).c_variadic() {
475+
if self.infcx.tcx.bound_fn_sig(def_id).skip_binder().c_variadic() {
476476
let va_list_did = self.infcx.tcx.require_lang_item(
477477
LangItem::VaList,
478478
Some(self.infcx.tcx.def_span(self.mir_def.did)),
@@ -665,7 +665,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
665665
}
666666

667667
DefiningTy::FnDef(def_id, _) => {
668-
let sig = tcx.fn_sig(def_id);
668+
let sig = tcx.bound_fn_sig(def_id).subst_identity();
669669
let sig = indices.fold_to_region_vids(tcx, sig);
670670
sig.inputs_and_output()
671671
}

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn maybe_create_entry_wrapper(
4646
is_main_fn: bool,
4747
sigpipe: u8,
4848
) {
49-
let main_ret_ty = tcx.fn_sig(rust_main_def_id).output();
49+
let main_ret_ty = tcx.bound_fn_sig(rust_main_def_id).subst_identity().output();
5050
// Given that `main()` has no arguments,
5151
// then its return type cannot have
5252
// late-bound regions, since late-bound

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
441441
// the WebAssembly specification, which has this feature. This won't be
442442
// needed when LLVM enables this `multivalue` feature by default.
443443
if !cx.tcx.is_closure(instance.def_id()) {
444-
let abi = cx.tcx.fn_sig(instance.def_id()).abi();
444+
let abi = cx.tcx.bound_fn_sig(instance.def_id()).skip_binder().abi();
445445
if abi == Abi::Wasm {
446446
function_features.push("+multivalue".to_string());
447447
}

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
214214
}
215215
} else if attr.has_name(sym::cmse_nonsecure_entry) {
216216
if validate_fn_only_attr(attr.span)
217-
&& !matches!(tcx.fn_sig(did).abi(), abi::Abi::C { .. })
217+
&& !matches!(tcx.bound_fn_sig(did.into()).skip_binder().abi(), abi::Abi::C { .. })
218218
{
219219
struct_span_err!(
220220
tcx.sess,
@@ -234,7 +234,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
234234
} else if attr.has_name(sym::track_caller) {
235235
if !tcx.is_closure(did.to_def_id())
236236
&& validate_fn_only_attr(attr.span)
237-
&& tcx.fn_sig(did).abi() != abi::Abi::Rust
237+
&& tcx.bound_fn_sig(did.into()).skip_binder().abi() != abi::Abi::Rust
238238
{
239239
struct_span_err!(tcx.sess, attr.span, E0737, "`#[track_caller]` requires Rust ABI")
240240
.emit();
@@ -266,7 +266,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
266266
}
267267
} else if attr.has_name(sym::target_feature) {
268268
if !tcx.is_closure(did.to_def_id())
269-
&& tcx.fn_sig(did).unsafety() == hir::Unsafety::Normal
269+
&& tcx.bound_fn_sig(did.into()).skip_binder().unsafety() == hir::Unsafety::Normal
270270
{
271271
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
272272
// The `#[target_feature]` attribute is allowed on

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
6464
&& match tcx.lookup_const_stability(def_id) {
6565
Some(stab) => {
6666
if cfg!(debug_assertions) && stab.promotable {
67-
let sig = tcx.fn_sig(def_id);
67+
let sig = tcx.bound_fn_sig(def_id);
6868
assert_eq!(
69-
sig.unsafety(),
69+
sig.skip_binder().unsafety(),
7070
hir::Unsafety::Normal,
7171
"don't mark const unsafe fns as promotable",
7272
// https://github.com/rust-lang/rust/pull/53851#issuecomment-418760682

compiler/rustc_const_eval/src/transform/check_consts/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
7272
let ty::Closure(_, substs) = ty.kind() else { bug!("type_of closure not ty::Closure") };
7373
substs.as_closure().sig()
7474
} else {
75-
self.tcx.fn_sig(did)
75+
self.tcx.bound_fn_sig(did).subst_identity()
7676
}
7777
}
7878
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn compare_method_predicate_entailment<'tcx>(
249249
let unnormalized_impl_sig = infcx.replace_bound_vars_with_fresh_vars(
250250
impl_m_span,
251251
infer::HigherRankedType,
252-
tcx.fn_sig(impl_m.def_id),
252+
tcx.bound_fn_sig(impl_m.def_id).subst_identity(),
253253
);
254254
let unnormalized_impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(unnormalized_impl_sig));
255255

@@ -422,8 +422,8 @@ fn extract_bad_args_for_implies_lint<'tcx>(
422422

423423
// Map late-bound regions from trait to impl, so the names are right.
424424
let mapping = std::iter::zip(
425-
tcx.fn_sig(trait_m.def_id).bound_vars(),
426-
tcx.fn_sig(impl_m.def_id).bound_vars(),
425+
tcx.bound_fn_sig(trait_m.def_id).subst_identity().bound_vars(),
426+
tcx.bound_fn_sig(impl_m.def_id).subst_identity().bound_vars(),
427427
)
428428
.filter_map(|(impl_bv, trait_bv)| {
429429
if let ty::BoundVariableKind::Region(impl_bv) = impl_bv
@@ -540,7 +540,7 @@ fn compare_asyncness<'tcx>(
540540
trait_item_span: Option<Span>,
541541
) -> Result<(), ErrorGuaranteed> {
542542
if tcx.asyncness(trait_m.def_id) == hir::IsAsync::Async {
543-
match tcx.fn_sig(impl_m.def_id).skip_binder().output().kind() {
543+
match tcx.bound_fn_sig(impl_m.def_id).subst_identity().skip_binder().output().kind() {
544544
ty::Alias(ty::Opaque, ..) => {
545545
// allow both `async fn foo()` and `fn foo() -> impl Future`
546546
}
@@ -643,7 +643,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
643643
infcx.replace_bound_vars_with_fresh_vars(
644644
return_span,
645645
infer::HigherRankedType,
646-
tcx.fn_sig(impl_m.def_id),
646+
tcx.bound_fn_sig(impl_m.def_id).subst_identity(),
647647
),
648648
);
649649
impl_sig.error_reported()?;
@@ -1117,7 +1117,7 @@ fn compare_self_type<'tcx>(
11171117
ty::ImplContainer => impl_trait_ref.self_ty(),
11181118
ty::TraitContainer => tcx.types.self_param,
11191119
};
1120-
let self_arg_ty = tcx.fn_sig(method.def_id).input(0);
1120+
let self_arg_ty = tcx.bound_fn_sig(method.def_id).subst_identity().input(0);
11211121
let param_env = ty::ParamEnv::reveal_all();
11221122

11231123
let infcx = tcx.infer_ctxt().build();
@@ -1348,10 +1348,10 @@ fn compare_number_of_method_arguments<'tcx>(
13481348
trait_m: &ty::AssocItem,
13491349
trait_item_span: Option<Span>,
13501350
) -> Result<(), ErrorGuaranteed> {
1351-
let impl_m_fty = tcx.fn_sig(impl_m.def_id);
1352-
let trait_m_fty = tcx.fn_sig(trait_m.def_id);
1353-
let trait_number_args = trait_m_fty.inputs().skip_binder().len();
1354-
let impl_number_args = impl_m_fty.inputs().skip_binder().len();
1351+
let impl_m_fty = tcx.bound_fn_sig(impl_m.def_id);
1352+
let trait_m_fty = tcx.bound_fn_sig(trait_m.def_id);
1353+
let trait_number_args = trait_m_fty.skip_binder().inputs().skip_binder().len();
1354+
let impl_number_args = impl_m_fty.skip_binder().inputs().skip_binder().len();
13551355

13561356
if trait_number_args != impl_number_args {
13571357
let trait_span = trait_m

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn equate_intrinsic_type<'tcx>(
5858
let fty = tcx.mk_fn_ptr(sig);
5959
let it_def_id = it.owner_id.def_id;
6060
let cause = ObligationCause::new(it.span, it_def_id, ObligationCauseCode::IntrinsicType);
61-
require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.fn_sig(it.owner_id)), fty);
61+
require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.bound_fn_sig(it.owner_id.to_def_id()).subst_identity()), fty);
6262
}
6363
}
6464

0 commit comments

Comments
 (0)