From f5b789b1dce1ab703f7ee1740819406cf82520b9 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 5 Jan 2022 18:04:36 +0100 Subject: [PATCH 1/2] Add failing test case for issue 11100 --- .../src/handlers/add_missing_impl_members.rs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/crates/ide_assists/src/handlers/add_missing_impl_members.rs b/crates/ide_assists/src/handlers/add_missing_impl_members.rs index a10eca10d119..b6af72cbac54 100644 --- a/crates/ide_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ide_assists/src/handlers/add_missing_impl_members.rs @@ -938,6 +938,47 @@ struct Foo(usize); impl FooB for Foo { $0fn foo< 'lt>(& 'lt self){} +} +"#, + ) + } + + #[test] + fn macro_trait_dyn_absolute_path() { + // https://github.com/rust-analyzer/rust-analyzer/issues/11100 + check_assist( + add_missing_impl_members, + r#" +macro_rules! foo { + () => { + trait MacroTrait { + fn trait_method(_: &dyn ::core::marker::Sized); + } + } +} +foo!(); +struct Foo; + +impl MacroTrait for Foo { + $0 +} +"#, + r#" +macro_rules! foo { + () => { + trait MacroTrait { + fn trait_method(_: &dyn ::core::marker::Sized); + } + } +} +foo!(); +struct Foo; + +impl MacroTrait for Foo { + fn trait_method(_: &dyn ::core::marker::Sized) { + ${0:todo!()} + } + } "#, ) From b8f4667aa9ff18ebc7730b7b69a0e0f616ef709a Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 5 Jan 2022 18:04:44 +0100 Subject: [PATCH 2/2] Always put a space after `dyn` in macro pretty-printing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … regardless of whether the next symbol is punctuation or not. Fixes issue 11100. --- crates/ide_db/src/helpers/insert_whitespace_into_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ide_db/src/helpers/insert_whitespace_into_node.rs b/crates/ide_db/src/helpers/insert_whitespace_into_node.rs index 251a4caa1327..9d31966cea67 100644 --- a/crates/ide_db/src/helpers/insert_whitespace_into_node.rs +++ b/crates/ide_db/src/helpers/insert_whitespace_into_node.rs @@ -88,7 +88,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode { LIFETIME_IDENT if is_next(|it| is_text(it), true) => { mods.push(do_ws(after, tok)); } - AS_KW => { + AS_KW | DYN_KW => { mods.push(do_ws(after, tok)); } T![;] => {