mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
#11973 associated type is unresolved
This commit is contained in:
parent
1894473b19
commit
5d1aff3357
2 changed files with 50 additions and 1 deletions
|
@ -652,7 +652,13 @@ fn resolve_hir_path_(
|
||||||
let (ty, remaining) =
|
let (ty, remaining) =
|
||||||
resolver.resolve_path_in_type_ns(db.upcast(), path.mod_path())?;
|
resolver.resolve_path_in_type_ns(db.upcast(), path.mod_path())?;
|
||||||
match remaining {
|
match remaining {
|
||||||
Some(remaining) if remaining > 1 => None,
|
Some(remaining) if remaining > 1 => {
|
||||||
|
if remaining + 1 == path.segments().len() {
|
||||||
|
Some((ty, path.segments().last()))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => Some((ty, path.segments().get(1))),
|
_ => Some((ty, path.segments().get(1))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3764,6 +3764,49 @@ pub fn gimme() -> theitem::TheItem {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hover_trait_assoc_typealias() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
fn main() {}
|
||||||
|
|
||||||
|
trait T1 {
|
||||||
|
type Bar;
|
||||||
|
type Baz;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Foo;
|
||||||
|
|
||||||
|
mod t2 {
|
||||||
|
pub trait T2 {
|
||||||
|
type Bar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use t2::T2;
|
||||||
|
|
||||||
|
impl T2 for Foo {
|
||||||
|
type Bar = String;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl T1 for Foo {
|
||||||
|
type Bar = <Foo as t2::T2>::Ba$0r;
|
||||||
|
// ^^^ unresolvedReference
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
*Bar*
|
||||||
|
|
||||||
|
```rust
|
||||||
|
test::t2
|
||||||
|
```
|
||||||
|
|
||||||
|
```rust
|
||||||
|
pub type Bar
|
||||||
|
```
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn hover_generic_assoc() {
|
fn hover_generic_assoc() {
|
||||||
check(
|
check(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue