diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index c57c0e519418..c9e83864a938 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -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` 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 = lifetime_names.iter().map(|lt| lt.span).collect(); diff --git a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr index da3056eac900..d260addef481 100644 --- a/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr +++ b/src/test/ui/mismatched_types/issue-74918-missing-lifetime.stderr @@ -6,8 +6,8 @@ LL | type Item = IteratorChunk; | 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