2024-06-14 15:21:55 -05:00
|
|
|
// If rustc is invoked on a file that would be overwritten by the
|
|
|
|
// compilation, the compilation should fail, to avoid accidental loss.
|
|
|
|
// See https://github.com/rust-lang/rust/pull/46814
|
|
|
|
|
|
|
|
//@ ignore-cross-compile
|
|
|
|
|
2024-07-17 08:31:38 -05:00
|
|
|
use run_make_support::{rfs, rustc};
|
2024-06-14 15:21:55 -05:00
|
|
|
|
|
|
|
fn main() {
|
2024-07-17 07:42:06 -05:00
|
|
|
rfs::copy("foo.rs", "foo");
|
2024-06-14 15:21:55 -05:00
|
|
|
rustc().input("foo").output("foo").run_fail().assert_stderr_contains(
|
|
|
|
r#"the input file "foo" would be overwritten by the generated executable"#,
|
|
|
|
);
|
2024-07-17 07:42:06 -05:00
|
|
|
rfs::copy("bar.rs", "bar.rlib");
|
2024-06-14 15:21:55 -05:00
|
|
|
rustc().input("bar.rlib").output("bar.rlib").run_fail().assert_stderr_contains(
|
|
|
|
r#"the input file "bar.rlib" would be overwritten by the generated executable"#,
|
|
|
|
);
|
|
|
|
rustc().input("foo.rs").output("foo.rs").run_fail().assert_stderr_contains(
|
|
|
|
r#"the input file "foo.rs" would be overwritten by the generated executable"#,
|
|
|
|
);
|
|
|
|
}
|