diff options
| author | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-28 20:22:42 +0000 |
| commit | c7312fe4ff85ada30103cea58db25d83e0bec4b0 (patch) | |
| tree | c45aed285c4e04591ea7d6e8bc6c90b3461671a6 /src/librustc_errors | |
| parent | 4560cb830fce63fcffdc4558f4281aaac6a3a1ba (diff) | |
| parent | 29c377882f545e24b9cc6e1198ee4f72c20d5449 (diff) | |
| download | rust-c7312fe4ff85ada30103cea58db25d83e0bec4b0.tar.gz rust-c7312fe4ff85ada30103cea58db25d83e0bec4b0.zip | |
Auto merge of #63090 - Centril:rollup-xnjwm2h, r=Centril
Rollup of 8 pull requests Successful merges: - #61856 (Lint attributes on function arguments) - #62360 (Document that ManuallyDrop::drop should not called more than once) - #62392 (Update minifier-rs version) - #62871 (Explicit error message for async recursion.) - #62995 (Avoid ICE when suggestion span is at Eof) - #63053 (SystemTime docs: recommend Instant for elapsed time) - #63081 (tidy: Cleanup the directory whitelist) - #63088 (Remove anonymous_parameters from unrelated test) Failed merges: r? @ghost
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 3f758c2521b..3b6a6a824c8 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -223,7 +223,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); |
