-
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-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-varianceArea: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)C-bugCategory: This is a bug.Category: This is a bug.T-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.
Description
I tried this code:
fn hr(arg: &for<'a> fn(&'static &'a ())) {
no_hr(arg)
}
fn no_hr(arg: &fn(&'static &'static ())) {
hr(arg)
}
I expected to see this happen: It compiles. In for<'a> fn(&'static &'a ())
, 'a
must be 'static
, so this type should be equivalent to fn(&'static &'static ())
.
Instead, this happened:
error[E0308]: mismatched types
--> src/lib.rs:6:10
|
6 | hr(arg)
| ^^^ one type is more general than the other
|
= note: expected reference `&for<'a> fn(&&'a ())`
found reference `&fn(&&())`
Meta
rustc --version
:
1.87.0
@rustbot label T-types A-higher-ranked A-lifetimes A-variance
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-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-varianceArea: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)Area: Variance (https://doc.rust-lang.org/nomicon/subtyping.html)C-bugCategory: This is a bug.Category: This is a bug.T-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.