Skip to content

Commit 84044cd

Browse files
Bless test fallout
1 parent eae5b5c commit 84044cd

30 files changed

+124
-186
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/region.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use rustc_span::{BytePos, ErrorGuaranteed, Span, Symbol};
1717
use rustc_type_ir::Upcast as _;
1818

1919
use super::nice_region_error::find_anon_type;
20-
use super::{nice_region_error, ObligationCauseAsDiagArg};
21-
use crate::error_reporting::infer::ObligationCauseExt as _;
20+
use super::ObligationCauseAsDiagArg;
21+
use crate::error_reporting::infer::ObligationCauseExt;
2222
use crate::error_reporting::TypeErrCtxt;
2323
use crate::errors::{
2424
self, note_and_explain, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound,
@@ -1212,22 +1212,8 @@ pub fn unexpected_hidden_region_diagnostic<'a, 'tcx>(
12121212
hidden_region,
12131213
"",
12141214
);
1215-
if let Some(reg_info) = tcx.is_suitable_region(generic_param_scope, hidden_region) {
1216-
if infcx.tcx.features().precise_capturing {
1217-
suggest_precise_capturing(tcx, opaque_ty_key.def_id, hidden_region, &mut err);
1218-
} else {
1219-
let fn_returns = tcx.return_type_impl_or_dyn_traits(reg_info.def_id);
1220-
nice_region_error::suggest_new_region_bound(
1221-
tcx,
1222-
&mut err,
1223-
fn_returns,
1224-
hidden_region.to_string(),
1225-
None,
1226-
format!("captures `{hidden_region}`"),
1227-
None,
1228-
Some(reg_info.def_id),
1229-
)
1230-
}
1215+
if let Some(_) = tcx.is_suitable_region(generic_param_scope, hidden_region) {
1216+
suggest_precise_capturing(tcx, opaque_ty_key.def_id, hidden_region, &mut err);
12311217
}
12321218
}
12331219
ty::RePlaceholder(_) => {

tests/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ LL | | (a, b)
2626
LL | | }
2727
| |_^
2828
|
29-
help: to declare that `impl Trait<'a>` captures `'b`, you can add an explicit `'b` lifetime bound
29+
help: add a `use<...>` bound to explicitly capture `'b`
3030
|
31-
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
32-
| ++++
31+
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + use<'a, 'b> {
32+
| +++++++++++++
3333

3434
error: aborting due to 2 previous errors
3535

tests/ui/borrowck/alias-liveness/opaque-type-param.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ LL | fn foo<'a>(s: &'a str) -> impl Trait + 'static {
77
| hidden type `impl Trait + 'static` captures the lifetime `'a` as defined here
88
LL | bar(s)
99
| ^^^^^^
10+
|
11+
help: add a `use<...>` bound to explicitly capture `'a`
12+
|
13+
LL | fn foo<'a>(s: &'a str) -> impl Trait + 'static + use<'a> {
14+
| +++++++++
1015

1116
error: aborting due to 1 previous error
1217

tests/ui/const-generics/generic_const_exprs/issue-109141.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ LL | fn a(&self) -> impl Iterator {
3030
LL | self.0.iter_mut()
3131
| ^^^^^^^^^^^^^^^^^
3232
|
33-
help: to declare that `impl Iterator` captures `'_`, you can add an explicit `'_` lifetime bound
33+
help: add a `use<...>` bound to explicitly capture `'_`
3434
|
35-
LL | fn a(&self) -> impl Iterator + '_ {
36-
| ++++
35+
LL | fn a(&self) -> impl Iterator + use<'_> {
36+
| +++++++++
3737

3838
error: aborting due to 3 previous errors
3939

tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ LL | fn foo(x: &Vec<i32>) -> impl Sized {
88
LL | x
99
| ^
1010
|
11-
help: to declare that `impl Sized` captures `'_`, you can add an explicit `'_` lifetime bound
11+
help: add a `use<...>` bound to explicitly capture `'_`
1212
|
13-
LL | fn foo(x: &Vec<i32>) -> impl Sized + '_ {
14-
| ++++
13+
LL | fn foo(x: &Vec<i32>) -> impl Sized + use<'_> {
14+
| +++++++++
1515

1616
error: aborting due to 1 previous error
1717

tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a {
88
LL | step1::<'a, 'b>()
99
| ^^^^^^^^^^^^^^^^^
1010
|
11-
help: to declare that `impl Sized + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
11+
help: add a `use<...>` bound to explicitly capture `'b`
1212
|
13-
LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a + 'b {
14-
| ++++
13+
LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a + use<'a, 'b> {
14+
| +++++++++++++
1515

1616
error: aborting due to 1 previous error
1717

tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
88
LL | x
99
| ^
1010
|
11-
help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
11+
help: add a `use<...>` bound to explicitly capture `'b`
1212
|
13-
LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + 'b {
14-
| ++++
13+
LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + use<'a, 'b, T> {
14+
| ++++++++++++++++
1515

1616
error: aborting due to 1 previous error
1717

tests/ui/impl-trait/hidden-lifetimes.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a {
88
LL | x
99
| ^
1010
|
11-
help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
11+
help: add a `use<...>` bound to explicitly capture `'b`
1212
|
13-
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b {
14-
| ++++
13+
LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + use<'a, 'b, T> {
14+
| ++++++++++++++++
1515

1616
error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds
1717
--> $DIR/hidden-lifetimes.rs:46:5
@@ -23,10 +23,10 @@ LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl S
2323
LL | x
2424
| ^
2525
|
26-
help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
26+
help: add a `use<...>` bound to explicitly capture `'b`
2727
|
28-
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + 'b {
29-
| ++++
28+
LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + use<'a, 'b, T> {
29+
| ++++++++++++++++
3030

3131
error: aborting due to 2 previous errors
3232

tests/ui/impl-trait/in-trait/cannot-capture-intersection.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(precise_capturing)]
2-
31
use std::future::Future;
42
use std::pin::Pin;
53

tests/ui/impl-trait/in-trait/cannot-capture-intersection.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0700]: hidden type for `impl Future<Output = i32>` captures lifetime that does not appear in bounds
2-
--> $DIR/cannot-capture-intersection.rs:24:9
2+
--> $DIR/cannot-capture-intersection.rs:22:9
33
|
44
LL | fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = i32> {
55
| ------------------------- opaque type defined here

0 commit comments

Comments
 (0)