Skip to content

Commit bfcf53f

Browse files
committed
Rollup merge of #23210 - richo:rust-o, r=alexcrichton
rustc will ICE if you specify an outfile path that is bare without a directory. As a workaround, before this -o ./foo will work It wasn't clear to me where I could put a test that actually invokes rustc from a shell, although I think I can add doctests to that machinery in librustc_driver that will arrange for this to be called with arguments that would trigger the ICE
2 parents 4398461 + 1036361 commit bfcf53f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/librustc_driver/driver.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ pub fn build_output_filenames(input: &Input,
927927
// We want to toss everything after the final '.'
928928
let dirpath = match *odir {
929929
Some(ref d) => d.clone(),
930-
None => PathBuf::new(".")
930+
None => PathBuf::new("")
931931
};
932932

933933
// If a crate name is present, we use it as the link name
@@ -954,8 +954,11 @@ pub fn build_output_filenames(input: &Input,
954954
if *odir != None {
955955
sess.warn("ignoring --out-dir flag due to -o flag.");
956956
}
957+
958+
let cur_dir = Path::new("");
959+
957960
OutputFilenames {
958-
out_directory: out_file.parent().unwrap().to_path_buf(),
961+
out_directory: out_file.parent().unwrap_or(cur_dir).to_path_buf(),
959962
out_filestem: out_file.file_stem().unwrap()
960963
.to_str().unwrap().to_string(),
961964
single_output_file: ofile,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-include ../tools.mk
2+
3+
all:
4+
rustc -o foo foo.rs

src/test/run-make/bare-outfile/foo.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
}

0 commit comments

Comments
 (0)