@@ -134,8 +134,9 @@ fn add_missing_impl_members_inner(
134
134
return None ;
135
135
}
136
136
137
- let file_id = ctx. frange . file_id ;
138
137
let db = ctx. db ;
138
+ let file_id = ctx. frange . file_id ;
139
+ let trait_file_id = trait_. source ( db) . file_id ;
139
140
140
141
ctx. add_assist ( AssistId ( assist_id) , label, |edit| {
141
142
let n_existing_items = impl_item_list. impl_items ( ) . count ( ) ;
@@ -157,10 +158,10 @@ fn add_missing_impl_members_inner(
157
158
let items = missing_items
158
159
. into_iter ( )
159
160
. map ( |it| {
160
- substitute_type_params ( db, hir:: InFile :: new ( file_id . into ( ) , it) , & substs_by_param)
161
+ substitute_type_params ( db, hir:: InFile :: new ( trait_file_id , it) , & substs_by_param)
161
162
} )
162
163
. map ( |it| match module {
163
- Some ( module) => qualify_paths ( db, hir:: InFile :: new ( file_id . into ( ) , it) , module) ,
164
+ Some ( module) => qualify_paths ( db, hir:: InFile :: new ( trait_file_id , it) , module) ,
164
165
None => it,
165
166
} )
166
167
. map ( |it| match it {
@@ -259,6 +260,7 @@ fn qualify_paths<N: AstNode>(db: &impl HirDatabase, node: hir::InFile<N>, from:
259
260
match resolution {
260
261
PathResolution :: Def ( def) => {
261
262
let found_path = from. find_path ( db, def) ?;
263
+ // TODO fix type arg replacements being qualified
262
264
let args = p
263
265
. segment ( )
264
266
. and_then ( |s| s. type_arg_list ( ) )
@@ -523,6 +525,32 @@ impl foo::Foo<u32> for S {
523
525
) ;
524
526
}
525
527
528
+ #[ test]
529
+ fn test_substitute_param_no_qualify ( ) {
530
+ // when substituting params, the substituted param should not be qualified!
531
+ check_assist (
532
+ add_missing_impl_members,
533
+ "
534
+ mod foo {
535
+ trait Foo<T> { fn foo(&self, bar: T); }
536
+ pub struct Param;
537
+ }
538
+ struct Param;
539
+ struct S;
540
+ impl foo::Foo<Param> for S { <|> }" ,
541
+ "
542
+ mod foo {
543
+ trait Foo<T> { fn foo(&self, bar: T); }
544
+ pub struct Param;
545
+ }
546
+ struct Param;
547
+ struct S;
548
+ impl foo::Foo<Param> for S {
549
+ <|>fn foo(&self, bar: Param) { unimplemented!() }
550
+ }" ,
551
+ ) ;
552
+ }
553
+
526
554
#[ test]
527
555
fn test_qualify_path_associated_item ( ) {
528
556
check_assist (
0 commit comments