-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
For this code:
trait Foo {
const BAR: i32;
}
impl Foo for i32 {
const BAR: i32 = 42;
}
fn baz<F: Foo>(a: F) {
const QUX: i32 = F::BAR;
println!("{}", QUX);
}
fn main() {
baz(1i32);
}
I get the error message:
| fn baz<F: Foo>(a: F) {
| --- - type variable from outer function
| |
| try adding a local type parameter in this method instead
| const QUX: i32 = F::BAR;
| ^^^^^^ use of type variable from outer function
QUX
is not a method and cannot have local type parameters; I don't think constants can be generic. So the error message is confusing.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.