Skip to content

Breaking changes in rustfmt with 1.44.0 #73078

Closed
@Elrendio

Description

@Elrendio

Important

This is not a breaking change in the compiler. Sorry if it's not the place for such issue. However this has high chance to break a lot of continuous integrations and is highly linked to rust update.

Description

Default version for rustfmt in rust 1.44.0 is 1.4.14-stable (e417356 2020-04-21) when in 1.43.1 it was 1.4.12. rustfmt removed the support for #![cfg_attr(rustfmt, rustfmt_skip)] and #[cfg_attr(rustfmt, rustfmt_skip)] in version 1.4.13 (this may be a bug, I don't know). Which means lint that was passing in 1.43.1 might not in 1.44.0.

Other implications

Moreover I believe #![rustfmt:skip] doesn't work, you need to add #[rustfmt::skip] mod my_mod; which is quite problematic with generated code. For example I have a lot of crate using rust-protobuf to generate rust structs for grpc. Before 1.44.0 all the codegen was in files my_proto.rs and my_proto_grpc.rs.

Since the rust-protobuf crate was adding #![cfg_attr(rustfmt, rustfmt_skip)] at the beginning of each file you would just have to include them with mod my_proto.rs. And now you need to change to #[rustfmt:skip] mod my_protos.rs which is less ergonomic because I'd like to have all the dirtyness of generated code isolated in the generated files.

Suggestions

Lastly I coudln't find any notes on #[cfg_attr(rustfmt, rustfmt_skip)] vs #[rustfmt:skip] in recent release notes of either rust or rustfmt. I had to scroll down to the release note of rust 1.30.0 to learn about #[rustfmt:skip] and guess #[cfg_attr(rustfmt, rustfmt_skip)] might have been deprecated recently. I think it would be nice to mention it either in some rustfmt release note or rust 1.44.0 with an explanation on how to solve the problem.

Have a excellent day !

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions