File tree Expand file tree Collapse file tree 1 file changed +33
-3
lines changed
src/tools/rust-analyzer/crates/ide-completion/src/completions/item_list Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -133,8 +133,11 @@ pub(crate) fn complete_trait_impl_item_by_name(
133
133
acc,
134
134
ctx,
135
135
ImplCompletionKind :: All ,
136
- match name_ref {
137
- Some ( name) => name. syntax ( ) . text_range ( ) ,
136
+ match name_ref
137
+ . as_ref ( )
138
+ . and_then ( |name| ctx. sema . original_syntax_node_rooted ( name. syntax ( ) ) )
139
+ {
140
+ Some ( name) => name. text_range ( ) ,
138
141
None => ctx. source_range ( ) ,
139
142
} ,
140
143
impl_,
@@ -516,7 +519,7 @@ fn function_declaration(
516
519
mod tests {
517
520
use expect_test:: expect;
518
521
519
- use crate :: tests:: { check_edit, check_no_kw} ;
522
+ use crate :: tests:: { check , check_edit, check_no_kw} ;
520
523
521
524
#[ test]
522
525
fn no_completion_inside_fn ( ) {
@@ -1639,4 +1642,31 @@ impl DesugaredAsyncTrait for () {
1639
1642
"# ,
1640
1643
) ;
1641
1644
}
1645
+
1646
+ #[ test]
1647
+ fn within_attr_macro ( ) {
1648
+ check (
1649
+ r#"
1650
+ //- proc_macros: identity
1651
+ trait Trait {
1652
+ fn foo(&self) {}
1653
+ fn bar(&self) {}
1654
+ fn baz(&self) {}
1655
+ }
1656
+
1657
+ #[proc_macros::identity]
1658
+ impl Trait for () {
1659
+ f$0
1660
+ }
1661
+ "# ,
1662
+ expect ! [ [ r#"
1663
+ me fn bar(..)
1664
+ me fn baz(..)
1665
+ me fn foo(..)
1666
+ md proc_macros
1667
+ kw crate::
1668
+ kw self::
1669
+ "# ] ] ,
1670
+ ) ;
1671
+ }
1642
1672
}
You can’t perform that action at this time.
0 commit comments