You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lifetime error points to wrong reference in async fn return #75785
error[E0506]: cannot assign to `*x` because it is borrowed
--> src/lib.rs:3:5
|
2 | let y = &*x;
| --- borrow of `*x` occurs here
3 | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here
4 | (&32, y)
| -------- returning this value requires that `*x` is borrowed for `'1`
5 | }
| - return type of generator is (&'1 i32, &i32)
The '1 lifetime name should be given to the second reference in the tuple.
error[E0506]: cannot assign to `*x` because it is borrowed
--> src/lib.rs:3:5
|
2 | let y = &*x;
| --- borrow of `*x` occurs here
3 | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here
Per bisect-rustc, the commit that changed the output is f781bab - almost definitely #73806. @Aaron1011 is there something that can be done to improve this case?
Bisect output
searched nightlies: from nightly-2020-06-01 to nightly-2020-07-15
regressed nightly: nightly-2020-07-02
searched commits: from 16957bd to f781bab
regressed commit: f781bab
pubfnasync_fn(x:&muti32) -> (&i32,&i32){let y = &*x;*x += 1;(&32, y)}
error[E0506]: cannot assign to `*x` because it is borrowed
--> src/lib.rs:3:5
|
1 | pub fn async_fn(x: &mut i32) -> (&i32, &i32) {
| - let's call the lifetime of this reference `'1`
2 | let y = &*x;
| --- borrow of `*x` occurs here
3 | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here
4 | (&32, y)
| -------- returning this value requires that `*x` is borrowed for `'1`
It looks like we're missing the "let's call the lifetime of this reference" note in the async case.
It looks like we're missing the "let's call the lifetime of this reference" note in the async case.
The current equivalent of that annotation is the note at the bottom: (see #74072)
- return type of generator is (&'1 i32, &i32)
I actually ran into this while testing a potential fix for that issue - it would make the output
LL | pub async fn async_fn(x: &mut i32) -> (&i32, &i32) {
| - let's call the lifetime of this reference `'1`
LL | let y = &*x;
| --- borrow of `*x` occurs here
LL | *x += 1;
| ^^^^^^^ assignment to borrowed `*x` occurs here
LL | (&32, y)
| -------- returning this value requires that `*x` is borrowed for `'1`
Activity
SNCPlay42 commentedon Aug 21, 2020
On stable the output is different:
Per bisect-rustc, the commit that changed the output is f781bab - almost definitely #73806. @Aaron1011 is there something that can be done to improve this case?
Bisect output
searched nightlies: from nightly-2020-06-01 to nightly-2020-07-15
regressed nightly: nightly-2020-07-02
searched commits: from 16957bd to f781bab
regressed commit: f781bab
bisected with cargo-bisect-rustc v0.5.2
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
Aaron1011 commentedon Aug 21, 2020
Here's the output with
asyncremoved:It looks like we're missing the "let's call the lifetime of this reference" note in the
asynccase.SNCPlay42 commentedon Aug 21, 2020
The current equivalent of that annotation is the note at the bottom: (see #74072)
I actually ran into this while testing a potential fix for that issue - it would make the output
Which still points at the wrong reference.
tmandry commentedon Oct 20, 2020
@Aaron1011 Are you still planning to work on this?
Prefer regions with an `external_name` in `approx_universal_upper_bound`
Rollup merge of rust-lang#78164 - Aaron1011:fix/async-region-name, r=…