This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree 1 file changed +53
-5
lines changed 1 file changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ fn highlight_references(
166
166
match parent {
167
167
ast:: UseTree ( it) => it. syntax( ) . ancestors( ) . find( |it| {
168
168
ast:: SourceFile :: can_cast( it. kind( ) ) || ast:: Module :: can_cast( it. kind( ) )
169
- } ) ,
169
+ } ) . zip ( Some ( true ) ) ,
170
170
ast:: PathType ( it) => it
171
171
. syntax( )
172
172
. ancestors( )
@@ -178,14 +178,14 @@ fn highlight_references(
178
178
. ancestors( )
179
179
. find( |it| {
180
180
ast:: Item :: can_cast( it. kind( ) )
181
- } ) ,
181
+ } ) . zip ( Some ( false ) ) ,
182
182
_ => None ,
183
183
}
184
184
}
185
185
} ) ( ) ;
186
- if let Some ( trait_item_use_scope) = trait_item_use_scope {
186
+ if let Some ( ( trait_item_use_scope, use_tree ) ) = trait_item_use_scope {
187
187
res. extend (
188
- t . items_with_supertraits ( sema. db )
188
+ if use_tree { t . items ( sema . db ) } else { t . items_with_supertraits ( sema. db ) }
189
189
. into_iter ( )
190
190
. filter_map ( |item| {
191
191
Definition :: from ( item)
@@ -1598,7 +1598,10 @@ fn f() {
1598
1598
fn test_trait_highlights_assoc_item_uses ( ) {
1599
1599
check (
1600
1600
r#"
1601
- trait Foo {
1601
+ trait Super {
1602
+ type SuperT;
1603
+ }
1604
+ trait Foo: Super {
1602
1605
//^^^
1603
1606
type T;
1604
1607
const C: usize;
@@ -1614,6 +1617,8 @@ impl Foo for i32 {
1614
1617
}
1615
1618
fn f<T: Foo$0>(t: T) {
1616
1619
//^^^
1620
+ let _: T::SuperT;
1621
+ //^^^^^^
1617
1622
let _: T::T;
1618
1623
//^
1619
1624
t.m();
@@ -1635,6 +1640,49 @@ fn f2<T: Foo>(t: T) {
1635
1640
) ;
1636
1641
}
1637
1642
1643
+ #[ test]
1644
+ fn test_trait_highlights_assoc_item_uses_use_tree ( ) {
1645
+ check (
1646
+ r#"
1647
+ use Foo$0;
1648
+ // ^^^ import
1649
+ trait Super {
1650
+ type SuperT;
1651
+ }
1652
+ trait Foo: Super {
1653
+ //^^^
1654
+ type T;
1655
+ const C: usize;
1656
+ fn f() {}
1657
+ fn m(&self) {}
1658
+ }
1659
+ impl Foo for i32 {
1660
+ //^^^
1661
+ type T = i32;
1662
+ // ^
1663
+ const C: usize = 0;
1664
+ // ^
1665
+ fn f() {}
1666
+ // ^
1667
+ fn m(&self) {}
1668
+ // ^
1669
+ }
1670
+ fn f<T: Foo>(t: T) {
1671
+ //^^^
1672
+ let _: T::SuperT;
1673
+ let _: T::T;
1674
+ //^
1675
+ t.m();
1676
+ //^
1677
+ T::C;
1678
+ //^
1679
+ T::f();
1680
+ //^
1681
+ }
1682
+ "# ,
1683
+ ) ;
1684
+ }
1685
+
1638
1686
#[ test]
1639
1687
fn implicit_format_args ( ) {
1640
1688
check (
You can’t perform that action at this time.
0 commit comments