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

Commit

Permalink
Allow unstable features under "dev" channel
Browse files Browse the repository at this point in the history
This brings it in line with what's used by Rust and Rustfmt.
  • Loading branch information
Xanewok committed Apr 5, 2019
1 parent 7a83edc commit fc3448f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions rls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ impl<T> AsRef<T> for Inferrable<T> {
}
}

/// Returns whether RLS was built using nightly channel.
///
/// It is very similar to what rust and 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 is_nightly() -> 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 +262,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 !is_nightly() {
if self.unstable_features {
eprintln!("`unstable_features` setting can only be used on nightly channel");
}
Expand Down

0 comments on commit fc3448f

Please sign in to comment.