From a15bc5502cd1a4862abf190bc6c3644c6fa2ba1e Mon Sep 17 00:00:00 2001 From: Oneirical Date: Thu, 28 Mar 2024 22:49:43 -0400 Subject: [PATCH] Rewrite core-no-fp-fmt-parse in Rust Rewrite core-no-fp-fmt-parse in Rust fix: missing import fix: tidiness check more tidy checks remove tidy line length ignore new helper functions + arg_path generic fix: remove unused import --- src/tools/run-make-support/src/rustc.rs | 23 +++++++++++++++++++ .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/core-no-fp-fmt-parse/Makefile | 4 ---- tests/run-make/core-no-fp-fmt-parse/rmake.rs | 17 ++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) delete mode 100644 tests/run-make/core-no-fp-fmt-parse/Makefile create mode 100644 tests/run-make/core-no-fp-fmt-parse/rmake.rs diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index d0ab8df42d282..dbcfca6feedb0 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -104,6 +104,29 @@ impl Rustc { self } + /// Generic file path provider. + pub fn arg_path

(&mut self, path: P) -> &mut Self + where + P: AsRef, + { + self.cmd.arg(path.as_ref()); + self + } + + /// Specify the crate type. + pub fn crate_type(&mut self, crate_type: &str) -> &mut Self { + self.cmd.arg("--crate-type"); + self.cmd.arg(crate_type); + self + } + + /// Specify the edition year. + pub fn edition(&mut self, edition: &str) -> &mut Self { + self.cmd.arg("--edition"); + self.cmd.arg(edition); + self + } + /// Generic command arguments provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`. /// This method will panic if a plain `-Z` or `-C` is passed, or if `-Z ` or `-C ` /// is passed (note the space). diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index bdee3afa6b71d..40950e6ba4432 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -31,7 +31,6 @@ run-make/compiler-rt-works-on-mingw/Makefile run-make/compressed-debuginfo/Makefile run-make/const-prop-lint/Makefile run-make/const_fn_mir/Makefile -run-make/core-no-fp-fmt-parse/Makefile run-make/core-no-oom-handling/Makefile run-make/crate-data-smoke/Makefile run-make/crate-hash-rustc-version/Makefile diff --git a/tests/run-make/core-no-fp-fmt-parse/Makefile b/tests/run-make/core-no-fp-fmt-parse/Makefile deleted file mode 100644 index 837664d92b938..0000000000000 --- a/tests/run-make/core-no-fp-fmt-parse/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --cfg no_fp_fmt_parse diff --git a/tests/run-make/core-no-fp-fmt-parse/rmake.rs b/tests/run-make/core-no-fp-fmt-parse/rmake.rs new file mode 100644 index 0000000000000..36948f0564397 --- /dev/null +++ b/tests/run-make/core-no-fp-fmt-parse/rmake.rs @@ -0,0 +1,17 @@ +// This test checks that the core library of Rust can be compiled without enabling +// support for formatting and parsing floating-point numbers. + +extern crate run_make_support; + +use run_make_support::rustc; +use std::path::PathBuf; + +fn main() { + rustc() + .edition("2021") + .arg("-Dwarnings") + .crate_type("rlib") + .arg_path("../../../library/core/src/lib.rs") + .cfg("no_fp_fmt_parse") + .run(); +}