11200: Always put a space after dyn in macro pretty-printing r=Veykril a=jplatte

Fixes #11100.

Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
This commit is contained in:
bors[bot] 2022-01-05 20:04:49 +00:00 committed by GitHub
commit 149981fbfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View File

@ -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!()}
}
}
"#,
)

View File

@ -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![;] => {