File tree Expand file tree Collapse file tree 1 file changed +53
-5
lines changed Expand file tree Collapse file tree 1 file changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ fn highlight_references(
166166 match parent {
167167 ast:: UseTree ( it) => it. syntax( ) . ancestors( ) . find( |it| {
168168 ast:: SourceFile :: can_cast( it. kind( ) ) || ast:: Module :: can_cast( it. kind( ) )
169- } ) ,
169+ } ) . zip ( Some ( true ) ) ,
170170 ast:: PathType ( it) => it
171171 . syntax( )
172172 . ancestors( )
@@ -178,14 +178,14 @@ fn highlight_references(
178178 . ancestors( )
179179 . find( |it| {
180180 ast:: Item :: can_cast( it. kind( ) )
181- } ) ,
181+ } ) . zip ( Some ( false ) ) ,
182182 _ => None ,
183183 }
184184 }
185185 } ) ( ) ;
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 {
187187 res. extend (
188- t . items_with_supertraits ( sema. db )
188+ if use_tree { t . items ( sema . db ) } else { t . items_with_supertraits ( sema. db ) }
189189 . into_iter ( )
190190 . filter_map ( |item| {
191191 Definition :: from ( item)
@@ -1598,7 +1598,10 @@ fn f() {
15981598 fn test_trait_highlights_assoc_item_uses ( ) {
15991599 check (
16001600 r#"
1601- trait Foo {
1601+ trait Super {
1602+ type SuperT;
1603+ }
1604+ trait Foo: Super {
16021605 //^^^
16031606 type T;
16041607 const C: usize;
@@ -1614,6 +1617,8 @@ impl Foo for i32 {
16141617}
16151618fn f<T: Foo$0>(t: T) {
16161619 //^^^
1620+ let _: T::SuperT;
1621+ //^^^^^^
16171622 let _: T::T;
16181623 //^
16191624 t.m();
@@ -1635,6 +1640,49 @@ fn f2<T: Foo>(t: T) {
16351640 ) ;
16361641 }
16371642
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+
16381686 #[ test]
16391687 fn implicit_format_args ( ) {
16401688 check (
You can’t perform that action at this time.
0 commit comments