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
Coroutine upvars are not required to be live in borrowck if witness has no drop requirements #144155
structNeedsDrop<'a>(&'aVec<i32>);implDropforNeedsDrop<'_>{fndrop(&mutself){println!("dropping {:#?}",self.0);}}asyncfnawait_point(){}fnmain(){let v = vec![1,2,3];let x = NeedsDrop(&v);let c = async{
std::future::ready(()).await;drop(x);};drop(v);}
I expected it to fail, since dropping the coroutine c requires that NeedsDrop's 'a lifetime is live, since dropping the coroutine also performs a drop of NeedsDrop (as an upvar).
Instead, it compiled. This is UB.
This fails on rustc as of nightly 2025-07-18. Not sure if this has either always been incorrect, or if this was introduced due to the fix in #117134.
error[E0505]: cannot move out of `v` because it is borrowed
--> /tmp/crash.rs:18:10
|
12 | let v = vec![1, 2, 3];
| - binding `v` declared here
13 | let x = NeedsDrop(&v);
| -- borrow of `v` occurs here
...
18 | drop(v);
| ^ move out of `v` occurs here
19 | }
| - borrow might be used here, when `c` is dropped and runs the destructor for coroutine
error: aborting due to previous error; 1 warning emitted
nightly-2023-11-03
pass
prs:
commit[0] 2023-11-01: Auto merge of #117029 - rmehri01:mir_opt_filecheck_inline_tests, r=cjgillot
commit[1] 2023-11-01: Auto merge of #117498 - matthiaskrgr:rollup-z7mg4ck, r=matthiaskrgr
commit[2] 2023-11-02: Auto merge of #117506 - massivebird:ord-typo, r=ChrisDenton
commit[3] 2023-11-02: Auto merge of #117386 - roblabla:fix-switch-stdio-win7, r=ChrisDenton
commit[4] 2023-11-02: Auto merge of #117204 - nnethercote:rustc_ast_passes, r=compiler-errors
commit[5] 2023-11-02: Auto merge of #117466 - compiler-errors:alias-bound, r=aliemjay
commit[6] 2023-11-02: Auto merge of #117513 - matthiaskrgr:rollup-jvl6y84, r=matthiaskrgr
commit[7] 2023-11-02: Auto merge of #117521 - GuillaumeGomez:impl-on-foreign-order, r=notriddle
commit[8] 2023-11-02: Auto merge of #117471 - onur-ozkan:tmp-fix, r=clubby789
commit[9] 2023-11-02: Auto merge of #117134 - lcnr:dropck_outlives-coroutine, r=compiler-errors
Activity
compiler-errors commentedon Jul 18, 2025
Bisection would be helpful if someone wants to do this; specifically, I want to know if this code went from fail->pass sometime in the past.
lqd commentedon Jul 18, 2025
For me this has always failed since 1.36 until #117134 (or say, until 1.74 as I haven't bisected the 1.73 to 1.74 nightlies)
matthiaskrgr commentedon Jul 18, 2025
nightly-2023-11-02nightly-2023-11-03pass
prs:
commit[0] 2023-11-01: Auto merge of #117029 - rmehri01:mir_opt_filecheck_inline_tests, r=cjgillot
commit[1] 2023-11-01: Auto merge of #117498 - matthiaskrgr:rollup-z7mg4ck, r=matthiaskrgr
commit[2] 2023-11-02: Auto merge of #117506 - massivebird:ord-typo, r=ChrisDenton
commit[3] 2023-11-02: Auto merge of #117386 - roblabla:fix-switch-stdio-win7, r=ChrisDenton
commit[4] 2023-11-02: Auto merge of #117204 - nnethercote:rustc_ast_passes, r=compiler-errors
commit[5] 2023-11-02: Auto merge of #117466 - compiler-errors:alias-bound, r=aliemjay
commit[6] 2023-11-02: Auto merge of #117513 - matthiaskrgr:rollup-jvl6y84, r=matthiaskrgr
commit[7] 2023-11-02: Auto merge of #117521 - GuillaumeGomez:impl-on-foreign-order, r=notriddle
commit[8] 2023-11-02: Auto merge of #117471 - onur-ozkan:tmp-fix, r=clubby789
commit[9] 2023-11-02: Auto merge of #117134 - lcnr:dropck_outlives-coroutine, r=compiler-errors
compiler-errors commentedon Jul 18, 2025
this one ^
Rollup merge of rust-lang#144156 - compiler-errors:dtorck-upvars, r=lcnr
Unrolled build for #144156