File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1875,17 +1875,24 @@ impl SourceMap {
18751875 let end = end. map ( |end| src. to_relative_offset ( end) ) ;
18761876 let ( line, col) = src. linecol ( start) ;
18771877 let snippet = src. contents . lines ( ) . nth ( line) . unwrap_or ( "" ) ;
1878+ let line = line + 1 ;
1879+ let col = col + 1 ;
1880+
1881+ // If the snippet is too large then don't overload output on a terminal
1882+ // for example and instead just print the error. This also sidesteps
1883+ // Rust's restriction that `>0$` below has to be less than `u16::MAX`.
1884+ if snippet. len ( ) > 500 {
1885+ return format ! ( "{}:{line}:{col}: {err}" , src. path) ;
1886+ }
18781887 let mut msg = format ! (
18791888 "\
18801889 {err}
18811890 --> {file}:{line}:{col}
18821891 |
18831892 {line:4} | {snippet}
18841893 | {marker:>0$}" ,
1885- col + 1 ,
1894+ col,
18861895 file = src. path,
1887- line = line + 1 ,
1888- col = col + 1 ,
18891896 marker = "^" ,
18901897 ) ;
18911898 if let Some ( end) = end {
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ tests/ui/parse-fail/very-large-column.wit:1:65543: expected '{', found an identifier
You can’t perform that action at this time.
0 commit comments