Skip to content

rust_analyzer fails to resolve type information if custom deref implementation exists #23329

Description

@Linus045

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
rust-analyzer 0.3.3041-standalone

rustc version: (eg. output of rustc -V)
rustc 1.98.1 (48a229cea 2026-09-01)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
Neovim with custom config, though the same happens in fresh LazyVim config with rust_analyzer LSP installed via :Mason

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
I set nothing that I'm aware of

repository link (if public, optional): (eg. rust-analyzer)
See link in reproduction section below

code snippet to reproduce:
See reproduction project here: https://github.com/Linus045/rust_analyzer_bug

First up, I'm not that experienced with rust so this my be an oversight on my part and not an issue with rust_analyzer, though it seems weird to me that I get not type info at all.

I was working with tauri and used a rather complex type from the mdns_sd crate inside a struct that I then used inside a tauri::State struct (see commented out code at the beginning, line 25 in example1()).
For some reason, as soon as I added the ServiceDaemon type in the Test struct, the autocompletion for the state object broke. It shows up as red underlines in my editor (see the inner() and lock() function calls in the image) and when I try to hover over the type it shows {unknown}.

I investigated and tracked the issue down to the the Deref trait implementation for tauri::State.
I copied the tauri State struct and created my own TestState which showed the same issue: If I comment out the Deref impl the type resolution works (see line 48in the example main.rs) but as soon as I add it back in it fails.

I'm not familiar enough with rust to reduce the example code any further but I hope someone else can maybe help with that.
Also I tried to check existing issues but its hard to search for as I don't even exactly know what to search for, so sorry if this is a duplicate.

Additional info:

  • cargo check shows no errors or warnings.

  • there is some differnt behavior using .0 or .inner() with multiple let definitions, see example2(), example3() and example4() which I don't fully understand

  • I don't fully understand lifetimes and deref behavior yet so maybe this might be an error with the tauri::State implementation?

  • dependencies used:

[dependencies]
tokio = { version = "1.53.1", features = ["macros", "rt-multi-thread", "sync"] }
tauri = { version = "2", features = [] }
mdns-sd = "0.19.1"

See reproduction project here: https://github.com/Linus045/rust_analyzer_bug
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions