Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
maxwase opened this issue Oct 4, 2024 · 2 comments
Labels
C-bug Category: bug

Comments

@maxwase
Copy link
Contributor

maxwase commented Oct 4, 2024

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

@maxwase maxwase added the C-bug Category: bug label Oct 4, 2024
@ChayimFriedman2
Copy link
Contributor

I don't think we lower const bodies yet, so we don't do inference for them and type analysis is not available.

@ChayimFriedman2
Copy link
Contributor

Duplicate #7434 (also #8655).

@ChayimFriedman2 ChayimFriedman2 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants