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

Commit fc3448f

Browse files
committed
Allow unstable features under "dev" channel
This brings it in line with what's used by Rust and Rustfmt.
1 parent 7a83edc commit fc3448f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

rls/src/config.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ impl<T> AsRef<T> for Inferrable<T> {
103103
}
104104
}
105105

106+
/// Returns whether RLS was built using nightly channel.
107+
///
108+
/// It is very similar to what rust and rustfmt uses [1] - it relies on
109+
/// CFG_RELEASE_CHANNEL being set by Rust bootstrap.
110+
/// In case the env var is missing, we assume that we're built by Cargo and are
111+
/// using nightly since that's the only channel supported right now.
112+
/// [1]: https://github.com/rust-lang/rustfmt/blob/dfa94d150555da40780413d7f1a1378565208c99/src/config/config_type.rs#L53-L67
113+
pub fn is_nightly() -> bool {
114+
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
115+
}
116+
106117
/// RLS configuration options.
107118
#[derive(Clone, Debug, Deserialize)]
108119
#[allow(missing_docs)]
@@ -251,10 +262,7 @@ impl Config {
251262
/// Ensures that unstable options are only allowed if `unstable_features` is
252263
/// true and that is not allowed on stable release channels.
253264
pub fn normalise(&mut self) {
254-
let allow_unstable =
255-
option_env!("CFG_RELEASE_CHANNEL").map(|c| c == "nightly").unwrap_or(true);
256-
257-
if !allow_unstable {
265+
if !is_nightly() {
258266
if self.unstable_features {
259267
eprintln!("`unstable_features` setting can only be used on nightly channel");
260268
}

0 commit comments

Comments
 (0)