-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.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
Code
const CONST: usize = 0;
fn foo<const C: usize>() {}
fn main() {
foo::<CONS>();
}Current output
error[E0425]: cannot find type `CONS` in this scope
--> src/main.rs:6:11
|
6 | foo::<CONS>();
| ^^^^ not found in this scope
error[E0747]: unresolved item provided when a constant was expected
--> src/main.rs:6:11
|
6 | foo::<CONS>();
| ^^^^
|
help: if this generic argument was intended as a const parameter, surround it with braces
|
6 | foo::<{ CONS }>();
| + +Desired output
error[E0425]: cannot find type `CONS` in this scope
--> src/main.rs:6:11
1 | const CONST: usize = 0;
| ----- similarly named `const` `CONST` defined here
|
6 | foo::<CONS>();
| ^^^^ not found in this scopeRationale and extra context
We're emitting two errors when one was made, and we already provide fuzzy-search in other resolve errors.
Other cases
Rust Version
Stable to Nightly
1.93.0-nightly
2025-12-03 83e49b75e7daf827e439Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.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.