rust-lang / rust-lang/rust

Resolve error in const params doesn't do fuzzy search for consts

Open
#149,660 0 comments 0 reactions 1 assignee View on GitHub

@estebank is already working on this.

Since Dec 8, 2025.

A-const-generics A-diagnostics A-resolve D-lack-of-suggestion D-terse D-verbose T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

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 scope
Rationale 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 83e49b75e7daf827e439
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.