Skip to content

Commit 85c7081

Browse files
committed
Sync from rust 37b2813
2 parents 9c95819 + 4ae6586 commit 85c7081

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

build_system/tests.rs

+9
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
104104
runner.run_out_command("polymorphize_coroutine", &[]);
105105
}),
106106
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
107+
TestCase::custom("aot.gen_block_iterate", &|runner| {
108+
runner.run_rustc([
109+
"example/gen_block_iterate.rs",
110+
"--edition",
111+
"2024",
112+
"-Zunstable-options",
113+
]);
114+
runner.run_out_command("gen_block_iterate", &[]);
115+
}),
107116
];
108117

109118
pub(crate) static RAND_REPO: GitRepo = GitRepo::github(

config.txt

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ aot.issue-72793
4444
aot.issue-59326
4545
aot.polymorphize_coroutine
4646
aot.neon
47+
aot.gen_block_iterate
4748

4849
testsuite.extended_sysroot
4950
test.rust-random/rand

example/gen_block_iterate.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copied from https://github.com/rust-lang/rust/blob/46455dc65069387f2dc46612f13fd45452ab301a/tests/ui/coroutine/gen_block_iterate.rs
2+
// revisions: next old
3+
//compile-flags: --edition 2024 -Zunstable-options
4+
//[next] compile-flags: -Ztrait-solver=next
5+
// run-pass
6+
#![feature(gen_blocks)]
7+
8+
fn foo() -> impl Iterator<Item = u32> {
9+
gen { yield 42; for x in 3..6 { yield x } }
10+
}
11+
12+
fn moved() -> impl Iterator<Item = u32> {
13+
let mut x = "foo".to_string();
14+
gen move {
15+
yield 42;
16+
if x == "foo" { return }
17+
x.clear();
18+
for x in 3..6 { yield x }
19+
}
20+
}
21+
22+
fn main() {
23+
let mut iter = foo();
24+
assert_eq!(iter.next(), Some(42));
25+
assert_eq!(iter.next(), Some(3));
26+
assert_eq!(iter.next(), Some(4));
27+
assert_eq!(iter.next(), Some(5));
28+
assert_eq!(iter.next(), None);
29+
// `gen` blocks are fused
30+
assert_eq!(iter.next(), None);
31+
32+
let mut iter = moved();
33+
assert_eq!(iter.next(), Some(42));
34+
assert_eq!(iter.next(), None);
35+
36+
}

rustfmt.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
ignore = ["y.rs"]
1+
ignore = [
2+
"y.rs",
3+
"example/gen_block_iterate.rs", # uses edition 2024
4+
]
25

36
# Matches rustfmt.toml of rustc
47
version = "Two"

0 commit comments

Comments
 (0)