diff options
| author | Dan Robertson <dan@dlrobertson.com> | 2019-01-17 13:53:21 +0000 |
|---|---|---|
| committer | Dan Robertson <dan@dlrobertson.com> | 2019-01-18 01:10:14 +0000 |
| commit | e3ba6ed3f571119e2f9165805e77c20b5e7a14b4 (patch) | |
| tree | 7f0c9a63f07b514900200bf8b2fe467bfef93bcf /src/librustc_errors | |
| parent | e2f221c75932de7a29845c8d6f1f73536ad00c41 (diff) | |
| download | rust-e3ba6ed3f571119e2f9165805e77c20b5e7a14b4.tar.gz rust-e3ba6ed3f571119e2f9165805e77c20b5e7a14b4.zip | |
Fix suggestions given mulitple bad lifetimes
When given multiple lifetimes prior to type parameters in generic parameters, do not ICE and print the correct suggestion.
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index a074441f8a1..3e25f98ccd2 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -135,10 +135,11 @@ impl CodeSuggestion { if let Some(line) = line_opt { if let Some(lo) = line.char_indices().map(|(i, _)| i).nth(lo) { let hi_opt = hi_opt.and_then(|hi| line.char_indices().map(|(i, _)| i).nth(hi)); - buf.push_str(match hi_opt { - Some(hi) => &line[lo..hi], - None => &line[lo..], - }); + match hi_opt { + Some(hi) if hi > lo => buf.push_str(&line[lo..hi]), + Some(_) => (), + None => buf.push_str(&line[lo..]), + } } if let None = hi_opt { buf.push('\n'); |
