Skip to content

Variables in const generic blocks have unresolvedReference as their semantic type #18236

Closed as not planned
@maxwase

Description

@maxwase

rust-analyzer version: 0.4.2133-standalone
rustc version: rustc 1.81.0 (eeb90cda1 2024-09-04)

editor or extension: VSCode

relevant settings:

    "editor.semanticTokenColorCustomizations": {
        "enabled": true,
        "rules": {
            "const": {
                "bold": true,
                "foreground": "#F0F080",
            },
            "variable": "#FFFFFF",
        }
    }

code snippet to reproduce:

struct Foo<const G: usize>;

impl
    Foo<
        {
            const A: usize = 1;
            let a = A;

            if a > 1 as usize {
                A
            } else {
                0
            }
        },
    >
{
    fn foo() -> usize {
        const A: usize = 1;
        let a = A;

        if a > 1 as usize {
            A
        } else {
            0
        }
    }
}

Notice how both constant and variable (a and A) semantic types are determined correctly in the function, but not in the const generic block + type hints are not available
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions