Skip to content

Commit 9e71c7b

Browse files
Small run-make-support API improvements
1 parent d68fe4e commit 9e71c7b

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/tools/run-make-support/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ pub fn set_host_rpath(cmd: &mut Command) {
321321
/// Read the contents of a file that cannot simply be read by
322322
/// read_to_string, due to invalid utf8 data, then assert that it contains `expected`.
323323
#[track_caller]
324-
pub fn invalid_utf8_contains<P: AsRef<Path>>(path: P, expected: &str) {
324+
pub fn invalid_utf8_contains<P: AsRef<Path>, S: AsRef<str>>(path: P, expected: S) {
325325
let buffer = fs_wrapper::read(path.as_ref());
326+
let expected = expected.as_ref();
326327
if !String::from_utf8_lossy(&buffer).contains(expected) {
327328
eprintln!("=== FILE CONTENTS (LOSSY) ===");
328329
eprintln!("{}", String::from_utf8_lossy(&buffer));
@@ -335,8 +336,9 @@ pub fn invalid_utf8_contains<P: AsRef<Path>>(path: P, expected: &str) {
335336
/// Read the contents of a file that cannot simply be read by
336337
/// read_to_string, due to invalid utf8 data, then assert that it does not contain `expected`.
337338
#[track_caller]
338-
pub fn invalid_utf8_not_contains<P: AsRef<Path>>(path: P, expected: &str) {
339+
pub fn invalid_utf8_not_contains<P: AsRef<Path>, S: AsRef<str>>(path: P, expected: S) {
339340
let buffer = fs_wrapper::read(path.as_ref());
341+
let expected = expected.as_ref();
340342
if String::from_utf8_lossy(&buffer).contains(expected) {
341343
eprintln!("=== FILE CONTENTS (LOSSY) ===");
342344
eprintln!("{}", String::from_utf8_lossy(&buffer));

src/tools/run-make-support/src/rustc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ impl Rustc {
8686
}
8787

8888
/// Specify type(s) of output files to generate.
89-
pub fn emit(&mut self, kinds: &str) -> &mut Self {
89+
pub fn emit<S: AsRef<str>>(&mut self, kinds: S) -> &mut Self {
90+
let kinds = kinds.as_ref();
9091
self.cmd.arg(format!("--emit={kinds}"));
9192
self
9293
}

tests/run-make/emit-named-files/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use run_make_support::{fs_wrapper, rustc};
44

55
fn emit_and_check(out_dir: &Path, out_file: &str, format: &str) {
66
let out_file = out_dir.join(out_file);
7-
rustc().input("foo.rs").emit(&format!("{format}={}", out_file.display())).run();
7+
rustc().input("foo.rs").emit(format!("{format}={}", out_file.display())).run();
88
assert!(out_file.is_file());
99
}
1010

0 commit comments

Comments
 (0)