Skip to content

Commit 237ea0d

Browse files
Merge #10418
10418: Add whitespace between lifetime and mut keyword in "expand macro" command r=lnicola a=nathanwhit Before, we were only adding whitespace between a lifetime and the following ident, which produced invalid code for mutable references. Before this PR: ```rust macro_rules! foo { () => { pub struct Foo<'a> { foo: &'a mut str, } }; } foo!(); // <- expand macro here ``` expanded to ```rust pub struct Foo< 'a>{ foo: & 'amut str, } ``` with this PR, it expands to ```rust pub struct Foo< 'a>{ foo: & 'a mut str, } ``` Co-authored-by: nathan.whitaker <[email protected]>
2 parents 6b10dec + a3661b3 commit 237ea0d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/ide/src/expand_macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn insert_whitespaces(syn: SyntaxNode) -> String {
159159
res.push_str("}\n");
160160
res.extend(iter::repeat(" ").take(2 * indent));
161161
}
162-
LIFETIME_IDENT if is_next(|it| it == IDENT, true) => {
162+
LIFETIME_IDENT if is_next(|it| it == IDENT || it == MUT_KW, true) => {
163163
res.push_str(token.text());
164164
res.push(' ');
165165
}

0 commit comments

Comments
 (0)