This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +35
-6
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -311,12 +311,16 @@ fn inline(
311311 } else {
312312 fn_body. clone_for_update ( )
313313 } ;
314- if let Some ( t) = body. syntax ( ) . ancestors ( ) . find_map ( ast:: Impl :: cast) . and_then ( |i| i. self_ty ( ) ) {
315- body. syntax ( )
316- . descendants_with_tokens ( )
317- . filter_map ( NodeOrToken :: into_token)
318- . filter ( |tok| tok. kind ( ) == SyntaxKind :: SELF_TYPE_KW )
319- . for_each ( |tok| ted:: replace ( tok, t. syntax ( ) ) ) ;
314+ if let Some ( imp) = body. syntax ( ) . ancestors ( ) . find_map ( ast:: Impl :: cast) {
315+ if !node. syntax ( ) . ancestors ( ) . any ( |anc| & anc == imp. syntax ( ) ) {
316+ if let Some ( t) = imp. self_ty ( ) {
317+ body. syntax ( )
318+ . descendants_with_tokens ( )
319+ . filter_map ( NodeOrToken :: into_token)
320+ . filter ( |tok| tok. kind ( ) == SyntaxKind :: SELF_TYPE_KW )
321+ . for_each ( |tok| ted:: replace ( tok, t. syntax ( ) ) ) ;
322+ }
323+ }
320324 }
321325 let usages_for_locals = |local| {
322326 Definition :: Local ( local)
@@ -1221,6 +1225,31 @@ impl A {
12211225fn main() {
12221226 A(114514);
12231227}
1228+ "# ,
1229+ )
1230+ }
1231+
1232+ #[ test]
1233+ fn inline_call_with_self_type_but_within_same_impl ( ) {
1234+ check_assist (
1235+ inline_call,
1236+ r#"
1237+ struct A(u32);
1238+ impl A {
1239+ fn f() -> Self { Self(1919810) }
1240+ fn main() {
1241+ Self::f$0();
1242+ }
1243+ }
1244+ "# ,
1245+ r#"
1246+ struct A(u32);
1247+ impl A {
1248+ fn f() -> Self { Self(1919810) }
1249+ fn main() {
1250+ Self(1919810);
1251+ }
1252+ }
12241253"# ,
12251254 )
12261255 }
You can’t perform that action at this time.
0 commit comments