From 9f72e001a0a761f711739bfe07c8ea54136ec5da Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Thu, 24 Dec 2015 23:05:57 -0500 Subject: [PATCH] Add test. --- src/test/run-pass/mir_match_arm_guard.rs | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/run-pass/mir_match_arm_guard.rs diff --git a/src/test/run-pass/mir_match_arm_guard.rs b/src/test/run-pass/mir_match_arm_guard.rs new file mode 100644 index 0000000000000..fb177ba7b2bb0 --- /dev/null +++ b/src/test/run-pass/mir_match_arm_guard.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #30527 - We were not generating arms with guards in certain cases. + +#![feature(rustc_attrs)] + +#[rustc_mir] +fn match_with_guard(x: Option) -> i8 { + match x { + Some(xyz) if xyz > 100 => 0, + Some(_) => -1, + None => -2 + } +} + +fn main() { + assert_eq!(match_with_guard(Some(111)), 0); + assert_eq!(match_with_guard(Some(2)), -1); + assert_eq!(match_with_guard(None), -2); +}