Skip to content

Commit

Permalink
more has_main cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Dec 25, 2023
1 parent c36977c commit b8af820
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/run_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(crate) fn run_rustc(
}
// if the file contains no "main", run with "--crate-type lib"
let file_as_text = std::fs::read_to_string(file).unwrap_or_default();
let has_main = file_as_text.contains("fn main(");
let has_main = file_has_main(&file);

let tempdir = TempDir::new_in(global_tempdir_path, "rustc_testrunner_tmpdir").unwrap();
let tempdir_path = tempdir.path().display();
Expand Down Expand Up @@ -189,9 +189,7 @@ pub(crate) fn run_rustc_incremental(

let dump_mir_dir = String::from("-Zdump-mir-dir=/dev/null");

let has_main = std::fs::read_to_string(file)
.unwrap_or_default()
.contains("fn main(");
let has_main = file_has_main(&file);

let mut cmd = Command::new("DUMMY");
let mut output = None;
Expand Down Expand Up @@ -468,7 +466,7 @@ pub(crate) fn run_clippy_fix(
// https://github.com/matthiaskrgr/icemaker/issues/26
let file = std::fs::canonicalize(file).unwrap();

let has_main = file_string.contains("pub(crate) fn main(");
let has_main = file_has_main(&file);

let tempdir = TempDir::new_in(global_tempdir_path, "icemaker_clippyfix_tempdir").unwrap();
let tempdir_path = tempdir.path();
Expand Down

0 comments on commit b8af820

Please sign in to comment.