migrate lifetime too
This commit is contained in:
parent
26cd5486f8
commit
724f3ff50d
@ -102,6 +102,9 @@ hir_analysis_invalid_union_field_sugg =
|
|||||||
hir_analysis_late_bound_const_in_apit = `impl Trait` can only mention const parameters from an fn or impl
|
hir_analysis_late_bound_const_in_apit = `impl Trait` can only mention const parameters from an fn or impl
|
||||||
.label = const parameter declared here
|
.label = const parameter declared here
|
||||||
|
|
||||||
|
hir_analysis_late_bound_lifetime_in_apit = `impl Trait` can only mention lifetimes from an fn or impl
|
||||||
|
.label = lifetime declared here
|
||||||
|
|
||||||
hir_analysis_late_bound_type_in_apit = `impl Trait` can only mention type parameters from an fn or impl
|
hir_analysis_late_bound_type_in_apit = `impl Trait` can only mention type parameters from an fn or impl
|
||||||
.label = type parameter declared here
|
.label = type parameter declared here
|
||||||
|
|
||||||
|
@ -1344,12 +1344,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||||||
Scope::Binder {
|
Scope::Binder {
|
||||||
where_bound_origin: Some(hir::PredicateOrigin::ImplTrait), ..
|
where_bound_origin: Some(hir::PredicateOrigin::ImplTrait), ..
|
||||||
} => {
|
} => {
|
||||||
let mut err = self.tcx.sess.struct_span_err(
|
self.tcx.sess.emit_err(errors::LateBoundInApit::Lifetime {
|
||||||
lifetime_ref.ident.span,
|
span: lifetime_ref.ident.span,
|
||||||
"`impl Trait` can only mention lifetimes bound at the fn or impl level",
|
param_span: self.tcx.def_span(region_def_id),
|
||||||
);
|
});
|
||||||
err.span_note(self.tcx.def_span(region_def_id), "lifetime declared here");
|
|
||||||
err.emit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Scope::Root { .. } => break,
|
Scope::Root { .. } => break,
|
||||||
|
@ -892,4 +892,11 @@ pub(crate) enum LateBoundInApit {
|
|||||||
#[label]
|
#[label]
|
||||||
param_span: Span,
|
param_span: Span,
|
||||||
},
|
},
|
||||||
|
#[diag(hir_analysis_late_bound_lifetime_in_apit)]
|
||||||
|
Lifetime {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
#[label]
|
||||||
|
param_span: Span,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@ trait Trait<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
|
fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
|
||||||
//~^ ERROR `impl Trait` can only mention lifetimes bound at the fn or impl level
|
//~^ ERROR `impl Trait` can only mention lifetimes from an fn or impl
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
error: `impl Trait` can only mention lifetimes bound at the fn or impl level
|
error: `impl Trait` can only mention lifetimes from an fn or impl
|
||||||
--> $DIR/universal_wrong_hrtb.rs:5:73
|
--> $DIR/universal_wrong_hrtb.rs:5:73
|
||||||
|
|
|
|
||||||
LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
|
LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
|
||||||
| ^^
|
| -- lifetime declared here ^^
|
||||||
|
|
|
||||||
note: lifetime declared here
|
|
||||||
--> $DIR/universal_wrong_hrtb.rs:5:39
|
|
||||||
|
|
|
||||||
LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {}
|
|
||||||
| ^^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user