-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
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
Metadata
Metadata
Assignees
Labels
A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-inferenceArea: Type inferenceArea: Type inferenceC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.