rustc: Fail fast when compiling a source file larger than 4 GiB - 1 B
Fixes #132862
This commit is contained in:
parent
209799f3b9
commit
5caf516cd0
2 changed files with 15 additions and 1 deletions
|
@ -115,6 +115,12 @@ impl FileLoader for RealFileLoader {
|
|||
}
|
||||
|
||||
fn read_file(&self, path: &Path) -> io::Result<String> {
|
||||
if path.metadata().is_ok_and(|metadata| metadata.len() > SourceFile::MAX_FILE_SIZE.into()) {
|
||||
return Err(io::Error::other(format!(
|
||||
"text files larger than {} bytes are unsupported",
|
||||
SourceFile::MAX_FILE_SIZE
|
||||
)));
|
||||
}
|
||||
fs::read_to_string(path)
|
||||
}
|
||||
|
||||
|
@ -297,7 +303,10 @@ impl SourceMap {
|
|||
/// unmodified.
|
||||
pub fn new_source_file(&self, filename: FileName, src: String) -> Lrc<SourceFile> {
|
||||
self.try_new_source_file(filename, src).unwrap_or_else(|OffsetOverflowError| {
|
||||
eprintln!("fatal error: rustc does not support files larger than 4GB");
|
||||
eprintln!(
|
||||
"fatal error: rustc does not support text files larger than {} bytes",
|
||||
SourceFile::MAX_FILE_SIZE
|
||||
);
|
||||
crate::fatal_error::FatalError.raise()
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue