Fix suggestion to introduce explicit lifetime
This commit is contained in:
parent
07194ffcd2
commit
788e4bb4e5
3 changed files with 53 additions and 1 deletions
|
@ -2248,13 +2248,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
"...",
|
||||
);
|
||||
if let Some(infer::RelateParamBound(_, t)) = origin {
|
||||
let return_impl_trait = self
|
||||
.in_progress_typeck_results
|
||||
.map(|typeck_results| typeck_results.borrow().hir_owner)
|
||||
.and_then(|owner| self.tcx.return_type_impl_trait(owner))
|
||||
.is_some();
|
||||
let t = self.resolve_vars_if_possible(t);
|
||||
match t.kind() {
|
||||
// We've got:
|
||||
// fn get_later<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
|
||||
// suggest:
|
||||
// fn get_later<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
|
||||
ty::Closure(_, _substs) | ty::Opaque(_, _substs) => {
|
||||
ty::Closure(_, _substs) | ty::Opaque(_, _substs) if return_impl_trait => {
|
||||
new_binding_suggestion(&mut err, type_param_span, bound_kind);
|
||||
}
|
||||
_ => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue