Skip to content

Commit 1b11393

Browse files
authored
Merge pull request #3903 from tgross35/update-version-cmd
Update `rustc_version_cmd`
2 parents 37f0e1e + cdf12d2 commit 1b11393

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

build.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,23 @@ fn main() {
111111
}
112112
}
113113

114+
/// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver`
115+
/// is used instead.
114116
fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
115117
let rustc_wrapper = env::var_os("RUSTC_WRAPPER").filter(|w| !w.is_empty());
116118
let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env");
117119

118-
let mut cmd = if let Some(wrapper) = rustc_wrapper {
119-
let mut cmd = Command::new(wrapper);
120-
cmd.arg(rustc);
121-
if is_clippy_driver {
122-
cmd.arg("--rustc");
123-
}
120+
let mut cmd = match rustc_wrapper {
121+
Some(wrapper) => {
122+
let mut cmd = Command::new(wrapper);
123+
cmd.arg(rustc);
124+
if is_clippy_driver {
125+
cmd.arg("--rustc");
126+
}
124127

125-
cmd
126-
} else {
127-
Command::new(rustc)
128+
cmd
129+
}
130+
None => Command::new(rustc),
128131
};
129132

130133
cmd.arg("--version");
@@ -141,6 +144,8 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {
141144
output
142145
}
143146

147+
/// Return the minor version of `rustc`, as well as a bool indicating whether or not the version
148+
/// is a nightly.
144149
fn rustc_minor_nightly() -> (u32, bool) {
145150
macro_rules! otry {
146151
($e:expr) => {

0 commit comments

Comments
 (0)