Skip to content

Commit

Permalink
Bump rust-toolchain to nightly-2021-03-15, unlocking for i in 0..n
Browse files Browse the repository at this point in the history
…loops!
  • Loading branch information
eddyb committed Mar 15, 2021
1 parent 74bf5d1 commit cbce87a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
19 changes: 16 additions & 3 deletions crates/spirv-builder/src/test/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,11 @@ pub fn main() {
}"#);
}

// HACK(eddyb) test that `for` loop desugaring (with its call to `Iterator::next`
// and matching on the resulting `Option`) works, without a working `Range`
// iterator (due to the use of `mem::swap` and its block-wise implementation).
// NOTE(eddyb) this tests `for` loop desugaring (with its call to `Iterator::next`
// and matching on the resulting `Option`), without relying on a `Range` iterator.
// More precisely, `Range` used to not compile, due to it using `mem::replace`,
// which, before https://github.com/rust-lang/rust/pull/83022, used to just call
// `mem::swap` (which has a block-wise optimization that can't work on SPIR-V).
#[test]
fn cf_for_with_custom_range_iter() {
val(r#"
Expand Down Expand Up @@ -408,3 +410,14 @@ pub fn main(i: Input<i32>) {
}
"#);
}

#[test]
fn cf_for_range() {
val(r#"
#[spirv(fragment)]
pub fn main(i: Input<i32>) {
for _ in 0..*i {
}
}
"#);
}
5 changes: 1 addition & 4 deletions examples/shaders/mouse-shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ pub fn main_fs(
.intersect(mouse_circle)
};

// FIXME(eddyb) use a `for i in 0..3` loop when that works.
let mut i = 0;
while i < 3 {
for i in 0..3 {
painter.fill(
mouse_button(i),
RED.lerp(
Expand All @@ -242,7 +240,6 @@ pub fn main_fs(
),
),
);
i += 1;
}

painter.fill_with_contrast_border(
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".

[toolchain]
channel = "nightly-2021-03-11"
channel = "nightly-2021-03-15"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

0 comments on commit cbce87a

Please sign in to comment.