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

Commit

Permalink
Rephrase unstable features helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Apr 6, 2019
1 parent fc3448f commit 8825e14
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ impl<T> AsRef<T> for Inferrable<T> {
}
}

/// Returns whether RLS was built using nightly channel.
/// Returns whether unstable features are allowed.
///
/// It is very similar to what rust and rustfmt uses [1] - it relies on
/// 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 is_nightly() -> bool {
pub fn unstable_features_allowed() -> bool {
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
}

Expand Down Expand Up @@ -262,7 +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) {
if !is_nightly() {
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 8825e14

Please sign in to comment.