Skip to content

Hints and autocompletion failed for complex type constraint #14615

@bool-rus

Description

@bool-rus

rust-analyzer version: 0.4.1482-standalone (9b835f3 2023-04-17)

rustc version: rustc 1.68.2 (9eb3afe9e 2023-03-27)

relevant settings: dont matter, but... vscodium 1.77.2

Steps to reproduce

There is some traits:

trait Foo {type Inner;}
trait Bar {type Inner;}
impl Foo for i32 {type Inner = i32;}
impl Bar for i32 {type Inner = i32;}

And when some struct with impl depends of constraint:

struct Baz<T>(T);
impl<T> Baz<T> where T: Foo, T::Inner: Bar,
<T::Inner as Bar>::Inner: Sized
{
    pub fn new(obj: T) -> Self {Self(obj)}
    pub fn foo(&self) -> String {"foobazz".to_owned()}
}

fn test() {
    let baz = Baz::new(1);
    let s = baz.foo();
}

type hints and autocomplete fails on it (not worked for obj baz):
image

When remove consrtaint <T::Inner as Bar>::Inner: Sized it worked back:
image

its important, that tonic code generation creates type constraints like that

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