Skip to content

Commit 3ab084a

Browse files
crodjerjrvidal
authored andcommitted
fix(run): compile clippy exercise files
Additionally to running clippy, also compile the exercise file so that `rustling run clippy1` works after a successful completion of the exercise. closes #291 Signed-off-by: Rohan Jain <crodjer@gmail.com>
1 parent 495174f commit 3ab084a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/exercise.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ path = "{}.rs""#,
9898
);
9999
fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml)
100100
.expect("Failed to write 📎 Clippy 📎 Cargo.toml file.");
101+
// To support the ability to run the clipy exercises, build
102+
// an executable, in addition to running clippy. With a
103+
// compilation failure, this would silently fail. But we expect
104+
// clippy to reflect the same failure while compiling later.
105+
Command::new("rustc")
106+
.args(&[self.path.to_str().unwrap(), "-o", &temp_file()])
107+
.args(RUSTC_COLOR_ARGS)
108+
.output()
109+
.expect("Failed to compile!");
101110
// Due to an issue with Clippy, a cargo clean is required to catch all lints.
102111
// See https://github.com/rust-lang/rust-clippy/issues/2604
103112
// This is already fixed on master branch. See this issue to track merging into Cargo:

0 commit comments

Comments
 (0)