Closed
Description
I tried this code:
tests/ui/late-bound-lifetimes/late_bound_through_alias.rs
#![feature(lazy_type_alias)]
// check-pass
fn f(_: X) -> X {
unimplemented!()
}
fn g<'a>(_: X<'a>) -> X<'a> {
unimplemented!()
}
type X<'a> = &'a ();
fn main() {
let _: for<'a> fn(X<'a>) -> X<'a> = g;
let _: for<'a> fn(X<'a>) -> X<'a> = f;
}
without -Zcrate-attr=feature(lazy_type_alias)
: no warnings
with -Zcrate-attr=feature(lazy_type_alias)
:
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
--> tests/ui/late-bound-lifetimes/late_bound_through_alias.rs:3:15
|
3 | fn f(_: X) -> X {
| ^
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
= note: consider introducing a named lifetime parameter
error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types
--> tests/ui/late-bound-lifetimes/late_bound_through_alias.rs:7:23
|
7 | fn g<'a>(_: X<'a>) -> X<'a> {
| ^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0581`.
rustc 1.73.0-nightly (04abc370b 2023-07-28)
binary: rustc
commit-hash: 04abc370b9f3855b28172b65a7f7d5a433f41412
commit-date: 2023-07-28
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done