Don't ICE if getting the input's file_stem fails
This commit is contained in:
parent
c8d50ef2ee
commit
c6d94821f0
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user