rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.39k stars 1.62k forks source link

type inference, inlayhint, and autocomplete no longer working for hecs world.get() ref since version 0.3.2029+ #17734

Closed jestarray closed 4 months ago

jestarray commented 4 months ago

rust-analyzer version: rust-analyzer version: 0.3.2045-standalone [/home/a/.vscode-oss/extensions/rust-lang.rust-analyzer-0.3.2045-linux-x64/server/rust-analyzer]

rustc version: rustc 1.80.0 (051478957 2024-07-21)

editor or extension: vscode on linux(have not tested on windows yet)

code snippet to reproduce:

use hecs::{Entity, World};
fn main() {
    let mut world = hecs::World::new();
    let entity = world.spawn((0.0,));
    if let Ok(f) = world.get::<&mut f32>(entity) {
        dbg!(f);
    };
}

deps:

//Cargo.toml
[dependencies]
hecs = "0.10"

Latest working working version: v0.3.2020 image

Any version above 0.3.2020 does not show the inlayhint, typeinference, and autocomplete methods for the given type as shown above. hecs info: https://docs.rs/hecs/latest/hecs/struct.World.html#method.get https://docs.rs/hecs/latest/hecs/trait.ComponentRef.html#associatedtype.Ref

Veykril commented 4 months ago

Typing world.get::<'_, &mut f32>(entity) makes it work so we are messing up some indices here probably. Also does not happen with a fully qualified call, so this is specifically an issue with method resoluton

Veykril commented 4 months ago

fn main() {
    // fails
    let x = S.foo::<&()>();
    // works
    let x = S::foo::<&()>(&S);
}

struct S;

impl S {
    pub fn foo<'a, T: Trait<'a>>(&'a self) -> T::Proj {
        loop {}
    }
}

struct Wrap<'a, T>(T);
trait Trait<'a> {
    type Proj;
}
impl<'a, T> Trait<'a> for &'a T {
    type Proj = Wrap<'a, T>;
}