diff options
| author | Chayim Refael Friedman <chayimfr@gmail.com> | 2025-07-24 09:41:20 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-24 09:41:20 +0000 |
| commit | d976ef8ae494cc8fd6672d43c49377e43c2876b5 (patch) | |
| tree | e24eb6b6d69749fa22496e79dcfd1a7832cc40f9 | |
| parent | cf886546fc6e58075dfef0100a16ac94c927c455 (diff) | |
| parent | abddbc5bcab8e731d07c2bfbeae966ed28a33efd (diff) | |
| download | rust-d976ef8ae494cc8fd6672d43c49377e43c2876b5.tar.gz rust-d976ef8ae494cc8fd6672d43c49377e43c2876b5.zip | |
Merge pull request #20297 from A4-Tacks/fix-ws-gen-trait-from-impl
Fix generate_trait_from_impl whitespace after vis
| -rw-r--r-- | src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_trait_from_impl.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_trait_from_impl.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_trait_from_impl.rs index 154b502e1bf..92a4bd35b3e 100644 --- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_trait_from_impl.rs +++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/generate_trait_from_impl.rs @@ -3,7 +3,7 @@ use ide_db::assists::AssistId; use syntax::{ AstNode, SyntaxKind, T, ast::{ - self, HasGenericParams, HasName, + self, HasGenericParams, HasName, HasVisibility, edit_in_place::{HasVisibilityEdit, Indent}, make, }, @@ -164,6 +164,12 @@ pub(crate) fn generate_trait_from_impl(acc: &mut Assists, ctx: &AssistContext<'_ /// `E0449` Trait items always share the visibility of their trait fn remove_items_visibility(item: &ast::AssocItem) { if let Some(has_vis) = ast::AnyHasVisibility::cast(item.syntax().clone()) { + if let Some(vis) = has_vis.visibility() + && let Some(token) = vis.syntax().next_sibling_or_token() + && token.kind() == SyntaxKind::WHITESPACE + { + ted::remove(token); + } has_vis.set_visibility(None); } } @@ -333,11 +339,11 @@ impl F$0oo { struct Foo; trait NewTrait { - fn a_func() -> Option<()>; + fn a_func() -> Option<()>; } impl NewTrait for Foo { - fn a_func() -> Option<()> { + fn a_func() -> Option<()> { Some(()) } }"#, |
