aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/handlers/add_missing_impl_members.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-25 15:57:15 +0100
committerGitHub <[email protected]>2020-09-25 15:57:15 +0100
commit662ed41ebcb1cd221b32be95d08b5bf5f10ae525 (patch)
tree943ef1bbcd95d9854975da1d2d9c6a3aa24e11ba /crates/assists/src/handlers/add_missing_impl_members.rs
parentdc09f1597fea78900a6b67d4871edfbb6fafbcdc (diff)
parent747f6f64d7f8fae3a40be6ffacc9640bca068bd0 (diff)
Merge #6073
6073: Dont unnecessarily unnest imports r=matklad a=Veykril Fixes #6071 This has the side effect that paths that refer to items inside of the current module get prefixed with `self`. Changing this behavior is unfortunately not straightforward should it be unwanted, though I don't see a problem with this as prefixing imports like this with `self` is what I do personally anyways 😅. You can see what I mean with this in one of the tests which had to be changed in `crates/ssr/src/tests.rs`. There is one test that i still have to look at though, ~~which I by accident pushed with `#[ignore]` on it~~, which is `different_crate_renamed`, for some reason this now doesn't use the crate alias. This also makes me believe that aliases in general will break with this. So maybe this is not as straight forwards as I'd hoped for, but I don't really know how aliases work here. Edit: The failing test should work now Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/assists/src/handlers/add_missing_impl_members.rs')
-rw-r--r--crates/assists/src/handlers/add_missing_impl_members.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs
index 8df1d786b..1ac5fefd6 100644
--- a/crates/assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/assists/src/handlers/add_missing_impl_members.rs
@@ -415,6 +415,41 @@ impl foo::Foo for S {
415 } 415 }
416 416
417 #[test] 417 #[test]
418 fn test_qualify_path_2() {
419 check_assist(
420 add_missing_impl_members,
421 r#"
422mod foo {
423 pub mod bar {
424 pub struct Bar;
425 pub trait Foo { fn foo(&self, bar: Bar); }
426 }
427}
428
429use foo::bar;
430
431struct S;
432impl bar::Foo for S { <|> }"#,
433 r#"
434mod foo {
435 pub mod bar {
436 pub struct Bar;
437 pub trait Foo { fn foo(&self, bar: Bar); }
438 }
439}
440
441use foo::bar;
442
443struct S;
444impl bar::Foo for S {
445 fn foo(&self, bar: bar::Bar) {
446 ${0:todo!()}
447 }
448}"#,
449 );
450 }
451
452 #[test]
418 fn test_qualify_path_generic() { 453 fn test_qualify_path_generic() {
419 check_assist( 454 check_assist(
420 add_missing_impl_members, 455 add_missing_impl_members,