Rebase resume argument projections during state transform
When remapping a resume argument with projections rebase them on top of the new base. The case where resume argument has projections is unusual, but might arise with box syntax where the assignment is performed directly into the box without an intermediate temporary.
This commit is contained in:
parent
83f147b3ba
commit
8901ea29b9
3 changed files with 12 additions and 5 deletions
|
|
@ -1,8 +1,10 @@
|
|||
// run-pass
|
||||
|
||||
// Test that box-statements with yields in them work.
|
||||
|
||||
#![feature(generators, box_syntax)]
|
||||
#![feature(generators, box_syntax, generator_trait)]
|
||||
use std::pin::Pin;
|
||||
use std::ops::Generator;
|
||||
use std::ops::GeneratorState;
|
||||
|
||||
fn main() {
|
||||
let x = 0i32;
|
||||
|
|
@ -15,4 +17,8 @@ fn main() {
|
|||
_t => {}
|
||||
}
|
||||
};
|
||||
|
||||
let mut g = |_| box yield;
|
||||
assert_eq!(Pin::new(&mut g).resume(1), GeneratorState::Yielded(()));
|
||||
assert_eq!(Pin::new(&mut g).resume(2), GeneratorState::Complete(box 2));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: unused generator that must be used
|
||||
--> $DIR/yield-in-box.rs:9:5
|
||||
--> $DIR/yield-in-box.rs:11:5
|
||||
|
|
||||
LL | / || {
|
||||
LL | | let y = 2u32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue