Skip to content

Commit e73d974

Browse files
committed
rustc: Fail fast when compiling a source file larger than 4 GiB
1 parent 209799f commit e73d974

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/rustc_span/src/source_map.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ impl FileLoader for RealFileLoader {
115115
}
116116

117117
fn read_file(&self, path: &Path) -> io::Result<String> {
118+
if path.metadata().is_ok_and(|metadata| metadata.len() > u32::MAX.into()) {
119+
eprintln!("fatal error: rustc does not support files larger than 4GB");
120+
crate::fatal_error::FatalError.raise()
121+
}
118122
fs::read_to_string(path)
119123
}
120124

0 commit comments

Comments
 (0)