Fix suggestion to use lifetime in type
This commit is contained in:
parent
4b9ac51617
commit
0f7205f202
2 changed files with 9 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue