Emits error if has bound regions
This commit is contained in:
parent
a7d6f42db3
commit
4830325a14
@ -124,7 +124,10 @@ fn main_fn_return_type_span(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Span> {
|
|||||||
if let Some(term_did) = tcx.lang_items().termination() {
|
if let Some(term_did) = tcx.lang_items().termination() {
|
||||||
let return_ty = main_fnsig.output();
|
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_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 infcx = tcx.infer_ctxt().build();
|
||||||
let cause = traits::ObligationCause::new(
|
let cause = traits::ObligationCause::new(
|
||||||
return_ty_span,
|
return_ty_span,
|
||||||
|
5
tests/ui/entry-point/return-ty-has-bound-vars.rs
Normal file
5
tests/ui/entry-point/return-ty-has-bound-vars.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// issue-119209
|
||||||
|
|
||||||
|
type Foo<'a> = impl PartialEq; //~ERROR `impl Trait` in type aliases is unstable
|
||||||
|
|
||||||
|
fn main<'a>(_: &'a i32) -> Foo<'a> {} //~ERROR `main` function return type is not allowed to have generic parameters
|
19
tests/ui/entry-point/return-ty-has-bound-vars.stderr
Normal file
19
tests/ui/entry-point/return-ty-has-bound-vars.stderr
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
error[E0658]: `impl Trait` in type aliases is unstable
|
||||||
|
--> $DIR/return-ty-has-bound-vars.rs:3:16
|
||||||
|
|
|
||||||
|
LL | type Foo<'a> = impl PartialEq;
|
||||||
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
|
||||||
|
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0131]: `main` function return type is not allowed to have generic parameters
|
||||||
|
--> $DIR/return-ty-has-bound-vars.rs:5:28
|
||||||
|
|
|
||||||
|
LL | fn main<'a>(_: &'a i32) -> Foo<'a> {}
|
||||||
|
| ^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0131, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0131`.
|
Loading…
Reference in New Issue
Block a user