From 91effb374c98927823b3032f7433e7b73a229f95 Mon Sep 17 00:00:00 2001 From: swgillespie Date: Wed, 10 Jun 2015 18:18:04 -0700 Subject: [PATCH] fix #26092 by returning an empty OS string when the output file path has no file_stem --- src/librustc_driver/driver.rs | 4 ++-- src/test/run-make/issue-26092/Makefile | 5 +++++ src/test/run-make/issue-26092/blank.rs | 11 +++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/test/run-make/issue-26092/Makefile create mode 100644 src/test/run-make/issue-26092/blank.rs diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index aa57a280157f7..bcb1c6d08d76d 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -33,7 +33,7 @@ use super::Compilation; use serialize::json; use std::env; -use std::ffi::OsString; +use std::ffi::{OsString, OsStr}; use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; @@ -966,7 +966,7 @@ pub fn build_output_filenames(input: &Input, OutputFilenames { out_directory: out_file.parent().unwrap_or(cur_dir).to_path_buf(), - out_filestem: out_file.file_stem().unwrap() + out_filestem: out_file.file_stem().unwrap_or(OsStr::new("")) .to_str().unwrap().to_string(), single_output_file: ofile, extra: sess.opts.cg.extra_filename.clone(), diff --git a/src/test/run-make/issue-26092/Makefile b/src/test/run-make/issue-26092/Makefile new file mode 100644 index 0000000000000..1e66e3a53804f --- /dev/null +++ b/src/test/run-make/issue-26092/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -o "" blank.rs 2>&1 | \ + grep 'No such file or directory' diff --git a/src/test/run-make/issue-26092/blank.rs b/src/test/run-make/issue-26092/blank.rs new file mode 100644 index 0000000000000..8ae3d072362ed --- /dev/null +++ b/src/test/run-make/issue-26092/blank.rs @@ -0,0 +1,11 @@ +// Copyright 2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {}