Description
rust-analyzer version: 0.3.2011-standalone
rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)
extension: VSCode extension v0.3.2011
Reproduction
Paste the following code into main.rs
struct Blackjack<'a, T = bool> {
state: &'a T,
}
impl<'a, T> Blackjack<'a, T> {
fn method(self) {
let _ = self.state;
}
}
fn make_blackjack<'a>() -> Blackjack<'a> {
Blackjack { state: &true }
}
fn main() {
let blackjack = make_blackjack();
blackjack.method();
}
Expected
I expected rust-analyzer to resolve the .method()
invocation correctly and highlight it as yellow according to my semantic tokens highlighting config.
Actual
You may see that method()
method symbol is unresolved. Here is how it looks in my VSCode. I configured unresolved symbols semantic token type to be displayed in pale-red. You may see that the lifetime parameter of the struct is inferred to be {unknown}
. I suppose this is the reason why .method()
is unresolved.

Well-formed variation
If you remove the T = bool
default value of the generic parameter on the struct definition and pass bool
explicitly then all is fine.
