Skip to content

Commit

Permalink
Unrolled build for rust-lang#119215
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#119215 - mu001999:fix/119209, r=Nilstrieb

Emits error if has bound regions

Fixes rust-lang#119209
  • Loading branch information
rust-timer authored Dec 22, 2023
2 parents 208dd20 + d3f466a commit af7242c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_hir_analysis/src/check/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
if let Some(term_did) = tcx.lang_items().termination() {
let return_ty = main_fnsig.output();
let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span);
let return_ty = return_ty.skip_binder();
let Some(return_ty) = return_ty.no_bound_vars() else {
tcx.sess.emit_err(errors::MainFunctionReturnTypeGeneric { span: return_ty_span });
return;
};
let infcx = tcx.infer_ctxt().build();
let cause = traits::ObligationCause::new(
return_ty_span,
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/entry-point/return-ty-has-bound-vars.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// issue-119209

fn main<'a>(_: &'a i32) -> &'a () { &() } //~ERROR `main` function return type is not allowed to have generic parameters
9 changes: 9 additions & 0 deletions tests/ui/entry-point/return-ty-has-bound-vars.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0131]: `main` function return type is not allowed to have generic parameters
--> $DIR/return-ty-has-bound-vars.rs:3:28
|
LL | fn main<'a>(_: &'a i32) -> &'a () { &() }
| ^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0131`.

0 comments on commit af7242c

Please sign in to comment.