Skip to content

Methods provided via Deref<Target> are not being found #13238

Closed
@woody77

Description

@woody77

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

rustc version:
rust-analyzer version: 0.4.1202-standalone
rustc 1.65.0-nightly (350cca3b6 2022-08-30)

relevant settings: VSCode remote, with a very large project (1000s of crates), no extra env settings for CHALK

Methods from OtherType that are defined for a type (ThisType) via implementing Deref<Target=OtherType> are not being found as valid symbols, and flagged as unresolvedReference.

Using the following struct:

struct Wrapper(pub String);

impl std::ops::Deref for Wrapper {
    type Target = str;

    fn deref(&self) -> &Self::Target {
        self.0.as_str()
    }
}

The following do not resolve .chars():
Screen Shot 2022-09-15 at 5 02 03 PM

But the following do resolve chars() correctly:
Screen Shot 2022-09-15 at 5 02 11 PM

Full source (and proof that these work) at:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d5c1d59fa47c1228df2be80042ec41a1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions