-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #124112 - beetrees:incremental-os-str, r=Nadrieril
Fix ICE when there is a non-Unicode entry in the incremental crate directory Fix the ICE that occurs when there is a non-Unicode entry in the incremental crate directory by replacing uses of `to_string_lossy` + `assert_no_characters_lost` with `to_str`. The added test would cause the compiler to ICE before this PR.
- Loading branch information
Showing
3 changed files
with
46 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extern crate run_make_support; | ||
|
||
use run_make_support::{rustc, tmp_dir}; | ||
|
||
fn main() { | ||
#[cfg(unix)] | ||
let non_unicode: &std::ffi::OsStr = std::os::unix::ffi::OsStrExt::from_bytes(&[0xFF]); | ||
#[cfg(windows)] | ||
let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]); | ||
match std::fs::create_dir(tmp_dir().join(&non_unicode)) { | ||
// If an error occurs, check if creating a directory with a valid Unicode name would | ||
// succeed. | ||
Err(e) if std::fs::create_dir(tmp_dir().join("valid_unicode")).is_ok() => { | ||
// Filesystem doesn't appear support non-Unicode paths. | ||
return; | ||
} | ||
Err(e) => panic!("error creating non-Unicode directory: {e}"), | ||
_ => {} | ||
} | ||
let incr_dir = tmp_dir().join("incr-dir"); | ||
rustc().input("foo.rs").incremental(&incr_dir).run(); | ||
for crate_dir in std::fs::read_dir(&incr_dir).unwrap() { | ||
std::fs::create_dir(crate_dir.unwrap().path().join(&non_unicode)).unwrap(); | ||
} | ||
rustc().input("foo.rs").incremental(&incr_dir).run(); | ||
} |