Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format empty dyn without trailing space #3709

Closed
dtolnay opened this issue Jul 28, 2019 · 3 comments · Fixed by #3737
Closed

Format empty dyn without trailing space #3709

dtolnay opened this issue Jul 28, 2019 · 3 comments · Fixed by #3737
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors poor-formatting
Milestone

Comments

@dtolnay
Copy link
Member

dtolnay commented Jul 28, 2019

macro_rules! token {
    ($t:tt) => {};
}

fn main() {
    token!(dyn);
}

As of current master, in 2018 edition mode rustfmt applies the following diff:

-     token!(dyn);
+     token!(dyn );

I would prefer for there not to be a trailing space inserted. @topecongiro -- I believe this should fall under #3333.

Affects the Token! macro in Syn.

@topecongiro topecongiro added good first issue Issues up for grabs, also good candidates for new rustfmt contributors poor-formatting labels Jul 28, 2019
@topecongiro topecongiro added this to the 1.4.1 milestone Jul 28, 2019
@KamWithK
Copy link

KamWithK commented Aug 2, 2019

I would like to fix this.
I've had a look at #3333 however can't find token!(dyn) in the diffs

@topecongiro topecongiro modified the milestones: 1.4.3, 1.4.4 Aug 2, 2019
@topecongiro
Copy link
Contributor

@KamWithK Thanks! IIRC all you need to do is to flip the order of these two function calls:

rustfmt/src/macros.rs

Lines 306 to 309 in 3adfb08

if let Some(arg) = parse_macro_arg(&mut parser) {
arg_vec.push(arg);
} else if let Some(arg) = check_keyword(&mut parser) {
arg_vec.push(arg);

When you create a PR, please do not forget to add a test :). Also, note that this issue is reproducible only when we are using edition 2018.

@topecongiro topecongiro modified the milestones: 1.4.4, 1.4.5 Aug 6, 2019
@KamWithK
Copy link

KamWithK commented Aug 8, 2019

Hey, just wanted to let you know that I won't be able to work on this as a result of my lack of time right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors poor-formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants