rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

[unstable option] unstable_features

Open scampi opened this issue 6 years ago • 8 comments

Tracking issue for unstable_features

scampi avatar Feb 13 '19 22:02 scampi

So to use unstable_features that allow to opt in unstable feature, itself need to be in already unstable channel because it itself not stable.

There is something I miss

Stargateur avatar Jul 17 '19 19:07 Stargateur

According to this issue it behaves the way it is supposed to behave.

However, I'd still argue that it should behave differently.

Our usecase is to compile our code against stable Rust but we like to use unstable formatting features. Currently, this forces us install two versions of Rust in CI which

  • a) causes configuration complexity in our CI setup
  • b) extends the time our CI builds take by having to download two toolchains
  • c) causes complexity in our builds scripts because we have to call cargo fmt with a +nightly-XXXX option.

thomaseizinger avatar Jul 18 '19 02:07 thomaseizinger

On 2.0, we will remove this and enable all unstable features on the nightly channel by default. On the stable, every unstable feature will be disabled.

topecongiro avatar Jan 14 '20 12:01 topecongiro

Just to clarify: There is going to be no way of using unstable formatting features on the stable release channel? :( So we always have to install two versions of Rust in CI, just to check formatting and then compile with stable?

I believe stable/nightly rust and stable/unstable formatting features are orthogonal to each other.

thomaseizinger avatar Jan 14 '20 23:01 thomaseizinger

This will need to be re-decided for 1.x

karyon avatar Nov 14 '21 08:11 karyon

So we always have to install two versions of Rust in CI, just to check formatting and then compile with stable?

I totally agree on this one. It's really annoying, and it's the thing across entire rust toolchain. Why do we need to explicitly install the nightly version of the toolchain to use an unstable feature? Why is it not enough to pass --unstable-features flag to "sign a contract that I'm using unstable". This makes it annoying to use unstable features and provide feedback for them so much that one would rather give up on the idea and wait until the feature becomes stable.

With rustc though there is at least a workaround of using RUSTC_BOOTSTRAP, but with rustfmt you have to explicitly download and pin a specific nightly version because you don't want CI to break on occasion.

Veetaha avatar Dec 22 '23 11:12 Veetaha

For anyone else who lands here: YOU CAN USE UNSTABLE FEATURES ON STABLE TOOLCHAN, but you have to specify them via the CLI parameters like this:

cargo fmt -- --config unstable_features=true --config error_on_unformatted=true

For the reasoning why you can use them only via CLI and can't use them via a config file see https://github.com/rust-lang/rustfmt/issues/5511#issuecomment-1867600019

Veetaha avatar Dec 22 '23 12:12 Veetaha

For anyone else who lands here: YOU CAN USE UNSTABLE FEATURES ON STABLE TOOLCHAN, but you have to specify them via the CLI parameters like this:

cargo fmt -- --config unstable_features=true --config error_on_unformatted=true

For the reasoning why you can use them only via CLI and can't use them via a config file see #5511 (comment)

I was confused about this and thought this meant that I could enable just the unstable_features via cli and that would cause the rustfmt.toml config file values to just work, but you have to enable every config option that you'd like to use. This seems like an unfortunate and non-intuitive way of making this work.

joshka avatar May 22 '24 22:05 joshka