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

Commit 1838f1b

Browse files
committed
Only permit unstable features on nightly
And make workspace mode unstable
1 parent 51b77e0 commit 1838f1b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/actions/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,10 @@ impl ActionHandler {
802802
.and_then(|value| Config::deserialize(value));
803803

804804
let new_config = match config {
805-
Ok(value) => value,
805+
Ok(mut value) => {
806+
value.normalise();
807+
value
808+
}
806809
Err(err) => {
807810
debug!("Received unactionable config: {:?} (error: {:?})", params.settings, err);
808811
return;

src/config.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub struct Config {
111111

112112
impl Default for Config {
113113
fn default() -> Config {
114-
Config {
114+
let mut result = Config {
115115
sysroot: None,
116116
target: None,
117117
rustflags: None,
@@ -127,7 +127,9 @@ impl Default for Config {
127127
clear_env_rust_log: true,
128128
build_on_save: false,
129129
use_crate_blacklist: true,
130-
}
130+
};
131+
result.normalise();
132+
result
131133
}
132134
}
133135

@@ -139,6 +141,27 @@ impl Config {
139141
*self = new;
140142
}
141143

144+
/// Ensures that unstable options are only allowed if `unstable_features` is
145+
/// true and that is not allowed on stable release channels.
146+
pub fn normalise(&mut self) {
147+
let allow_unstable = option_env!("CFG_RELEASE_CHANNEL").map(|c| c == "nightly").unwrap_or(true);
148+
149+
if !allow_unstable {
150+
if self.unstable_features {
151+
eprintln!("`unstable_features` setting can only be used on nightly channel");
152+
}
153+
self.unstable_features = false;
154+
}
155+
156+
if !self.unstable_features {
157+
if self.workspace_mode {
158+
eprintln!("`workspace_mode` setting is unstable; ignored");
159+
}
160+
self.workspace_mode = false;
161+
self.analyze_package = None;
162+
}
163+
}
164+
142165
pub fn needs_inference(&self) -> bool {
143166
match (&self.build_lib, &self.build_bin) {
144167
(&Inferrable::None, _) |

0 commit comments

Comments
 (0)