Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #26199 - swgillespie:issue-26092, r=alexcrichton
`driver::build_output_filenames` calls `file_stem` on a PathBuf obtained from the output file compiler flag. It's possible to pass the empty string to this compiler flag. When file_stem is called on an empty Path, it returns None, which is unwrapped and the compiler panics. This change modifies the `unwrap` to an `unwrap_or` so that the empty string is passed through the compilation pipeline until it reaches `trans::back::write_output_file`, which will emit an appropriate error. Instead of panicking, the error that is emitted now is: ``` $ rustc -o "" thing.rs error: could not write output to : No such file or directory ``` The `:` is a little strange, but it /is/ reporting the filename (the empty string) correctly, I suppose. Both gcc and clang hand the output file to ld, which emits a similar error message when faced with the empty string as an output file: ``` $ clang -o "" thing.c ld: can't open output file for writing: , errno=2 for architecture x86_64 ``` This PR also adds a test for this, in `run-make`. This fixes issue #26092.
- Loading branch information