-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Open
Copy link
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-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)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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 foo() {
let _: [fn(_); 2] = [x, y];
}
fn x(_: &str) {
todo!()
}
fn y(_: &str) {
todo!()
}
I expected to see this happen: compiles
Instead, this happened:
error[E0308]: mismatched types
--> src/lib.rs:2:29
|
2 | let _: [fn(_); 2] = [x, y];
| ^ one type is more general than the other
|
= note: expected fn pointer `fn(&_)`
found fn item `for<'a> fn(&'a _) {y}`
For more information about this error, try `rustc --explain E0308`.
Meta
rustc --version --verbose
:
stable 1.89
Metadata
Metadata
Assignees
Labels
A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsA-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)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.