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

"Generate constant" assist creates constant with function's type when invoked on a const generic argument. #11034

Open
wildbook opened this issue Dec 16, 2021 · 1 comment
Labels
A-assists A-ty type system / type inference / traits / method resolution C-bug Category: bug S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@wildbook
Copy link
Contributor

  • serverVersion: '0.3.859'
  • nightlyReleaseId: 55412114

Example:

fn main() {
    fn foo<const X: usize>() { }
    foo::<BAR>();
}

Invoking the "Generate constant" assist on BAR results in:

fn main() {
    fn foo<const X: usize>() { }
    const BAR: fn foo() = ;
    foo::<BAR>();
}

It should instead use the argument's type and generate const BAR: usize = .

vMbZ0ItN6JeCb75U.1.mp4
@Veykril Veykril added A-assists C-bug Category: bug good first issue S-actionable Someone could pick this issue up and work on it right now and removed good first issue labels Dec 16, 2021
@Veykril
Copy link
Member

Veykril commented Dec 17, 2021

I assume the problem here is us not resolving const generics, so Semantics::type_of_expression falls back to climbing up the ancestors until it finds the foo function path querying that for its type and filling that in.
cc #8655

@Veykril Veykril added A-ty type system / type inference / traits / method resolution S-unactionable Issue requires feedback, design decisions or is blocked on other work and removed S-actionable Someone could pick this issue up and work on it right now labels Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists A-ty type system / type inference / traits / method resolution C-bug Category: bug S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

2 participants