Skip to content

[unstable option] inline_attribute_width #3343

Open
@dhardy

Description

@dhardy

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).

Activity

rchaser53

rchaser53 commented on Feb 19, 2019

@rchaser53
Contributor

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

changed the title [-]Allow inline attributes[/-] [+][unstable option] inline_attribute_width[/+] on Mar 20, 2019
soruh

soruh commented on Feb 22, 2020

@soruh

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

dhardy commented on Oct 14, 2022

@dhardy
Author

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    unstable optiontracking issue of an unstable option

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dhardy@scampi@rchaser53@topecongiro@soruh

        Issue actions

          [unstable option] inline_attribute_width · Issue #3343 · rust-lang/rustfmt