-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
127 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use async_stream::stream; | ||
use futures_util::StreamExt; | ||
|
||
use std::pin::pin; | ||
|
||
macro_rules! asynk { | ||
($e:expr) => { | ||
async { $e } | ||
}; | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
pin!(stream! { | ||
let yield_42 = asynk!(yield 42_usize); | ||
let s = stream! { | ||
yield Box::new(12345); | ||
yield_42.await; // yield 42 -- wait that's not a Box!? | ||
}; | ||
for await (n, i) in s.enumerate() { | ||
println!("Item at index {n}:\n {i}"); | ||
// Item at index 0: | ||
// 12345 | ||
// Item at index 1: | ||
// Segmentation fault | ||
} | ||
}) | ||
.next() | ||
.await; | ||
} |
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,36 @@ | ||
error[E0767]: use of unreachable label `'__async_stream_private_check_scope` | ||
--> tests/ui/unsoundness_issue_106.rs:14:10 | ||
| | ||
14 | pin!(stream! { | ||
| __________^ | ||
15 | | let yield_42 = asynk!(yield 42_usize); | ||
16 | | let s = stream! { | ||
17 | | yield Box::new(12345); | ||
... | | ||
26 | | } | ||
27 | | }) | ||
| | ^ | ||
| | | | ||
| |_____unreachable label `'__async_stream_private_check_scope` | ||
| unreachable label defined here | ||
| | ||
= note: labels are unreachable through functions, closures, async blocks and modules | ||
= note: this error originates in the macro `$crate::__private::stream_inner` which comes from the expansion of the macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0267]: `break` inside `async` block | ||
--> tests/ui/unsoundness_issue_106.rs:14:10 | ||
| | ||
8 | async { $e } | ||
| ----- enclosing `async` block | ||
... | ||
14 | pin!(stream! { | ||
| __________^ | ||
15 | | let yield_42 = asynk!(yield 42_usize); | ||
16 | | let s = stream! { | ||
17 | | yield Box::new(12345); | ||
... | | ||
26 | | } | ||
27 | | }) | ||
| |_____^ cannot `break` inside `async` block | ||
| | ||
= note: this error originates in the macro `$crate::__private::stream_inner` which comes from the expansion of the macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info) |
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,23 @@ | ||
use async_stream::stream; | ||
use futures_util::StreamExt; | ||
|
||
use std::pin::pin; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let mut outer = vec![]; | ||
{ | ||
let v = vec![0; 10]; | ||
let v_ref = &v; | ||
let mut s = pin!(stream! { | ||
for x in v_ref { | ||
yield x | ||
} | ||
}); | ||
while let Some(x) = s.next().await { | ||
outer.push(x); | ||
} | ||
}; | ||
// use-after-free | ||
println!("{outer:?}"); // […garbage allocator internals…, 0, 0, 0] | ||
} |
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,13 @@ | ||
error[E0597]: `v` does not live long enough | ||
--> tests/ui/unsoundness_issue_107.rs:11:21 | ||
| | ||
10 | let v = vec![0; 10]; | ||
| - binding `v` declared here | ||
11 | let v_ref = &v; | ||
| ^^ borrowed value does not live long enough | ||
... | ||
20 | }; | ||
| - `v` dropped here while still borrowed | ||
21 | // use-after-free | ||
22 | println!("{outer:?}"); // […garbage allocator internals…, 0, 0, 0] | ||
| --------- borrow later used here |