Skip to content

Commit

Permalink
Fix suggestion to use lifetime in type
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 11, 2020
1 parent 4b9ac51 commit 0f7205f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/librustc_resolve/late/diagnostics.rs
Expand Up @@ -1349,7 +1349,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
suggest_new(err, "'a");
}
(0, _, Some(snippet)) if !snippet.ends_with('>') && count == 1 => {
suggest_new(err, &format!("{}<'a>", snippet));
if snippet == "" {
// This happens when we have `type Bar<'a> = Foo<T>` where we point at the space
// before `T`. We will suggest `type Bar<'a> = Foo<'a, T>`.
suggest_new(err, "'a, ");
} else {
suggest_new(err, &format!("{}<'a>", snippet));
}
}
(n, ..) if n > 1 => {
let spans: Vec<Span> = lifetime_names.iter().map(|lt| lt.span).collect();
Expand Down
Expand Up @@ -6,8 +6,8 @@ LL | type Item = IteratorChunk<T, S>;
|
help: consider introducing a named lifetime parameter
|
LL | type Item<'a> = IteratorChunk<<'a>T, S>;
| ^^^^ ^^^^
LL | type Item<'a> = IteratorChunk<'a, T, S>;
| ^^^^ ^^^

error: `impl` item signature doesn't match `trait` item signature
--> $DIR/issue-74918-missing-lifetime.rs:11:5
Expand Down

0 comments on commit 0f7205f

Please sign in to comment.