]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-13027.rs
3 // Tests that match expression handles overlapped literal and range
4 // properly in the presence of guard function.
6 fn val() -> usize { 1 }
8 static CONST
: usize = 1;
14 multi_pats_shadow_lit();
15 multi_pats_shadow_range();
16 lit_shadow_multi_pats();
17 range_shadow_multi_pats();
21 fn lit_shadow_range() {
22 assert_eq
!(2, match 1 {
29 assert_eq
!(2, match x
+1 {
36 assert_eq
!(2, match val() {
42 assert_eq
!(2, match CONST
{
49 // value is out of the range of second arm, should match wildcard pattern
50 assert_eq
!(3, match 3 {
57 fn range_shadow_lit() {
58 assert_eq
!(2, match 1 {
65 assert_eq
!(2, match x
+1 {
72 assert_eq
!(2, match val() {
78 assert_eq
!(2, match CONST
{
86 assert_eq
!(3, match 3 {
93 fn range_shadow_range() {
94 assert_eq
!(2, match 1 {
101 assert_eq
!(2, match x
+1 {
108 assert_eq
!(2, match val() {
114 assert_eq
!(2, match CONST
{
122 assert_eq
!(3, match 5 {
129 fn multi_pats_shadow_lit() {
130 assert_eq
!(2, match 1 {
132 0 | 1..=10 if false => 1,
138 fn multi_pats_shadow_range() {
139 assert_eq
!(2, match 1 {
141 0 | 1..=10 if false => 1,
147 fn lit_shadow_multi_pats() {
148 assert_eq
!(2, match 1 {
156 fn range_shadow_multi_pats() {
157 assert_eq
!(2, match 1 {
169 // This test basically mimics how trace_macros! macro is implemented,
170 // which is a rare combination of vector patterns, multiple wild-card
171 // patterns and guard functions.
172 let r
= match [Foo
::Bar(0, false)] {
173 [Foo
::Bar(_
, pred
)] if pred
=> 1,
174 [Foo
::Bar(_
, pred
)] if !pred
=> 2,