-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bug
Description
rust-analyzer version: rust-analyzer version: 0.3.2675-standalone (21f8445 2025-11-09)
rustc version: rustc 1.90.0 (1159e78c4 2025-09-14)
editor or extension: VS Code
relevant settings: nothing out of ordinary
code snippet to reproduce:
use std::ops::Deref;
struct Base;
impl Base {
fn func(&self) -> i32 { 111 }
}
trait BaseLayerOne: Deref<Target = Base>{}
trait BaseLayerTwo: BaseLayerOne {}
impl<T> BaseLayerOne for T
where
T: BaseLayerTwo + 'static,
{
}
struct BaseLayerThree(Box<dyn BaseLayerTwo>);
impl Deref for BaseLayerThree {
type Target = dyn BaseLayerTwo;
fn deref(&self) -> &Self::Target {
self.0.deref()
}
}
struct NonBase(Base);
impl Deref for NonBase {
type Target = Base;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl BaseLayerTwo for NonBase {}
fn main() {
let t = BaseLayerThree(Box::new(NonBase(Base)));
let r = t.func();
println!("{r}");
}cargo/rustc has no problem with this, rust-analyzer gives up at recognizing the t.func() call "Go to Definition" doesn't work and r's type is {unknown} on hover. This is a based on real code (from fyrox).
Metadata
Metadata
Assignees
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bug