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

[macro_use] on the same line as crate #83

Closed
SuperCuber opened this issue May 30, 2017 · 3 comments
Closed

[macro_use] on the same line as crate #83

SuperCuber opened this issue May 30, 2017 · 3 comments

Comments

@SuperCuber
Copy link

SuperCuber commented May 30, 2017

Currently, rustfmt will apply this change:

-#[macro_use] extern crate clap;
+#[macro_use]
+extern crate clap;

I disagree with this, #[macro_use] is closely related to the crate itself and should be on the same line.
Also, this causes a bit of confusion with examples like:

#[macro_use]
extern crate that_defines_macros;
extern crate that_also_has_macros;

extern crate that_doesnt;

It seems like #[macro_use] applies to the whole paragraph, but if it were like this:

#[macro_use] extern crate that_defines_macros;
extern crate that_also_has_macros;

It would be much more obvious what the #[macro_use] actually does.

Comments are welcome.

@nrc
Copy link
Member

nrc commented May 30, 2017

The reasoning here is that #[macro_use] is just another attribute, Rustfmt doesn't distinguish between kinds of attributes. It seems strange to me to format one way for some attributes and some other way for others.

By the way, #[macro_use] is disappearing in the long run, so the decision here may be moot.

@joshtriplett
Copy link
Member

I wouldn't have an objection if rustfmt had an option to single-line #[macro_use], but I don't think it should do so by default. I'd probably feel differently if we didn't plan to get rid of #[macro_use].

@nrc
Copy link
Member

nrc commented Jun 11, 2017

I propose closing this. We will keep the line break by default. Rustfmt might support an option for single line, but I don't think we should specify it.

@nrc nrc closed this as completed Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants