Skip to content

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

Closed

Description

@estebank

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-const-genericsArea: const generics (parameters and arguments)
    D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.
    D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.
    D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.
    on Dec 4, 2025
  2. self-assigned this
    on Dec 8, 2025
  3. added 3 commits that reference this issue on Oct 7, 2026
    b08d67c
    ec2dfaa
    cd1efdc
  4. added a commit that references this issue on Oct 8, 2026
    7267961
  5. added a commit that references this issue on Oct 10, 2026
    3c69abc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyD-lack-of-suggestionDiagnostics: 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.D-verboseDiagnostics: 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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions