Skip to content

Commit ab40ba2

Browse files
committed
add EarlyBinder::no_bound_vars
1 parent c2414df commit ab40ba2

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

compiler/rustc_codegen_cranelift/src/main_shim.rs

+1-1
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).subst_identity().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_ssa/src/base.rs

+1-1
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).subst_identity().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_middle/src/ty/subst.rs

+5
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,11 @@ impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder<T> {
758758
pub fn subst_identity(self) -> T {
759759
self.0
760760
}
761+
762+
/// Returns the inner value, but only if it contains no bound vars.
763+
pub fn no_bound_vars(self) -> Option<T> {
764+
if !self.0.needs_subst() { Some(self.0) } else { None }
765+
}
761766
}
762767

763768
///////////////////////////////////////////////////////////////////////////

compiler/rustc_monomorphize/src/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ impl<'v> RootCollector<'_, 'v> {
12961296
};
12971297

12981298
let start_def_id = self.tcx.require_lang_item(LangItem::Start, None);
1299-
let main_ret_ty = self.tcx.fn_sig(main_def_id).subst_identity().output();
1299+
let main_ret_ty = self.tcx.fn_sig(main_def_id).no_bound_vars().unwrap().output();
13001300

13011301
// Given that `main()` has no arguments,
13021302
// then its return type cannot have

src/tools/miri/src/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
357357
match entry_type {
358358
EntryFnType::Main { .. } => {
359359
let start_id = tcx.lang_items().start_fn().unwrap();
360-
let main_ret_ty = tcx.fn_sig(entry_id).subst_identity().output();
360+
let main_ret_ty = tcx.fn_sig(entry_id).no_bound_vars().unwrap().output();
361361
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
362362
let start_instance = ty::Instance::resolve(
363363
tcx,

0 commit comments

Comments
 (0)