Skip to content

Commit 7919ef0

Browse files
committed
Auto merge of #107055 - kylematsuda:eb-fn-sig, r=lcnr
Switch to `EarlyBinder` for `fn_sig` query Part of the work to finish #105779 (also see rust-lang/types-team#78). Several queries `X` have a `bound_X` variant that wraps the output in [`EarlyBinder`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/subst/struct.EarlyBinder.html). This adds `EarlyBinder` to the return type of the `fn_sig` query and removes `bound_fn_sig`. r? `@lcnr`
2 parents 6874f4e + dc1216b commit 7919ef0

File tree

86 files changed

+193
-172
lines changed

Some content is hidden

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

86 files changed

+193
-172
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.fn_sig(self.mir_def_id()).subst_identity(),
26032603
),
26042604
_ => None,
26052605
}

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10641064
);
10651065
}
10661066
}
1067-
CallKind::Normal { self_arg, desugaring, method_did } => {
1067+
CallKind::Normal { self_arg, desugaring, method_did, method_substs } => {
10681068
let self_arg = self_arg.unwrap();
10691069
let tcx = self.infcx.tcx;
10701070
if let Some((CallDesugaringKind::ForLoopIntoIter, _)) = desugaring {
@@ -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.fn_sig(method_did).subst(tcx, method_substs).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.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.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.fn_sig(rust_main_def_id).no_bound_vars().unwrap().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.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/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
436436
cx.type_func(&[], cx.type_int())
437437
};
438438

439-
let main_ret_ty = cx.tcx().fn_sig(rust_main_def_id).output();
439+
let main_ret_ty = cx.tcx().fn_sig(rust_main_def_id).no_bound_vars().unwrap().output();
440440
// Given that `main()` has no arguments,
441441
// then its return type cannot have
442442
// late-bound regions, since late-bound

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.fn_sig(did).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.fn_sig(did).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.fn_sig(did).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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
6666
if cfg!(debug_assertions) && stab.promotable {
6767
let sig = tcx.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.fn_sig(did).subst_identity()
7676
}
7777
}
7878
}

compiler/rustc_const_eval/src/util/call_kind.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub enum CallKind<'tcx> {
4040
self_arg: Option<Ident>,
4141
desugaring: Option<(CallDesugaringKind, Ty<'tcx>)>,
4242
method_did: DefId,
43+
method_substs: SubstsRef<'tcx>,
4344
},
4445
/// A call to `Fn(..)::call(..)`, desugared from `my_closure(a, b, c)`
4546
FnCall { fn_trait_id: DefId, self_ty: Ty<'tcx> },
@@ -131,6 +132,6 @@ pub fn call_kind<'tcx>(
131132
} else {
132133
None
133134
};
134-
CallKind::Normal { self_arg, desugaring, method_did }
135+
CallKind::Normal { self_arg, desugaring, method_did, method_substs }
135136
})
136137
}

0 commit comments

Comments
 (0)