&self,
generic_param_scope: LocalDefId,
span: Span,
- origin: Option<SubregionOrigin<'tcx>>,
+ mut origin: Option<SubregionOrigin<'tcx>>,
bound_kind: GenericKind<'tcx>,
sub: Region<'tcx>,
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
None
}
}
+ GenericKind::Opaque(def_id, _substs) => {
+ // Avoid emitting a `... so that the type` message at the error site.
+ // It would be out of order for return position impl trait
+ origin = None;
+ // Make sure the lifetime suggestion is on the RPIT instead of proposing
+ // to add a bound for opaque types (which isn't possible)
+ Some((self.tcx.def_span(def_id).shrink_to_hi(), true))
+ }
_ => None,
};
post: P,
x: &'t Foo,
) -> &'t impl Trait {
+ //~^ HELP: consider adding an explicit lifetime bound...
x
}
) -> &'t impl Trait {
foo(post, x)
//~^ ERROR: the opaque type `foo<T>::{opaque#0}` may not live long enough
- //~| HELP: consider adding an explicit lifetime bound `foo<T>::{opaque#0}: 't`
}
fn main() {}
error[E0309]: the opaque type `foo<T>::{opaque#0}` may not live long enough
- --> $DIR/unactionable_diagnostic.rs:18:5
+ --> $DIR/unactionable_diagnostic.rs:19:5
|
LL | foo(post, x)
| ^^^^^^^^^^^^
|
- = help: consider adding an explicit lifetime bound `foo<T>::{opaque#0}: 't`...
- = note: ...so that the type `impl Trait` will meet its required lifetime bounds
+help: consider adding an explicit lifetime bound...
+ |
+LL | ) -> &'t impl Trait + 't {
+ | ++++
error: aborting due to previous error