Prevent rustc overwriting input files
If rustc is invoked on a file that would be overwritten by the compilation, the compilation now fails, to avoid accidental loss. This resolves #13019.
This commit is contained in:
parent
53a6d14e5b
commit
c76cdce3d9
5 changed files with 63 additions and 3 deletions
10
src/test/run-make/output-filename-overwrites-input/Makefile
Normal file
10
src/test/run-make/output-filename-overwrites-input/Makefile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-include ../tools.mk
|
||||
|
||||
all:
|
||||
cp foo.rs $(TMPDIR)/foo
|
||||
$(RUSTC) $(TMPDIR)/foo 2>&1 \
|
||||
| $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
|
||||
$(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
|
||||
cp foo.rs $(TMPDIR)/foo.rs
|
||||
$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
|
||||
| $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable"
|
||||
11
src/test/run-make/output-filename-overwrites-input/foo.rs
Normal file
11
src/test/run-make/output-filename-overwrites-input/foo.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -7,8 +7,8 @@ all:
|
|||
cp foo.rs $(TMPDIR)/.foo.bar
|
||||
$(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \
|
||||
| $(CGREP) -e "invalid character.*in crate name:"
|
||||
cp foo.rs $(TMPDIR)/+foo+bar
|
||||
$(RUSTC) $(TMPDIR)/+foo+bar 2>&1 \
|
||||
cp foo.rs $(TMPDIR)/+foo+bar.rs
|
||||
$(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \
|
||||
| $(CGREP) -e "invalid character.*in crate name:"
|
||||
cp foo.rs $(TMPDIR)/-foo.rs
|
||||
$(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue