Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Auto merge of #1416 - Xanewok:allow-unstable-in-dev, r=Xanewok
Browse files Browse the repository at this point in the history
Allow unstable features under "dev" channel

This brings it in line with what's used by Rust and Rustfmt.

Closes #1414.

r? @jsgf

@bors delegate=jsgf (hopefully this works)
  • Loading branch information
bors committed Apr 6, 2019
2 parents 4834d4f + 8825e14 commit 6e14b56
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions rls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ impl<T> AsRef<T> for Inferrable<T> {
}
}

/// Returns whether unstable features are allowed.
///
/// It is very similar to what rustfmt uses [[1]] - it relies on
/// CFG_RELEASE_CHANNEL being set by Rust bootstrap.
/// In case the env var is missing, we assume that we're built by Cargo and are
/// using nightly since that's the only channel supported right now.
///
/// [1]: https://github.com/rust-lang/rustfmt/blob/dfa94d150555da40780413d7f1a1378565208c99/src/config/config_type.rs#L53-L67
pub fn unstable_features_allowed() -> bool {
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
}

/// RLS configuration options.
#[derive(Clone, Debug, Deserialize)]
#[allow(missing_docs)]
Expand Down Expand Up @@ -251,10 +263,7 @@ impl Config {
/// Ensures that unstable options are only allowed if `unstable_features` is
/// true and that is not allowed on stable release channels.
pub fn normalise(&mut self) {
let allow_unstable =
option_env!("CFG_RELEASE_CHANNEL").map(|c| c == "nightly").unwrap_or(true);

if !allow_unstable {
if !unstable_features_allowed() {
if self.unstable_features {
eprintln!("`unstable_features` setting can only be used on nightly channel");
}
Expand Down

0 comments on commit 6e14b56

Please sign in to comment.