diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-28 21:19:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-28 21:19:58 +0200 |
| commit | a3cae5740cca893204c4d6d9fe43506f0eec8441 (patch) | |
| tree | b0103b2066011b4eb1c38cbce85291b9190f0f0b /src/librustc_errors | |
| parent | 2ac9b89d7b18ba68ec9d362bcae010045572988b (diff) | |
| parent | 6263eb438def79c393e372eac1237b4d4f97772f (diff) | |
| download | rust-a3cae5740cca893204c4d6d9fe43506f0eec8441.tar.gz rust-a3cae5740cca893204c4d6d9fe43506f0eec8441.zip | |
Rollup merge of #62995 - estebank:issue-62973, r=varkor
Avoid ICE when suggestion span is at Eof Fix #62973.
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/lib.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 0a6c02c0ca6..15c4dfb67d0 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -226,7 +226,8 @@ impl CodeSuggestion { } } if let Some(cur_line) = fm.get_line(cur_lo.line - 1) { - buf.push_str(&cur_line[..cur_lo.col.to_usize()]); + let end = std::cmp::min(cur_line.len(), cur_lo.col.to_usize()); + buf.push_str(&cur_line[..end]); } } buf.push_str(&part.snippet); |
