Skip to content

Commit 23c3620

Browse files
authored
Merge pull request #1355 from wjwrh/main
Fix the problem of different edition between rustc and rust-analyzer
2 parents ce7ffcd + 1721ddc commit 23c3620

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/exercise.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::path::PathBuf;
88
use std::process::{self, Command};
99

1010
const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
11+
const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"];
1112
const I_AM_DONE_REGEX: &str = r"(?m)^\s*///?\s*I\s+AM\s+NOT\s+DONE";
1213
const CONTEXT: usize = 2;
1314
const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/clippy/Cargo.toml";
@@ -111,10 +112,12 @@ impl Exercise {
111112
Mode::Compile => Command::new("rustc")
112113
.args(&[self.path.to_str().unwrap(), "-o", &temp_file()])
113114
.args(RUSTC_COLOR_ARGS)
115+
.args(RUSTC_EDITION_ARGS)
114116
.output(),
115117
Mode::Test => Command::new("rustc")
116118
.args(&["--test", self.path.to_str().unwrap(), "-o", &temp_file()])
117119
.args(RUSTC_COLOR_ARGS)
120+
.args(RUSTC_EDITION_ARGS)
118121
.output(),
119122
Mode::Clippy => {
120123
let cargo_toml = format!(
@@ -140,6 +143,7 @@ path = "{}.rs""#,
140143
Command::new("rustc")
141144
.args(&[self.path.to_str().unwrap(), "-o", &temp_file()])
142145
.args(RUSTC_COLOR_ARGS)
146+
.args(RUSTC_EDITION_ARGS)
143147
.output()
144148
.expect("Failed to compile!");
145149
// Due to an issue with Clippy, a cargo clean is required to catch all lints.
@@ -154,7 +158,7 @@ path = "{}.rs""#,
154158
Command::new("cargo")
155159
.args(&["clippy", "--manifest-path", CLIPPY_CARGO_TOML_PATH])
156160
.args(RUSTC_COLOR_ARGS)
157-
.args(&["--", "-D", "warnings","-D","clippy::float_cmp"])
161+
.args(&["--", "-D", "warnings", "-D", "clippy::float_cmp"])
158162
.output()
159163
}
160164
}

0 commit comments

Comments
 (0)