Tracking issue for `Res<_>` deref rust-analyzer autocompletion failure
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
Currently, and in older bevy versions the autocompletions for the deref of `Res<_>` are broken.
Maybe a minimal reproducer can be created and an upstream rust-analyzer issue be filed.
```rust
use bevy::prelude::*;
#[derive(Component)]
struct MyComponent {
value: f32,
}
#[derive(Resource)]
struct MyResource {
value: f32,
}
fn hello_world(query: Query<&MyComponent>, resource: Res) {
let component = query.iter().next().unwrap();
let comp_value = component.value; // rust-analyzer suggestions work
let res_value_deref = resource.value; // rust-analyzer suggestions don't work but ctrl+click works once it's written, also type inlay hints work correctly
let res_value_direct = resource.into_inner().value; // rust-analyzer suggestions work
println!(
"hello world! Value: {} {} {}",
comp_value, res_value_deref, res_value_direct
);
}
fn spawn_component(mut commands: Commands) {
commands.spawn(MyComponent { value: 10.0 });
}
#[test]
fn simple_ecs_test() {
App::new()
.insert_resource(MyResource { value: 5.0 })
.add_systems(Startup, spawn_component)
.add_systems(Update, hello_world)
.run();
}
```
Also see the following test matrix: https://github.com/bevyengine/bevy/issues/17004#issuecomment-2599769547
This should be further investigated once, #17330 has landed.
Contributor guide
Assessment
This issue has not been assessed yet.