Open
Description
The following compiles (although it shouldn't, arguably, see below for reasoning): https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=05d31c1cc2a9e8752d7a3fc05e9446ea
pub trait Trait {
type Ty<'a>;
}
fn my_fn<T: Trait>(_: T::Ty<'_>) {}
fn test<A: Trait, B: Trait>() -> impl Fn(A::Ty<'static>) {
my_fn
}
It stops compiling with a trivial change that gets rid of higher-ranked regions:
- fn my_fn<T: Trait>(_: T::Ty<'_>) {}
+ fn my_fn<T: Trait>(_: T::Ty<'static>) {}
fn test<A: Trait, B: Trait>() -> impl Fn(A::Ty<'static>) {
my_fn
+ //~^ ERROR type annotation needed
}
This was discovered by @BoxyUwU in #96912.
@rustbot label T-types C-bug I-unsound A-inference