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 +38
-2
lines changed
crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -363,10 +363,10 @@ fn inline(
363363 . collect ( ) ;
364364
365365 if function. self_param ( sema. db ) . is_some ( ) {
366- let this = || make:: name_ref ( "this" ) . syntax ( ) . clone_for_update ( ) ;
366+ let this = || make:: name_ref ( "this" ) . syntax ( ) . clone_for_update ( ) . first_token ( ) . unwrap ( ) ;
367367 if let Some ( self_local) = params[ 0 ] . 2 . as_local ( sema. db ) {
368368 usages_for_locals ( self_local)
369- . flat_map ( |FileReference { name, range, .. } | match name {
369+ . filter_map ( |FileReference { name, range, .. } | match name {
370370 ast:: NameLike :: NameRef ( _) => Some ( body. syntax ( ) . covering_element ( range) ) ,
371371 _ => None ,
372372 } )
@@ -680,6 +680,42 @@ impl Foo {
680680 }
681681}
682682
683+ fn main() {
684+ let x = {
685+ let ref this = Foo(3);
686+ Foo(this.0 + 2)
687+ };
688+ }
689+ "# ,
690+ ) ;
691+ }
692+
693+ #[ test]
694+ fn generic_method_by_ref ( ) {
695+ check_assist (
696+ inline_call,
697+ r#"
698+ struct Foo(u32);
699+
700+ impl Foo {
701+ fn add<T>(&self, a: u32) -> Self {
702+ Foo(self.0 + a)
703+ }
704+ }
705+
706+ fn main() {
707+ let x = Foo(3).add$0::<usize>(2);
708+ }
709+ "# ,
710+ r#"
711+ struct Foo(u32);
712+
713+ impl Foo {
714+ fn add<T>(&self, a: u32) -> Self {
715+ Foo(self.0 + a)
716+ }
717+ }
718+
683719fn main() {
684720 let x = {
685721 let ref this = Foo(3);
You can’t perform that action at this time.
0 commit comments