Skip to content

Commit

Permalink
Bump rust-toolchain to nightly-2021-03-17, unlocking for i in 0..n
Browse files Browse the repository at this point in the history
…loops!
  • Loading branch information
eddyb committed Mar 17, 2021
1 parent 74bf5d1 commit 45a225f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions crates/rustc_codegen_spirv/src/linker/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ fn assemble_and_link(binaries: &[&[u8]]) -> Result<Module, String> {
diagnostic_output: DiagnosticOutput::Raw(Box::new(write_diags)),
stderr: None,
lint_caps: Default::default(),
parse_sess_created: None,
register_lints: None,
override_queries: None,
make_codegen_backend: None,
Expand Down
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 {
}
}
"#);
}
4 changes: 2 additions & 2 deletions examples/runners/ash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,15 +1217,15 @@ impl PipelineDescriptor {
.build();

Self {
color_blend_attachments,
dynamic_state,
shader_stages,
vertex_input,
input_assembly,
rasterization,
multisample,
depth_stencil,
color_blend_attachments,
color_blend,
dynamic_state,
dynamic_state_info,
}
}
Expand Down
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-17"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

0 comments on commit 45a225f

Please sign in to comment.