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

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

Closed
fitzgen opened this issue Aug 25, 2017 · 3 comments
Closed

Comments

@fitzgen
Copy link
Member

fitzgen commented Aug 25, 2017

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

@fitzgen
Copy link
Member Author

fitzgen commented Aug 25, 2017

Also, thanks for the quick responses to my other issues filed :)

@nrc
Copy link
Member

nrc commented Aug 27, 2017

Hmm, stringify might not be parsing as a function call, but assert_eq looks like it should, it could be the nested macros, but then, I'd expect the first assert_eq not to format either.

@topecongiro
Copy link
Contributor

Hmm, stringify might not be parsing as a function call, but assert_eq looks like it should, it could be the nested macros, but then, I'd expect the first assert_eq not to format either.

I think this is hitting the same issue as #1742.

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