mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-11 22:43:42 +00:00
Rollup merge of #128710 - ChrisDenton:null, r=jieyouxu
Don't ICE when getting an input file name's stem fails Fixes #128681 The file stem is only used as a user-friendly prefix on intermediary files. While nice to have, it's not the end of the world if it fails so there's no real reason to emit an error here. We can continue with a fixed name as we do when an anonymous string is used.
This commit is contained in:
commit
f9325b72d9
@ -838,10 +838,14 @@ pub enum Input {
|
||||
|
||||
impl Input {
|
||||
pub fn filestem(&self) -> &str {
|
||||
match *self {
|
||||
Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap(),
|
||||
Input::Str { .. } => "rust_out",
|
||||
if let Input::File(ifile) = self {
|
||||
// If for some reason getting the file stem as a UTF-8 string fails,
|
||||
// then fallback to a fixed name.
|
||||
if let Some(name) = ifile.file_stem().and_then(OsStr::to_str) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
"rust_out"
|
||||
}
|
||||
|
||||
pub fn source_name(&self) -> FileName {
|
||||
|
13
tests/run-make/dos-device-input/rmake.rs
Normal file
13
tests/run-make/dos-device-input/rmake.rs
Normal file
@ -0,0 +1,13 @@
|
||||
//@ only-windows
|
||||
// Reason: dos devices are a Windows thing
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use run_make_support::{rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
rustc().input(r"\\.\NUL").crate_type("staticlib").run();
|
||||
rustc().input(r"\\?\NUL").crate_type("staticlib").run();
|
||||
|
||||
assert!(Path::new(&static_lib_name("rust_out")).exists());
|
||||
}
|
Loading…
Reference in New Issue
Block a user