File tree 1 file changed +32
-0
lines changed
crates/ide-assists/src/handlers
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ fn add_missing_impl_members_inner(
109
109
110
110
if ctx. token_at_offset ( ) . all ( |t| {
111
111
t. parent_ancestors ( )
112
+ . take_while ( |node| node != impl_def. syntax ( ) )
112
113
. any ( |s| ast:: BlockExpr :: can_cast ( s. kind ( ) ) || ast:: ParamList :: can_cast ( s. kind ( ) ) )
113
114
} ) {
114
115
return None ;
@@ -1486,4 +1487,35 @@ impl Trait for () {
1486
1487
}"# ,
1487
1488
)
1488
1489
}
1490
+
1491
+ #[ test]
1492
+ fn test_works_inside_function ( ) {
1493
+ check_assist (
1494
+ add_missing_impl_members,
1495
+ r#"
1496
+ trait Tr {
1497
+ fn method();
1498
+ }
1499
+ fn main() {
1500
+ struct S;
1501
+ impl Tr for S {
1502
+ $0
1503
+ }
1504
+ }
1505
+ "# ,
1506
+ r#"
1507
+ trait Tr {
1508
+ fn method();
1509
+ }
1510
+ fn main() {
1511
+ struct S;
1512
+ impl Tr for S {
1513
+ fn method() {
1514
+ ${0:todo!()}
1515
+ }
1516
+ }
1517
+ }
1518
+ "# ,
1519
+ ) ;
1520
+ }
1489
1521
}
You can’t perform that action at this time.
0 commit comments