Skip to content

Code within stringify!(...) and assert_eq!(...) not being formatted very well #1919

Closed
@fitzgen

Description

@fitzgen

input.rs:

# [ test ] fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation ( ) { assert_eq ! ( :: std :: mem :: size_of :: < HandleWithDtor < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Size of template specialization: " , stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > ) ) ) ; assert_eq ! ( :: std :: mem :: align_of :: < HandleWithDtor < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > ) ) ) ; }

Run rustfmt:

$ rustup run nightly rustfmt --version
0.2.2-nightly ( )
$ rustup run nightly rustfmt < input.rs > output.rs

And here is output.rs:

#[test]
fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
    assert_eq!(
        ::std::mem::size_of::<HandleWithDtor<::std::os::raw::c_int>>(),
        8usize,
        concat!(
            "Size of template specialization: ",
            stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > )
        )
    );
    assert_eq ! ( :: std :: mem :: align_of :: < HandleWithDtor < :: std :: os :: raw :: c_int > > ( ) , 8usize , concat ! ( "Alignment of template specialization: " , stringify ! ( HandleWithDtor < :: std :: os :: raw :: c_int > ) ) );
}

Note that ::std::os::raw::c_int still has a bunch of spaces between tokens, as do the actual macro invocations, eg stringify ! ( ... ) instead of stringify!(...).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions