Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
/// --> $DIR/lifetime-bound-will-change-warning.rs:44:5
/// |
/// LL | fn test2<'a>(x: &'a Box<Fn()+'a>) {
/// | - `x` is a reference that is only valid in the function body
/// | - `x` is only valid in the function body
/// LL | // but ref_obj will not, so warn.
/// LL | ref_obj(x)
/// | ^^^^^^^^^^ `x` escapes the function body here
Expand Down Expand Up @@ -714,9 +714,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
if let Some((Some(fr_name), fr_span)) = fr_name_and_span {
diag.span_label(
fr_span,
format!(
"`{fr_name}` is a reference that is only valid in the {escapes_from} body",
),
format!("`{fr_name}` is only valid in the {escapes_from} body"),
);

diag.span_label(*span, format!("`{fr_name}` escapes the {escapes_from} body here"));
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/crashes/ice-6256.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let f = |x: &dyn TT| x.func();
| | | `x` escapes the closure body here
| | | argument requires that `'1` must outlive `'static`
| | let's call the lifetime of this reference `'1`
| `x` is a reference that is only valid in the closure body
| `x` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/any/any_static.next.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn extend(a: &Payload) -> &'static Payload {
| - - let's call the lifetime of this reference `'1`
| |
| `a` is a reference that is only valid in the function body
| `a` is only valid in the function body
LL | let b: &(dyn Any + 'static) = try_as_dyn::<&Payload, dyn Any + 'static>(&a).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/any/any_static.old.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn extend(a: &Payload) -> &'static Payload {
| - - let's call the lifetime of this reference `'1`
| |
| `a` is a reference that is only valid in the function body
| `a` is only valid in the function body
LL | let b: &(dyn Any + 'static) = try_as_dyn::<&Payload, dyn Any + 'static>(&a).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/any/static_method_bound.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn extend(a: &Payload) -> &'static Payload {
| - - let's call the lifetime of this reference `'1`
| |
| `a` is a reference that is only valid in the function body
| `a` is only valid in the function body
LL | let b: &(dyn Trait + 'static) = try_as_dyn::<&Payload, dyn Trait + 'static>(&a).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/issues/issue-62097.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method
LL | pub async fn run_dummy_fn(&self) {
| -----
| |
| `self` is a reference that is only valid in the method body
| `self` is only valid in the method body
| let's call the lifetime of this reference `'1`
LL | foo(|| self.bar()).await;
| ^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/issues/issue-72312.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct Problem;
impl Problem {
pub async fn start(&self) {
//~^ NOTE let's call
//~| NOTE `self` is a reference
//~| NOTE `self` is only valid
require_static(async move {
//~^ ERROR borrowed data escapes
//~| NOTE `self` escapes
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/issues/issue-72312.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method
LL | pub async fn start(&self) {
| -----
| |
| `self` is a reference that is only valid in the method body
| `self` is only valid in the method body
| let's call the lifetime of this reference `'1`
...
LL | / require_static(async move {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/anonymous-region-in-apit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | |baz: &str| foo.bar(baz);
| | | `baz` escapes the closure body here
| | | argument requires that `'1` must outlive `'2`
| | let's call the lifetime of this reference `'1`
| `baz` is a reference that is only valid in the closure body
| `baz` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/fn-item-check-type-params.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/fn-item-check-type-params.rs:31:5
|
LL | pub fn test_call<'a>(val: &'a str) {
| -- --- `val` is a reference that is only valid in the function body
| -- --- `val` is only valid in the function body
| |
| lifetime `'a` defined here
LL | extend_lt(val);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/ice-on-non-ref-sig-ty.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method
LL | impl<'a> W<'a> for &'static () {
| -- lifetime `'a` defined here
LL | fn g<T>(self, x: &'a T) -> &'static T {
| ---- - `x` is a reference that is only valid in the method body
| ---- - `x` is only valid in the method body
| |
| `self` declared here, outside of the method body
LL | f(&self, x)
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-103624.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method
LL | async fn foo(&self) {
| -----
| |
| `self` is a reference that is only valid in the method body
| `self` is only valid in the method body
| let's call the lifetime of this reference `'1`
LL | let bar = self.b.bar().await;
LL | / spawn_blocking(move || {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-45983.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | let mut x = None;
LL | give_any(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
| `y` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-7573.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn remove_package_from_database() {
let mut lines_to_use: Vec<&CrateId> = Vec::new();
//~^ NOTE `lines_to_use` declared here, outside of the closure body
let push_id = |installed_id: &CrateId| {
//~^ NOTE `installed_id` is a reference that is only valid in the closure body
//~^ NOTE `installed_id` is only valid in the closure body
lines_to_use.push(installed_id);
//~^ ERROR borrowed data escapes outside of closure
//~| NOTE `installed_id` escapes the closure body here
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-7573.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
| ---------------- `lines_to_use` declared here, outside of the closure body
LL |
LL | let push_id = |installed_id: &CrateId| {
| ------------ `installed_id` is a reference that is only valid in the closure body
| ------------ `installed_id` is only valid in the closure body
LL |
LL | lines_to_use.push(installed_id);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/regions-escape-bound-fn-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | let mut x = None;
LL | with_int(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
| `y` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/regions-escape-bound-fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | let mut x: Option<&isize> = None;
LL | with_int(|y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
| `y` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/regions-escape-unboxed-closure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | let mut x: Option<&isize> = None;
LL | with_int(&mut |y| x = Some(y));
| - ^^^^^^^^^^^ `y` escapes the closure body here
| |
| `y` is a reference that is only valid in the closure body
| `y` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn foo<'a>(
| -- lifetime `'a` defined here
LL | used_arg: &'a u8,
| -------- `used_arg` is a reference that is only valid in the function body
| -------- `used_arg` is only valid in the function body
...
LL | consume(c);
| ^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ LL | fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) {
| -- ---
| | |
| | `ptr` declared here, outside of the function body
| | `ptr` is a reference that is only valid in the function body
| | `ptr` is only valid in the function body
| lifetime `'a` defined here
LL | require_static(ptr as _)
| ^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn foo(x: &()) {
| - - let's call the lifetime of this reference `'1`
| |
| `x` is a reference that is only valid in the function body
| `x` is only valid in the function body
LL | / bar(|| {
LL | |
LL | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of closure
LL | let mut f: Option<&u32> = None;
| ----- `f` declared here, outside of the closure body
LL | closure_expecting_bound(|x| {
| - `x` is a reference that is only valid in the closure body
| - `x` is only valid in the closure body
LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here

Expand All @@ -14,7 +14,7 @@ error[E0521]: borrowed data escapes outside of closure
LL | let mut f: Option<&u32> = None;
| ----- `f` declared here, outside of the closure body
LL | closure_expecting_bound(|x: &u32| {
| - `x` is a reference that is only valid in the closure body
| - `x` is only valid in the closure body
LL | f = Some(x);
| ^^^^^^^^^^^ `x` escapes the closure body here

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/coroutine/resume-arg-outlives-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/resume-arg-outlives-2.rs:21:5
|
LL | fn demo<'not_static>(s: &'not_static str) -> thread::JoinHandle<()> {
| ----------- - `s` is a reference that is only valid in the function body
| ----------- - `s` is only valid in the function body
| |
| lifetime `'not_static` defined here
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool
| ---- - let's call the lifetime of this reference `'1`
| |
| `iter` is a reference that is only valid in the function body
| `iter` is only valid in the function body
...
LL | let _next = iter2.next();
| ^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn fails(iter: &str) {
| ---- - let's call the lifetime of this reference `'1`
| |
| `iter` is a reference that is only valid in the function body
| `iter` is only valid in the function body
LL | trivial_bound(iter);
| ^^^^^^^^^^^^^^^^^^^
| |
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/impl-header-lifetime-elision/dyn-trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/dyn-trait.rs:24:5
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| -- - `x` is a reference that is only valid in the function body
| -- - `x` is only valid in the function body
| |
| lifetime `'a` defined here
LL | static_val(x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn inner(mut foo: &[u8]) {
| ------- - let's call the lifetime of this reference `'1`
| |
| `foo` is a reference that is only valid in the function body
| `foo` is only valid in the function body
...
LL | read_thing(read);
| ^^^^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lifetimes/lifetime-bound-will-change-warning.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/lifetime-bound-will-change-warning.rs:34:5
|
LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) {
| -- - `x` is a reference that is only valid in the function body
| -- - `x` is only valid in the function body
| |
| lifetime `'a` defined here
LL | // but ref_obj will not, so warn.
Expand All @@ -16,7 +16,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/lifetime-bound-will-change-warning.rs:40:5
|
LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) {
| -- - `x` is a reference that is only valid in the function body
| -- - `x` is only valid in the function body
| |
| lifetime `'a` defined here
LL | // same as test2, but cross crate
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/closure-arg-type-mismatch.rs:10:5
|
LL | fn _test<'a>(f: fn(*mut &'a u32)) {
| -- - `f` is a reference that is only valid in the function body
| -- - `f` is only valid in the function body
| |
| lifetime `'a` defined here
LL | baz(f);
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/nll/check-normalized-sig-for-wf.current.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn extend<T>(input: &T) -> &'static T {
| ----- - let's call the lifetime of this reference `'1`
| |
| `input` is a reference that is only valid in the function body
| `input` is only valid in the function body
...
LL | n(input).0
| ^^^^^^^^
Expand All @@ -31,7 +31,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/check-normalized-sig-for-wf.rs:27:5
|
LL | fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T {
| -- ----- `input` is a reference that is only valid in the function body
| -- ----- `input` is only valid in the function body
| |
| lifetime `'a` defined here
...
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/nll/check-normalized-sig-for-wf.next.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ error[E0521]: borrowed data escapes outside of function
LL | fn extend<T>(input: &T) -> &'static T {
| ----- - let's call the lifetime of this reference `'1`
| |
| `input` is a reference that is only valid in the function body
| `input` is only valid in the function body
...
LL | n(input).0
| ^^^^^^^^
Expand All @@ -31,7 +31,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/check-normalized-sig-for-wf.rs:27:5
|
LL | fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T {
| -- ----- `input` is a reference that is only valid in the function body
| -- ----- `input` is only valid in the function body
| |
| lifetime `'a` defined here
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ error[E0521]: borrowed data escapes outside of closure
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:22:9
|
LL | foo(cell, |cell_a, cell_x| {
| ------ ------ `cell_x` is a reference that is only valid in the closure body
| ------ ------ `cell_x` is only valid in the closure body
| |
| `cell_a` declared here, outside of the closure body
LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:34:9
|
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| -- ------ `cell_a` is a reference that is only valid in the function body
| -- ------ `cell_a` is only valid in the function body
| |
| lifetime `'a` defined here
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:37:9
|
LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) {
| -- ------ `cell_a` is a reference that is only valid in the function body
| -- ------ `cell_a` is only valid in the function body
| |
| lifetime `'a` defined here
...
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/nll/issue-54779-anon-static-lifetime.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0521]: borrowed data escapes outside of method
LL | cx: &dyn DebugContext,
| -- - let's call the lifetime of this reference `'1`
| |
| `cx` is a reference that is only valid in the method body
| `cx` is only valid in the method body
...
LL | bar.debug_with(cx);
| ^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/nll/user-annotations/closure-substs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ error[E0521]: borrowed data escapes outside of closure
LL | |x: &i32, b: fn(&'static i32)| {
| - - let's call the lifetime of this reference `'1`
| |
| `x` is a reference that is only valid in the closure body
| `x` is only valid in the closure body
LL | b(x);
| ^^^^
| |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ error[E0521]: borrowed data escapes outside of function
--> $DIR/object-lifetime-default-mybox.rs:32:5
|
LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> {
| -- -- `ss` is a reference that is only valid in the function body
| -- -- `ss` is only valid in the function body
| |
| lifetime `'a` defined here
LL | load0(ss)
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/regions/issue-78262.base.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let f = |x: &dyn TT| x.func();
| | | `x` escapes the closure body here
| | | argument requires that `'1` must outlive `'static`
| | let's call the lifetime of this reference `'1`
| `x` is a reference that is only valid in the closure body
| `x` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/regions/issue-78262.polonius.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | let f = |x: &dyn TT| x.func();
| | | `x` escapes the closure body here
| | | argument requires that `'1` must outlive `'static`
| | let's call the lifetime of this reference `'1`
| `x` is a reference that is only valid in the closure body
| `x` is only valid in the closure body

error: aborting due to 1 previous error

Expand Down
Loading
Loading