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/libsyntax | |
| 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/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 823c786bded..5b430d13516 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5234,22 +5234,13 @@ impl<'a> Parser<'a> { kind: ast::GenericParamKind::Lifetime, }); if let Some(sp) = seen_ty_param { - let param_span = self.prev_span; - let ate_comma = self.eat(&token::Comma); - let remove_sp = if ate_comma { - param_span.until(self.span) - } else { - last_comma_span.unwrap_or(param_span).to(param_span) - }; - bad_lifetime_pos.push(param_span); - - if let Ok(snippet) = self.sess.source_map().span_to_snippet(param_span) { + let remove_sp = last_comma_span.unwrap_or(self.prev_span).to(self.prev_span); + bad_lifetime_pos.push(self.prev_span); + if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.prev_span) { suggestions.push((remove_sp, String::new())); - suggestions.push((sp.shrink_to_lo(), format!("{}, ", snippet))); - } - if ate_comma { - last_comma_span = Some(self.prev_span); - continue + suggestions.push(( + sp.shrink_to_lo(), + format!("{}, ", snippet))); } } } else if self.check_ident() { |
