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

[unstable option] inline_attribute_width #3343

Open
dhardy opened this issue Feb 12, 2019 · 3 comments
Open

[unstable option] inline_attribute_width #3343

dhardy opened this issue Feb 12, 2019 · 3 comments
Labels
unstable option tracking issue of an unstable option

Comments

@dhardy
Copy link

dhardy commented Feb 12, 2019

As you can see from this diff, inline-attributes are viable and sometimes even useful (specifically: making diffs align properly, which has been an issue in Rand's lib.rs quite a few times).

-#[cfg(feature="alloc")] use core::slice;
+#[cfg(feature = "alloc")]
+use core::slice;

rustfmt is forcing multi-line attributes everywhere. I would like an option for inline attributes (when small).

@rchaser53
Copy link
Contributor

I also want this feature a bit, so I send the PR.

@scampi scampi added unstable option tracking issue of an unstable option and removed feature-request labels Feb 23, 2019
@scampi scampi changed the title Allow inline attributes [unstable option] inline_attribute_width Mar 20, 2019
@soruh
Copy link

soruh commented Feb 22, 2020

It appears like this does not work within extern blocks.

i.e.:

extern "C" {
    #[no_mangle]
    fn sprintf(_: *mut c_char, _: *const c_char, ...) -> c_int;
}

should be formatted to this:

extern "C" {
    #[no_mangle] fn sprintf(_: *mut c_char, _: *const c_char, ...) -> c_int;
}

but isn't

versions:

> cargo -V       
cargo 1.43.0-nightly (e02974078 2020-02-18)
> cargo fmt -- -V
rustfmt 1.4.12-nightly (9f53665 2020-02-10)

rustfmt.toml

edition = "2018"
version = "Two"
inline_attribute_width = 100
unstable_features = true

@dhardy
Copy link
Author

dhardy commented Oct 14, 2022

This also doesn't work within #5538.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unstable option tracking issue of an unstable option
Projects
None yet
Development

No branches or pull requests

5 participants