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.
This commit is contained in:
Dan Robertson 2019-01-17 13:53:21 +00:00
parent e2f221c759
commit e3ba6ed3f5
No known key found for this signature in database
GPG key ID: 45C4A652C47E42A5
5 changed files with 69 additions and 21 deletions

View file

@ -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');