-
Notifications
You must be signed in to change notification settings - Fork 924
Add configuration stability information #2228
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
Conversation
Configurations.md
Outdated
@@ -391,6 +401,7 @@ Indentation of chain | |||
|
|||
- **Default value**: `"Block"` | |||
- **Possible values**: `"Block"`, `"Visual"` | |||
- **Stable**: ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration option (chain_indent
) wasn't in the create_config!
macro (or I missed it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this section from the doc please?
Travis failure (macOS) doesn't look like my fault
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, it's really good to have these docs. Do we have docs for unstable features in README.md? If not, could you add something there too please?
Configurations.md
Outdated
Stable options can be used directly, while unstable options are opt-in. | ||
|
||
To enable unstable options, set `unstable_features = true` in `rustfmt.toml` or pass `--unstable-options` to rustfmt, | ||
and ensure that the environment variable `CFG_RELEASE_CHANNEL` is set to `nightly`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not quite right - users need to be using a nightly toolchain, not setting that env var (which is a compile-time thing, iirc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using nightly, but unless I set the env variable I still see these messages:
Warning: can't set `use_try_shorthand = true`, unstable features are only available in nightly channel.
Warning: can't set `error_on_line_overflow = false`, unstable features are only available in nightly channel.
Warning: can't set `error_on_line_overflow_comments = false`, unstable features are only available in nightly channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I figured it out.
#2235 is a fix to inspect CFG_RELEASE_CHANNEL
at rustfmt compile time, whereas in 0.2.17 which was published before that merge, it was checked at runtime. So the rustfmt
distributed with the nightly toolchain will be built with support for unstable features, but the one distributed with the beta or stable toolchains won't.
What's the status of CFG_RELEASE_CHANNEL
when building crates not as part of the toolchain? (e.g. cargo +nightly install rustfmt-nightly
) The main advertised way of acquiring cargo fmt
in the README is still via cargo, so we should make sure that it's possible to access the unstable configuration options from there.
Configurations.md
Outdated
@@ -391,6 +401,7 @@ Indentation of chain | |||
|
|||
- **Default value**: `"Block"` | |||
- **Possible values**: `"Block"`, `"Visual"` | |||
- **Stable**: ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this section from the doc please?
I just confirmed that just doing The behavior of As far as I can tell, installing via cargo does not set As far as I can tell, testing for whether a crate is built with a certain rustc version is bound to run into endless edge cases. Doesn't rustfmt only work on nightlies, though? If my intuition is right and this is prepping for the eventual publishing of rustfmt through rustup, may I suggest flipping the condition to For the time being I've left the documentation in Configurations.md to be accurate to the version currently on crates.io. @nrc, if we get 0.2.18 published where |
TBH I am not certain about how Currently we do this: option_env!("CFG_RELEASE_CHANNEL")
.map(|c| c == "nightly")
.unwrap_or(false) @CAD97 Do you mean that we should not care about the value of option_env!("CFG_RELEASE_CHANNEL")
.map(|c| c == "nightly")
.unwrap_or(true) @nrc Do you think this works? |
Yes, that is accurate to that wall of text I wrote tired. It makes sense to default to allowing unstable options, then disabling them for stable builds. Any build outside the compiler pipeline will be with the nightly toolchain. |
@topecongiro @CAD97 yeah, I think it makes sense to assume nightly if CFG_RELEASE_CHANNEL is not set |
Filed #2249 which should enable unstable features enabling when built by cargo but not when built with |
The check was moved to compile time and was not intended to be user-facing
Rebased on top of master for CI fix and cleanliness. Also rewords dcd6ed7 slightly to better reflect its new position in history. If any lints have changed stability since I first issued this PR, ping me and I'll go through and check that the docs are accurate for all of the lints again. Still, it'd be good to see this doc merged. |
Looks good, thank you! |
Closes #2227
Stability extracted manually from config.rs. If I read #1998 correctly, the third argument to each line in the
create_config!
is a boolean indicating un/stable, which is what is now represented here as well.The
unstable_features
option is not separately documented, only at the top as how to enable unstable configuration options.