-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #3132 - rust-lang:rustup-2023-10-21, r=RalfJung
Automatic Rustup
- Loading branch information
Showing
11 changed files
with
100 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
029d00c4a3176a705e0092de3e1739f8b7c32010 | ||
249624b5043013d18c00f0401ca431c1a6baa8cd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows | ||
#![feature(coroutines, coroutine_trait)] | ||
|
||
use std::{ | ||
ops::{Coroutine, CoroutineState}, | ||
pin::Pin, | ||
}; | ||
|
||
fn firstn() -> impl Coroutine<Yield = u64, Return = ()> { | ||
static move || { | ||
let mut num = 0; | ||
let num = &mut num; | ||
*num += 0; | ||
|
||
yield *num; | ||
*num += 1; //~ERROR: has been freed | ||
} | ||
} | ||
|
||
struct CoroutineIteratorAdapter<G>(G); | ||
|
||
impl<G> Iterator for CoroutineIteratorAdapter<G> | ||
where | ||
G: Coroutine<Return = ()>, | ||
{ | ||
type Item = G::Yield; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
let me = unsafe { Pin::new_unchecked(&mut self.0) }; | ||
match me.resume(()) { | ||
CoroutineState::Yielded(x) => Some(x), | ||
CoroutineState::Complete(_) => None, | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut coroutine_iterator_2 = { | ||
let mut coroutine_iterator = Box::new(CoroutineIteratorAdapter(firstn())); | ||
coroutine_iterator.next(); // pin it | ||
|
||
Box::new(*coroutine_iterator) // move it | ||
}; // *deallocate* coroutine_iterator | ||
|
||
coroutine_iterator_2.next(); // and use moved value | ||
} |
22 changes: 11 additions & 11 deletions
22
tests/fail/generator-pinned-moved.stderr → tests/fail/coroutine-pinned-moved.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters