Skip to content

Commit 8d067f1

Browse files
committed
Make fn_sig return a simple FnSig.
1 parent bf1127d commit 8d067f1

File tree

74 files changed

+233
-328
lines changed

Some content is hidden

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

74 files changed

+233
-328
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,8 +2359,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
23592359
// If a closure captured our `target` and then assigned
23602360
// into a place then we should annotate the closure in
23612361
// case it ends up being assigned into the return place.
2362-
annotated_closure =
2363-
self.annotate_fn_sig(def_id, substs.as_closure().sig());
2362+
annotated_closure = self.annotate_fn_sig(
2363+
def_id,
2364+
substs.as_closure().sig().skip_binder(),
2365+
);
23642366
debug!(
23652367
"annotate_argument_and_return_for_borrow: \
23662368
annotated_closure={:?} assigned_from_local={:?} \
@@ -2483,7 +2485,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
24832485
fn annotate_fn_sig(
24842486
&self,
24852487
did: LocalDefId,
2486-
sig: ty::PolyFnSig<'tcx>,
2488+
sig: ty::FnSig<'tcx>,
24872489
) -> Option<AnnotatedBorrowFnSignature<'tcx>> {
24882490
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
24892491
let is_closure = self.infcx.tcx.is_closure(did.to_def_id());
@@ -2513,12 +2515,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25132515
// 3. The return type is not a reference. In this case, we don't highlight
25142516
// anything.
25152517
let return_ty = sig.output();
2516-
match return_ty.skip_binder().kind() {
2518+
match return_ty.kind() {
25172519
ty::Ref(return_region, _, _) if return_region.has_name() && !is_closure => {
25182520
// This is case 1 from above, return type is a named reference so we need to
25192521
// search for relevant arguments.
25202522
let mut arguments = Vec::new();
2521-
for (index, argument) in sig.inputs().skip_binder().iter().enumerate() {
2523+
for (index, argument) in sig.inputs().iter().enumerate() {
25222524
if let ty::Ref(argument_region, _, _) = argument.kind() {
25232525
if argument_region == return_region {
25242526
// Need to use the `rustc_middle::ty` types to compare against the
@@ -2542,7 +2544,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25422544

25432545
// We use a mix of the HIR and the Ty types to get information
25442546
// as the HIR doesn't have full types for closure arguments.
2545-
let return_ty = sig.output().skip_binder();
2547+
let return_ty = sig.output();
25462548
let mut return_span = fn_decl.output.span();
25472549
if let hir::FnRetTy::Return(ty) = &fn_decl.output {
25482550
if let hir::TyKind::Rptr(lifetime, _) = ty.kind {
@@ -2561,7 +2563,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25612563
// reference so we select
25622564
// the first argument.
25632565
let argument_span = fn_decl.inputs.first()?.span;
2564-
let argument_ty = sig.inputs().skip_binder().first()?;
2566+
let argument_ty = sig.inputs().first()?;
25652567

25662568
// Closure arguments are wrapped in a tuple, so we need to get the first
25672569
// from that.
@@ -2581,10 +2583,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25812583
// This is also case 2 from above but for functions, return type is still an
25822584
// anonymous reference so we select the first argument.
25832585
let argument_span = fn_decl.inputs.first()?.span;
2584-
let argument_ty = *sig.inputs().skip_binder().first()?;
2586+
let argument_ty = *sig.inputs().first()?;
25852587

25862588
let return_span = fn_decl.output.span();
2587-
let return_ty = sig.output().skip_binder();
2589+
let return_ty = sig.output();
25882590

25892591
// We expect the first argument to be a reference.
25902592
match argument_ty.kind() {

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
457457
// C-variadic fns also have a `VaList` input that's not listed in the signature
458458
// (as it's created inside the body itself, not passed in from outside).
459459
if let DefiningTy::FnDef(def_id, _) = defining_ty {
460-
if self.infcx.tcx.fn_sig(def_id).c_variadic() {
460+
if self.infcx.tcx.fn_sig(def_id).c_variadic {
461461
let va_list_did = self.infcx.tcx.require_lang_item(
462462
LangItem::VaList,
463463
Some(self.infcx.tcx.def_span(self.mir_def.did)),
@@ -652,7 +652,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
652652
DefiningTy::FnDef(def_id, _) => {
653653
let sig = tcx.fn_sig(def_id);
654654
let sig = indices.fold_to_region_vids(tcx, sig);
655-
sig.inputs_and_output()
655+
ty::Binder::dummy(sig.inputs_and_output)
656656
}
657657

658658
DefiningTy::Const(def_id, _) => {

compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ pub(crate) fn maybe_create_entry_wrapper(
5252
// late-bound regions, since late-bound
5353
// regions must appear in the argument
5454
// listing.
55-
let main_ret_ty = tcx.normalize_erasing_regions(
56-
ty::ParamEnv::reveal_all(),
57-
main_ret_ty.no_bound_vars().unwrap(),
58-
);
55+
let main_ret_ty = tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), main_ret_ty);
5956

6057
let cmain_sig = Signature {
6158
params: vec![

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
431431
// the WebAssembly specification, which has this feature. This won't be
432432
// needed when LLVM enables this `multivalue` feature by default.
433433
if !cx.tcx.is_closure(instance.def_id()) {
434-
let abi = cx.tcx.fn_sig(instance.def_id()).abi();
434+
let abi = cx.tcx.fn_sig(instance.def_id()).abi;
435435
if abi == Abi::Wasm {
436436
function_features.push("+multivalue".to_string());
437437
}

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
445445
// late-bound regions, since late-bound
446446
// regions must appear in the argument
447447
// listing.
448-
let main_ret_ty = cx.tcx().normalize_erasing_regions(
449-
ty::ParamEnv::reveal_all(),
450-
main_ret_ty.no_bound_vars().unwrap(),
451-
);
448+
let main_ret_ty =
449+
cx.tcx().normalize_erasing_regions(ty::ParamEnv::reveal_all(), main_ret_ty);
452450

453451
let Some(llfn) = cx.declare_c_main(llfty) else {
454452
// FIXME: We should be smart and show a better diagnostic here.

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
6565
if cfg!(debug_assertions) && stab.promotable {
6666
let sig = tcx.fn_sig(def_id);
6767
assert_eq!(
68-
sig.unsafety(),
68+
sig.unsafety,
6969
hir::Unsafety::Normal,
7070
"don't mark const unsafe fns as promotable",
7171
// https://github.com/rust-lang/rust/pull/53851#issuecomment-418760682

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
246246
// instead of the type of the return place.
247247
self.span = body.local_decls[RETURN_PLACE].source_info.span;
248248
let return_ty = tcx.fn_sig(def_id).output();
249-
self.check_local_or_return_ty(return_ty.skip_binder(), RETURN_PLACE);
249+
self.check_local_or_return_ty(return_ty, RETURN_PLACE);
250250
}
251251

252252
if !tcx.has_attr(def_id.to_def_id(), sym::rustc_do_not_const_check) {

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,8 +2919,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29192919
);
29202920

29212921
let ty = if let Some(arg_idx) = arg_idx { fn_sig.input(arg_idx) } else { fn_sig.output() };
2922-
2923-
Some(tcx.liberate_late_bound_regions(fn_hir_id.expect_owner().to_def_id(), ty))
2922+
Some(ty)
29242923
}
29252924

29262925
fn validate_late_bound_regions(

compiler/rustc_hir_analysis/src/check/compare_method.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ fn compare_self_type<'tcx>(
804804
let param_env = ty::ParamEnv::reveal_all();
805805

806806
let infcx = tcx.infer_ctxt().build();
807-
let self_arg_ty = tcx.liberate_late_bound_regions(method.def_id, self_arg_ty);
808807
let can_eq_self = |ty| infcx.can_eq(param_env, untransformed_self_ty, ty).is_ok();
809808
match ExplicitSelf::determine(self_arg_ty, can_eq_self) {
810809
ExplicitSelf::ByValue => "self".to_owned(),
@@ -1034,8 +1033,8 @@ fn compare_number_of_method_arguments<'tcx>(
10341033
) -> Result<(), ErrorGuaranteed> {
10351034
let impl_m_fty = tcx.fn_sig(impl_m.def_id);
10361035
let trait_m_fty = tcx.fn_sig(trait_m.def_id);
1037-
let trait_number_args = trait_m_fty.inputs().skip_binder().len();
1038-
let impl_number_args = impl_m_fty.inputs().skip_binder().len();
1036+
let trait_number_args = trait_m_fty.inputs().len();
1037+
let impl_number_args = impl_m_fty.inputs().len();
10391038
if trait_number_args != impl_number_args {
10401039
let trait_span = if let Some(def_id) = trait_m.def_id.as_local() {
10411040
match tcx.hir().expect_trait_item(def_id).kind {

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ fn suggestion_signature(assoc: &ty::AssocItem, tcx: TyCtxt<'_>) -> String {
449449
// regions just fine, showing `fn(&MyType)`.
450450
fn_sig_suggestion(
451451
tcx,
452-
tcx.fn_sig(assoc.def_id).skip_binder(),
452+
tcx.fn_sig(assoc.def_id),
453453
assoc.ident(tcx),
454454
tcx.predicates_of(assoc.def_id),
455455
assoc,

0 commit comments

Comments
 (0)