Description
rust-analyzer version:
rust-analyzer version: 1.89.0-nightly (59aa1e87 2025-06-03)
rustc version:
rustc 1.89.0-nightly (59aa1e873 2025-06-03)
editor or extension:
VSCode:
Identifier
rust-lang.rust-analyzer
Version
0.3.2490
Last Updated
2025-06-09, 10:06:56
relevant settings:
repository link (if public, optional):
We ran into this as part of a large in flight PR this commit demonstrates our workaround
code snippet to reproduce:
This is a minimal repro for the issue afaict.
We are adopting the nightly feature ptr_metadata
and observed that certain type constraints appears to greatly confuse Rust-Analyzer
fn make<T>(_thin: *const (), _meta: std::ptr::DynMetadata<T>) -> *const T
where
T: std::ptr::Pointee<Metadata = std::ptr::DynMetadata<T>> + ?Sized,
{
todo!()
}
trait Foo {
fn foo(&self) -> String {
todo!()
}
}
fn test() -> String {
struct F {}
impl Foo for F {}
let meta = std::ptr::metadata(std::ptr::null::<F>() as *const dyn Foo);
let f = F {};
let fat_ptr = make(&f as *const F as *const (), meta); // <-- infers type as `*const {unknown}`
let fat_ref = unsafe { &*fat_ptr }; // <-- infers type as `&{unknown}`
fat_ref.foo() // cannot 'go to definition' on `foo`
}
Rust Analyzer failed to understand the types of this program. DynMetadata
appears to be the problem since RA cannot understand how to perform inference on it.