Skip to content

Commit 187e105

Browse files
committed
small tweaks
1 parent 215de3b commit 187e105

10 files changed

+30
-31
lines changed

src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,22 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
7979
);
8080
} else {
8181
err.span_label(sup_origin.span(), "...is captured here...");
82-
err.span_note(
83-
return_sp,
84-
"...and is required to live as long as `'static` here",
85-
);
82+
if return_sp < sup_origin.span() {
83+
err.span_note(
84+
return_sp,
85+
"...and is required to live as long as `'static` here",
86+
);
87+
} else {
88+
err.span_label(
89+
return_sp,
90+
"...and is required to live as long as `'static` here",
91+
);
92+
}
8693
}
8794
} else {
8895
err.span_label(
8996
return_sp,
90-
"...is captured and required live as long as `'static` here",
97+
"...is captured and required to live as long as `'static` here",
9198
);
9299
}
93100

@@ -104,7 +111,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
104111
};
105112
let explicit =
106113
format!("you can add an explicit `{}` lifetime bound", lifetime_name);
107-
let explicit_static = format!("explicit `'static` bound to {}", arg);
114+
let explicit_static =
115+
format!("explicit `'static` bound to the lifetime of {}", arg);
108116
let captures = format!("captures data from {}", arg);
109117
let add_static_bound =
110118
"alternatively, add an explicit `'static` bound to this reference";

src/test/ui/async-await/issues/issue-62097.stderr

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ LL | pub async fn run_dummy_fn(&self) {
66
| |
77
| this data with an anonymous lifetime `'_`...
88
| ...is captured here...
9-
|
10-
note: ...and is required to live as long as `'static` here
11-
--> $DIR/issue-62097.rs:13:9
12-
|
139
LL | foo(|| self.bar()).await;
14-
| ^^^
10+
| --- ...and is required to live as long as `'static` here
1511

1612
error: aborting due to previous error
1713

src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ note: ...and is required to live as long as `'static` here
4747
|
4848
LL | fn elided2(x: &i32) -> impl Copy + 'static { x }
4949
| ^^^^^^^^^^^^^^^^^^^
50-
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
50+
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
5151
|
5252
LL | fn elided2(x: &i32) -> impl Copy + '_ { x }
5353
| ^^
@@ -69,7 +69,7 @@ note: ...and is required to live as long as `'static` here
6969
|
7070
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x }
7171
| ^^^^^^^^^^^^^^^^^^^
72-
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
72+
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
7373
|
7474
LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x }
7575
| ^^
@@ -97,7 +97,7 @@ note: ...and is required to live as long as `'static` here
9797
|
9898
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
9999
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100-
help: consider changing the `impl Trait`'s explicit `'static` bound to argument `x`
100+
help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x`
101101
|
102102
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x }
103103
| ^^
@@ -157,7 +157,7 @@ LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) }
157157
| |
158158
| this data with an anonymous lifetime `'_`...
159159
|
160-
help: consider changing the trait object's explicit `'static` bound to argument `x`
160+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
161161
|
162162
LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) }
163163
| ^^
@@ -172,7 +172,7 @@ error[E0758]: cannot infer an appropriate lifetime
172172
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) }
173173
| ------- this data with lifetime `'a`... ^ ...is captured here, requiring it to live as long as `'static`
174174
|
175-
help: consider changing the trait object's explicit `'static` bound to argument `x`
175+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
176176
|
177177
LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) }
178178
| ^^

src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> {
55
| --------------- this data with an anonymous lifetime `'_`...
66
...
77
LL | ss.r
8-
| ^^^^ ...is captured and required live as long as `'static` here
8+
| ^^^^ ...is captured and required to live as long as `'static` here
99
|
1010
help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound
1111
|

src/test/ui/regions/region-object-lifetime-in-coercion.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
66
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
77
| ^ ...is captured here, requiring it to live as long as `'static`
88
|
9-
help: consider changing the trait object's explicit `'static` bound to argument `v`
9+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
1010
|
1111
LL | fn a(v: &[u8]) -> Box<dyn Foo + '_> {
1212
| ^^
@@ -23,7 +23,7 @@ LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
2323
LL | Box::new(v)
2424
| ^ ...is captured here, requiring it to live as long as `'static`
2525
|
26-
help: consider changing the trait object's explicit `'static` bound to argument `v`
26+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
2727
|
2828
LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> {
2929
| ^^

src/test/ui/regions/regions-close-object-into-object-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
66
LL | box B(&*v) as Box<dyn X>
77
| ^^^ ...is captured here, requiring it to live as long as `'static`
88
|
9-
help: consider changing the trait object's explicit `'static` bound to argument `v`
9+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
1010
|
1111
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> {
1212
| ^^

src/test/ui/regions/regions-close-object-into-object-4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
66
LL | box B(&*v) as Box<dyn X>
77
| ^^^ ...is captured here, requiring it to live as long as `'static`
88
|
9-
help: consider changing the trait object's explicit `'static` bound to argument `v`
9+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v`
1010
|
1111
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'a> {
1212
| ^^

src/test/ui/regions/regions-proc-bound-capture.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | // This is illegal, because the region bound on `proc` is 'static.
77
LL | Box::new(move || { *x })
88
| ^^^^^^^^^^^^^^ ...is captured here, requiring it to live as long as `'static`
99
|
10-
help: consider changing the trait object's explicit `'static` bound to argument `x`
10+
help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x`
1111
|
1212
LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> {
1313
| ^^

src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@ error[E0758]: cannot infer an appropriate lifetime
22
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:16
33
|
44
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
5-
| ^^^^ ---------- this data with an anonymous lifetime `'_`...
6-
| |
5+
| ^^^^ ---------- ---------- ...and is required to live as long as `'static` here
6+
| | |
7+
| | this data with an anonymous lifetime `'_`...
78
| ...is captured here...
8-
|
9-
note: ...and is required to live as long as `'static` here
10-
--> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:37
11-
|
12-
LL | async fn f(self: Pin<&Self>) -> impl Clone { self }
13-
| ^^^^^^^^^^
149

1510
error: aborting due to previous error
1611

src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr

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

0 commit comments

Comments
 (0)