Skip to content

Commit

Permalink
small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jun 9, 2020
1 parent 215de3b commit 187e105
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,22 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
);
} else {
err.span_label(sup_origin.span(), "...is captured here...");
err.span_note(
return_sp,
"...and is required to live as long as `'static` here",
);
if return_sp < sup_origin.span() {
err.span_note(
return_sp,
"...and is required to live as long as `'static` here",
);
} else {
err.span_label(
return_sp,
"...and is required to live as long as `'static` here",
);
}
}
} else {
err.span_label(
return_sp,
"...is captured and required live as long as `'static` here",
"...is captured and required to live as long as `'static` here",
);
}

Expand All @@ -104,7 +111,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
};
let explicit =
format!("you can add an explicit `{}` lifetime bound", lifetime_name);
let explicit_static = format!("explicit `'static` bound to {}", arg);
let explicit_static =
format!("explicit `'static` bound to the lifetime of {}", arg);
let captures = format!("captures data from {}", arg);
let add_static_bound =
"alternatively, add an explicit `'static` bound to this reference";
Expand Down
6 changes: 1 addition & 5 deletions src/test/ui/async-await/issues/issue-62097.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ LL | pub async fn run_dummy_fn(&self) {
| |
| this data with an anonymous lifetime `'_`...
| ...is captured here...
|
note: ...and is required to live as long as `'static` here
--> $DIR/issue-62097.rs:13:9
|
LL | foo(|| self.bar()).await;
| ^^^
| --- ...and is required to live as long as `'static` here

error: aborting due to previous error

Expand Down
10 changes: 5 additions & 5 deletions src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ note: ...and is required to live as long as `'static` here
|
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
| ^^^^^^^^^^^^^^^^^^^
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
|
LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
| ^^
Expand All @@ -69,7 +69,7 @@ note: ...and is required to live as long as `'static` here
|
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
| ^^^^^^^^^^^^^^^^^^^
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
|
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
| ^^
Expand Down Expand Up @@ -97,7 +97,7 @@ note: ...and is required to live as long as `'static` here
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
| ^^
Expand Down Expand Up @@ -157,7 +157,7 @@ LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
| |
| this data with an anonymous lifetime `'_`...
|
help: consider changing the trait object's explicit `'static` bound to argument `x`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
|
LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
| ^^
Expand All @@ -172,7 +172,7 @@ error[E0758]: cannot infer an appropriate lifetime
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
| ------- this data with lifetime `'a`... ^ ...is captured here, requiring it to live as long as `'static`
|
help: consider changing the trait object's explicit `'static` bound to argument `x`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
|
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
| ^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
| --------------- this data with an anonymous lifetime `'_`...
...
LL | ss.r
| ^^^^ ...is captured and required live as long as `'static` here
| ^^^^ ...is captured and required to live as long as `'static` here
|
help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/regions/region-object-lifetime-in-coercion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
| ^ ...is captured here, requiring it to live as long as `'static`
|
help: consider changing the trait object's explicit `'static` bound to argument `v`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
| ^^
Expand All @@ -23,7 +23,7 @@ LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
LL | Box::new(v)
| ^ ...is captured here, requiring it to live as long as `'static`
|
help: consider changing the trait object's explicit `'static` bound to argument `v`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
| ^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
LL | box B(&*v) as Box<dyn X>
| ^^^ ...is captured here, requiring it to live as long as `'static`
|
help: consider changing the trait object's explicit `'static` bound to argument `v`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
| ^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
LL | box B(&*v) as Box<dyn X>
| ^^^ ...is captured here, requiring it to live as long as `'static`
|
help: consider changing the trait object's explicit `'static` bound to argument `v`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
|
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'a> {
| ^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/regions/regions-proc-bound-capture.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | // This is illegal, because the region bound on `proc` is 'static.
LL | Box::new(move || { *x })
| ^^^^^^^^^^^^^^ ...is captured here, requiring it to live as long as `'static`
|
help: consider changing the trait object's explicit `'static` bound to argument `x`
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
|
LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {
| ^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ error[E0758]: cannot infer an appropriate lifetime
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:16
|
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
| ^^^^ ---------- this data with an anonymous lifetime `'_`...
| |
| ^^^^ ---------- ---------- ...and is required to live as long as `'static` here
| | |
| | this data with an anonymous lifetime `'_`...
| ...is captured here...
|
note: ...and is required to live as long as `'static` here
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:37
|
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
| ^^^^^^^^^^

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
| ---- this data with an anonymous lifetime `'_`...
LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
LL | Box::new(items.iter())
| ---------------^^^^--- ...is captured and required live as long as `'static` here
| ---------------^^^^--- ...is captured and required to live as long as `'static` here
|
help: to declare that the trait object captures data from argument `items`, you can add an explicit `'_` lifetime bound
|
Expand Down

0 comments on commit 187e105

Please sign in to comment.