From cdbe76a1d402fc089976cb788efbba5b2fb2f4f2 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 11 Jun 2020 14:15:34 -0700 Subject: [PATCH] Remove uses of `matches!()` macro, incompatible with Firefox build. When we vendor Cranelift into Firefox, we need to be able to build with the Firefox CI setup (unless we carry patches on top of upstream). Unfortunately, the Firefox CI currently appears to build with a slightly older version of Rust: I can't work out which version exactly, but one without stable support for `matches!()`. A recent attempt to version-bump Cranelift failed with build errors at the two locations in this patch: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=305994046&repo=autoland&lineNumber=24829 I also see a bunch of uses of `matches!()` in Peepmatic, but those crates are not built by Firefox, so we can leave them be for now, I think. --- .github/workflows/main.yml | 6 ++++++ cranelift/codegen/src/abi.rs | 5 ++++- cranelift/codegen/src/ir/instructions.rs | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 28f18dffd2..8d3f4d5273 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -107,6 +107,12 @@ jobs: - run: cargo check --target wasm32-unknown-emscripten -p wasi-common - run: cargo check --target armv7-unknown-linux-gnueabihf -p wasi-common + # Check that codegen and wasm crates typecheck on 1.41.0; this is required + # for Firefox. + - run: rustup install 1.41.0 + - run: cargo +1.41.0 check -p cranelift-codegen + - run: cargo +1.41.0 check -p cranelift-wasm + fuzz_targets: name: Fuzz Targets diff --git a/cranelift/codegen/src/abi.rs b/cranelift/codegen/src/abi.rs index 0da415b5ce..cf4780e353 100644 --- a/cranelift/codegen/src/abi.rs +++ b/cranelift/codegen/src/abi.rs @@ -80,7 +80,10 @@ impl ValueConversion { /// Is this a conversion to pointer? pub fn is_pointer(self) -> bool { - matches!(self, Self::Pointer(_)) + match self { + Self::Pointer(_) => true, + _ => false, + } } } diff --git a/cranelift/codegen/src/ir/instructions.rs b/cranelift/codegen/src/ir/instructions.rs index 653926a242..6354b92580 100644 --- a/cranelift/codegen/src/ir/instructions.rs +++ b/cranelift/codegen/src/ir/instructions.rs @@ -311,7 +311,7 @@ impl InstructionData { arg: _, imm, } => { - if matches!(opcode, Opcode::SdivImm | Opcode::SremImm) { + if *opcode == Opcode::SdivImm || *opcode == Opcode::SremImm { imm.sign_extend_from_width(bit_width); } }