rust-analyzer: [BUG] Const generics broken when inside struct
Versions:
rust-analyzer version: 2023-05-15 & Nightly
rustc version: 1.69.0
relevant settings: https://github.com/utkarshgupta137/nvim-lazy/blob/main/lua/lvim/lsp/settings/rust_analyzer.lua
Minimal reproduction:
pub const ONE: usize = 1;
pub struct Inner<const P: usize>();
pub struct Outer {
pub inner: Inner<ONE>,
}
fn main() {
_ = Outer {
inner: Inner::<1>(), // Error: expected Inner<ONE>, found Inner<1> | rust-analyzer (type-mismatch) [11, 16]
};
}
Diagnosis:
The bug doesn’t exist in the 2023-05-08 release. This PR included in the 2023-05-15 release seems relevant: https://github.com/rust-lang/rust-analyzer/pull/14727
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 20 (8 by maintainers)
Commits related to this issue
- Auto merge of #14891 - HKalbasi:dev, r=HKalbasi Evaluate `UnevaluatedConst` in unify fix #14844 — committed to rust-lang/rust-analyzer by bors a year ago
- Auto merge of #14913 - HKalbasi:fix14844, r=HKalbasi Evaluate `UnevalutedConst` before trait solving cc #14844 — committed to rust-lang/rust-analyzer by bors a year ago
- Auto merge of #14913 - HKalbasi:fix14844, r=HKalbasi Evaluate `UnevalutedConst` before trait solving cc #14844 — committed to rust-lang/rust-analyzer by bors a year ago
At least it’s not crashing 😅
LSP Logs with `RA_LOG='rust_analyzer=debug' nvim`:
Yes, my issue is resolved now. Will update in case I see it someplace else. (Yes, I did re-enable the
type-mistmatchdiagnostic)Will do it once a nightly is released.