Don't ICE if getting the input's file_stem fails
This commit is contained in:
parent
c8d50ef2ee
commit
c6d94821f0
1 changed files with 7 additions and 3 deletions
|
@ -838,11 +838,15 @@ pub enum Input {
|
||||||
|
|
||||||
impl Input {
|
impl Input {
|
||||||
pub fn filestem(&self) -> &str {
|
pub fn filestem(&self) -> &str {
|
||||||
match *self {
|
if let Input::File(ifile) = self {
|
||||||
Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap(),
|
// If for some reason getting the file stem as a UTF-8 string fails,
|
||||||
Input::Str { .. } => "rust_out",
|
// 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 {
|
pub fn source_name(&self) -> FileName {
|
||||||
match *self {
|
match *self {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue