-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Attributes are evolving and now are used also to create DSL. Now, by the rising of procedural macro and the possibility to use arbitrary rust code in attributes syntax formatting attribute by simple rules based on meta and nested meta can produce some formatting that make the procedural macro DSL not clear.
For instance I have a crate of mine la10736/rstest that you can use to write tests like this:
#[rstest_parametrize(foo, bar, baz,
case(0, "a", "A"),
case(1, "b", "B")
)]
fn mytest(foo: u32, bar: &str, baz: &str) {}
Now, use rustfmt
on this file make it flat and hard to read:
#[rstest_parametrize(foo, bar, baz, case(0, 'a', 'A'), case(1, 'b', 'B'))]
fn mytest(foo: u32, bar: char, baz: char) {}
Or wrost:
#[rstest_parametrize(foo, bar, baz,
case(0, "a", "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
case(1, "b", "B")
)]
fn mytest(foo: u32, bar: &str, baz: &str) {}
in
#[rstest_parametrize(
foo,
bar,
baz,
case(0, "a", "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
case(1, "b", "B")
)]
fn mytest(foo: u32, bar: &str, baz: &str) {}
We can use rustfmt::skip::macros()
or a brand new rustfmt::skip::attributes()
to have the ability of skip attributes formatting too.
If you are ok I can work on it.