rust-protobuf icon indicating copy to clipboard operation
rust-protobuf copied to clipboard

warning about rustfmt::skip with nightly rustc

Open martinvonz opened this issue 4 years ago • 11 comments

I updated my rust toolchain today and it seems it started failing on rust-protobuf's generated code since then. The failures look like this:

  |
9 | #![rustfmt::skip]
  |    ^^^^^^^^^^^^^
  |
  = note: `#[deny(soft_unstable)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>

martinvonz avatar Mar 15 '21 05:03 martinvonz

I have the same problem here.

chenju2k6 avatar Mar 16 '21 03:03 chenju2k6

I have the same problem here.

version:nightly-x86_64-pc-windows-msvc unchanged - rustc 1.52.0-nightly (107896c32 2021-03-15)

ruaruagerry avatar Mar 16 '21 09:03 ruaruagerry

This is due to https://github.com/rust-lang/rust/pull/82399 although I can't figure out why we didn't see a warning before.

nrc avatar Mar 16 '21 21:03 nrc

In case it helps someone: a workaround is to add #![allow(soft_unstable)] to your crate root (such as lib.rs).

martinvonz avatar Mar 17 '21 05:03 martinvonz

Does anyone know how to fix the issue? (I don't have time right now to investigate, will return in a couple days, but right now I can commit a fix if the fix is known).

stepancheg avatar Mar 18 '21 02:03 stepancheg

You can use #![cfg_attr(rustfmt, rustfmt_skip)] instead.

BusyJay avatar Mar 18 '21 03:03 BusyJay

About a year ago we migrated from rustfmt_skip to rustfmt::skip because rustfmt_skip became deprecated. Did they undeprecate it back?

stepancheg avatar Mar 18 '21 03:03 stepancheg

Moreover, rustfmt officially recommends using rustfmt::skip and does not even mention rustfmt_skip.

stepancheg avatar Mar 18 '21 03:03 stepancheg

I think the problem is using it as an inner attribute (#![...]) rather than an outer attribute (#[...]). I'm not up to speed with why this is a problem now though. rustfmt_skip in cfg_attr is a desugaring, I think.

nrc avatar Mar 18 '21 03:03 nrc

OK, I did this as temporary workaround until we find the proper fix: https://github.com/stepancheg/rust-protobuf/commit/6069c64ed162edcc4d89e000ef7abf027638548c.

Any reason not to release a new stable version with this change?

stepancheg avatar Mar 18 '21 05:03 stepancheg

Published version 2.22.1 with the workaround. Let me know if similar fix is needed in older 2.x versions.

Keeping this issue open because we need to find a proper fix.

stepancheg avatar Mar 18 '21 19:03 stepancheg