Skip to content

Commit

Permalink
Merge pull request rust-lang#1637 from mo8it/fix-warnings
Browse files Browse the repository at this point in the history
Run clippy --fix
  • Loading branch information
shadows-withal committed Aug 28, 2023
2 parents c2eaa8f + 571bab2 commit d79984d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
18 changes: 9 additions & 9 deletions src/exercise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ impl Exercise {
pub fn compile(&self) -> Result<CompiledExercise, ExerciseOutput> {
let cmd = match self.mode {
Mode::Compile => Command::new("rustc")
.args(&[self.path.to_str().unwrap(), "-o", &temp_file()])
.args([self.path.to_str().unwrap(), "-o", &temp_file()])
.args(RUSTC_COLOR_ARGS)
.args(RUSTC_EDITION_ARGS)
.output(),
Mode::Test => Command::new("rustc")
.args(&["--test", self.path.to_str().unwrap(), "-o", &temp_file()])
.args(["--test", self.path.to_str().unwrap(), "-o", &temp_file()])
.args(RUSTC_COLOR_ARGS)
.args(RUSTC_EDITION_ARGS)
.output(),
Expand All @@ -141,7 +141,7 @@ path = "{}.rs""#,
// compilation failure, this would silently fail. But we expect
// clippy to reflect the same failure while compiling later.
Command::new("rustc")
.args(&[self.path.to_str().unwrap(), "-o", &temp_file()])
.args([self.path.to_str().unwrap(), "-o", &temp_file()])
.args(RUSTC_COLOR_ARGS)
.args(RUSTC_EDITION_ARGS)
.output()
Expand All @@ -151,14 +151,14 @@ path = "{}.rs""#,
// This is already fixed on Clippy's master branch. See this issue to track merging into Cargo:
// https://github.com/rust-lang/rust-clippy/issues/3837
Command::new("cargo")
.args(&["clean", "--manifest-path", CLIPPY_CARGO_TOML_PATH])
.args(["clean", "--manifest-path", CLIPPY_CARGO_TOML_PATH])
.args(RUSTC_COLOR_ARGS)
.output()
.expect("Failed to run 'cargo clean'");
Command::new("cargo")
.args(&["clippy", "--manifest-path", CLIPPY_CARGO_TOML_PATH])
.args(["clippy", "--manifest-path", CLIPPY_CARGO_TOML_PATH])
.args(RUSTC_COLOR_ARGS)
.args(&["--", "-D", "warnings", "-D", "clippy::float_cmp"])
.args(["--", "-D", "warnings", "-D", "clippy::float_cmp"])
.output()
}
}
Expand All @@ -183,7 +183,7 @@ path = "{}.rs""#,
Mode::Test => "--show-output",
_ => "",
};
let cmd = Command::new(&temp_file())
let cmd = Command::new(temp_file())
.arg(arg)
.output()
.expect("Failed to run 'run' command");
Expand Down Expand Up @@ -260,7 +260,7 @@ impl Display for Exercise {

#[inline]
fn clean() {
let _ignored = remove_file(&temp_file());
let _ignored = remove_file(temp_file());
}

#[cfg(test)]
Expand All @@ -270,7 +270,7 @@ mod test {

#[test]
fn test_clean() {
File::create(&temp_file()).unwrap();
File::create(temp_file()).unwrap();
let exercise = Exercise {
name: String::from("example"),
path: PathBuf::from("tests/fixture/state/pending_exercise.rs"),
Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fn main() {
let filter_cond = filters
.split(',')
.filter(|f| !f.trim().is_empty())
.any(|f| e.name.contains(&f) || fname.contains(&f));
.any(|f| e.name.contains(f) || fname.contains(f));
let status = if e.looks_done() {
exercises_done += 1;
"Done"
Expand Down Expand Up @@ -429,7 +429,7 @@ fn watch(

fn rustc_exists() -> bool {
Command::new("rustc")
.args(&["--version"])
.args(["--version"])
.stdout(Stdio::null())
.spawn()
.and_then(|mut child| child.wait())
Expand Down Expand Up @@ -465,7 +465,7 @@ started, here's a couple of notes about how Rustlings operates:
Got all that? Great! To get started, run `rustlings watch` in order to get the first
exercise. Make sure to have your editor open!"#;

const FENISH_LINE: &str = r#"+----------------------------------------------------+
const FENISH_LINE: &str = r"+----------------------------------------------------+
| You made it to the Fe-nish line! |
+-------------------------- ------------------------+
\\/
Expand All @@ -490,12 +490,12 @@ If you noticed any issues, please don't hesitate to report them to our repo.
You can also contribute your own exercises to help the greater community!
Before reporting an issue or contributing, please read our guidelines:
https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"#;
https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md";

const WELCOME: &str = r#" welcome to...
const WELCOME: &str = r" welcome to...
_ _ _
_ __ _ _ ___| |_| (_)_ __ __ _ ___
| '__| | | / __| __| | | '_ \ / _` / __|
| | | |_| \__ \ |_| | | | | | (_| \__ \
|_| \__,_|___/\__|_|_|_| |_|\__, |___/
|___/"#;
|___/";
2 changes: 1 addition & 1 deletion src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl RustAnalyzerProject {

println!("Determined toolchain: {}\n", &toolchain);

self.sysroot_src = (std::path::Path::new(&*toolchain)
self.sysroot_src = (std::path::Path::new(toolchain)
.join("lib")
.join("rustlib")
.join("src")
Expand Down
4 changes: 2 additions & 2 deletions src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ fn compile_and_test(

// Compile the given Exercise and return an object with information
// about the state of the compilation
fn compile<'a, 'b>(
fn compile<'a>(
exercise: &'a Exercise,
progress_bar: &'b ProgressBar,
progress_bar: &ProgressBar,
) -> Result<CompiledExercise<'a>, ()> {
let compilation_result = exercise.compile();

Expand Down
34 changes: 17 additions & 17 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn verify_fails_if_some_fails() {
fn run_single_compile_success() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "compSuccess"])
.args(["run", "compSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.success();
Expand All @@ -54,7 +54,7 @@ fn run_single_compile_success() {
fn run_single_compile_failure() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "compFailure"])
.args(["run", "compFailure"])
.current_dir("tests/fixture/failure/")
.assert()
.code(1);
Expand All @@ -64,7 +64,7 @@ fn run_single_compile_failure() {
fn run_single_test_success() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "testSuccess"])
.args(["run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.success();
Expand All @@ -74,7 +74,7 @@ fn run_single_test_success() {
fn run_single_test_failure() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "testFailure"])
.args(["run", "testFailure"])
.current_dir("tests/fixture/failure/")
.assert()
.code(1);
Expand All @@ -84,7 +84,7 @@ fn run_single_test_failure() {
fn run_single_test_not_passed() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "testNotPassed.rs"])
.args(["run", "testNotPassed.rs"])
.current_dir("tests/fixture/failure/")
.assert()
.code(1);
Expand All @@ -104,7 +104,7 @@ fn run_single_test_no_filename() {
fn run_single_test_no_exercise() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "compNoExercise.rs"])
.args(["run", "compNoExercise.rs"])
.current_dir("tests/fixture/failure")
.assert()
.code(1);
Expand All @@ -114,7 +114,7 @@ fn run_single_test_no_exercise() {
fn reset_single_exercise() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["reset", "intro1"])
.args(["reset", "intro1"])
.assert()
.code(0);
}
Expand All @@ -135,7 +135,7 @@ fn reset_no_exercise() {
fn get_hint_for_single_test() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["hint", "testFailure"])
.args(["hint", "testFailure"])
.current_dir("tests/fixture/failure")
.assert()
.code(0)
Expand Down Expand Up @@ -171,7 +171,7 @@ fn all_exercises_require_confirmation() {
fn run_compile_exercise_does_not_prompt() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "pending_exercise"])
.args(["run", "pending_exercise"])
.current_dir("tests/fixture/state")
.assert()
.code(0)
Expand All @@ -182,7 +182,7 @@ fn run_compile_exercise_does_not_prompt() {
fn run_test_exercise_does_not_prompt() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "pending_test_exercise"])
.args(["run", "pending_test_exercise"])
.current_dir("tests/fixture/state")
.assert()
.code(0)
Expand All @@ -193,7 +193,7 @@ fn run_test_exercise_does_not_prompt() {
fn run_single_test_success_with_output() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["--nocapture", "run", "testSuccess"])
.args(["--nocapture", "run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.code(0)
Expand All @@ -204,7 +204,7 @@ fn run_single_test_success_with_output() {
fn run_single_test_success_without_output() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["run", "testSuccess"])
.args(["run", "testSuccess"])
.current_dir("tests/fixture/success/")
.assert()
.code(0)
Expand All @@ -215,7 +215,7 @@ fn run_single_test_success_without_output() {
fn run_rustlings_list() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list"])
.args(["list"])
.current_dir("tests/fixture/success")
.assert()
.success();
Expand All @@ -225,7 +225,7 @@ fn run_rustlings_list() {
fn run_rustlings_list_no_pending() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list"])
.args(["list"])
.current_dir("tests/fixture/success")
.assert()
.success()
Expand All @@ -236,7 +236,7 @@ fn run_rustlings_list_no_pending() {
fn run_rustlings_list_both_done_and_pending() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list"])
.args(["list"])
.current_dir("tests/fixture/state")
.assert()
.success()
Expand All @@ -247,7 +247,7 @@ fn run_rustlings_list_both_done_and_pending() {
fn run_rustlings_list_without_pending() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list", "--solved"])
.args(["list", "--solved"])
.current_dir("tests/fixture/state")
.assert()
.success()
Expand All @@ -258,7 +258,7 @@ fn run_rustlings_list_without_pending() {
fn run_rustlings_list_without_done() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["list", "--unsolved"])
.args(["list", "--unsolved"])
.current_dir("tests/fixture/state")
.assert()
.success()
Expand Down

0 comments on commit d79984d

Please sign in to comment.