Skip to content

Commit 3e9d1cc

Browse files
committed
Change wording for lifetime suggestion for opaque types from constraint to bound
1 parent 94089ad commit 3e9d1cc

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5454
err.span_suggestion(
5555
fn_return_span,
5656
&format!(
57-
"you can add a constraint to the return type to make it last \
57+
"you can add a bound to the return type to make it last \
5858
less than `'static` and match {}",
5959
lifetime,
6060
),

src/librustc_mir/borrow_check/diagnostics/explain_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl BorrowExplanation {
238238
err.span_suggestion(
239239
span,
240240
&format!(
241-
"you can add a constraint to the {}to make it last less than \
241+
"you can add a bound to the {}to make it last less than \
242242
`'static` and match `{}`",
243243
category.description(),
244244
region_name,

src/librustc_mir/borrow_check/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
778778
span,
779779
&format!(
780780
"to allow this `impl Trait` to capture borrowed data with lifetime \
781-
`{}`, add `{}` as a constraint",
781+
`{}`, add `{}` as a bound",
782782
fr_name, suggestable_fr_name,
783783
),
784784
format!("{} + {}", snippet, suggestable_fr_name),

src/test/ui/impl-trait/does-not-live-long-enough.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL |
1111
LL | }
1212
| - `prefix` dropped here while still borrowed
1313
|
14-
help: you can add a constraint to the opaque type to make it last less than `'static` and match `'a`
14+
help: you can add a bound to the opaque type to make it last less than `'static` and match `'a`
1515
|
1616
LL | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> + 'a {
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/impl-trait/multiple-lifetimes/error-handling.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
55
| -- lifetime `'a` defined here ^^^^^^^^^ opaque type requires that `'a` must outlive `'static`
66
|
77
= help: consider replacing `'a` with `'static`
8-
help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a constraint
8+
help: to allow this `impl Trait` to capture borrowed data with lifetime `'a`, add `'a` as a bound
99
|
1010
LL | type E<'a, 'b> = impl Sized; + 'a
1111
|

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: ...can't outlive the anonymous lifetime #1 defined on the function body at
1111
|
1212
LL | fn elided(x: &i32) -> impl Copy { x }
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14-
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the function body at 3:1
14+
help: you can add a bound to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the function body at 3:1
1515
|
1616
LL | fn elided(x: &i32) -> impl Copy + '_ { x }
1717
| ^^^^^^^^^^^^^^
@@ -29,7 +29,7 @@ note: ...can't outlive the lifetime `'a` as defined on the function body at 6:13
2929
|
3030
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
3131
| ^^
32-
help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 6:13
32+
help: you can add a bound to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 6:13
3333
|
3434
LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x }
3535
| ^^^^^^^^^^^^^^
@@ -47,7 +47,7 @@ note: ...can't outlive the lifetime `'a` as defined on the function body at 12:1
4747
|
4848
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
4949
| ^^
50-
help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 12:15
50+
help: you can add a bound to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the function body at 12:15
5151
|
5252
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static + 'a { x }
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/impl-trait/static-return-lifetime-infered.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | / fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
1515
LL | | self.x.iter().map(|a| a.0)
1616
LL | | }
1717
| |_____^
18-
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 6:5
18+
help: you can add a bound to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 6:5
1919
|
2020
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -35,7 +35,7 @@ note: ...can't outlive the lifetime `'a` as defined on the method body at 10:20
3535
|
3636
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
3737
| ^^
38-
help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the method body at 10:20
38+
help: you can add a bound to the return type to make it last less than `'static` and match the lifetime `'a` as defined on the method body at 10:20
3939
|
4040
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a {
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: ...can't outlive the anonymous lifetime #1 defined on the method body at 8
1111
|
1212
LL | fn f(self: Pin<&Self>) -> impl Clone { self }
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14-
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 8:5
14+
help: you can add a bound to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 8:5
1515
|
1616
LL | fn f(self: Pin<&Self>) -> impl Clone + '_ { self }
1717
| ^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)