Skip to content

Commit 149981f

Browse files
bors[bot]jplatte
andauthored
Merge #11200
11200: Always put a space after dyn in macro pretty-printing r=Veykril a=jplatte Fixes #11100. Co-authored-by: Jonas Platte <[email protected]>
2 parents 97838b1 + b8f4667 commit 149981f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

crates/ide_assists/src/handlers/add_missing_impl_members.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,47 @@ struct Foo(usize);
938938
impl FooB for Foo {
939939
$0fn foo< 'lt>(& 'lt self){}
940940
941+
}
942+
"#,
943+
)
944+
}
945+
946+
#[test]
947+
fn macro_trait_dyn_absolute_path() {
948+
// https://github.com/rust-analyzer/rust-analyzer/issues/11100
949+
check_assist(
950+
add_missing_impl_members,
951+
r#"
952+
macro_rules! foo {
953+
() => {
954+
trait MacroTrait {
955+
fn trait_method(_: &dyn ::core::marker::Sized);
956+
}
957+
}
958+
}
959+
foo!();
960+
struct Foo;
961+
962+
impl MacroTrait for Foo {
963+
$0
964+
}
965+
"#,
966+
r#"
967+
macro_rules! foo {
968+
() => {
969+
trait MacroTrait {
970+
fn trait_method(_: &dyn ::core::marker::Sized);
971+
}
972+
}
973+
}
974+
foo!();
975+
struct Foo;
976+
977+
impl MacroTrait for Foo {
978+
fn trait_method(_: &dyn ::core::marker::Sized) {
979+
${0:todo!()}
980+
}
981+
941982
}
942983
"#,
943984
)

crates/ide_db/src/helpers/insert_whitespace_into_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
8888
LIFETIME_IDENT if is_next(|it| is_text(it), true) => {
8989
mods.push(do_ws(after, tok));
9090
}
91-
AS_KW => {
91+
AS_KW | DYN_KW => {
9292
mods.push(do_ws(after, tok));
9393
}
9494
T![;] => {

0 commit comments

Comments
 (0)