rust/tests/ui/range/range-inclusive-pattern-precedence.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
655 B
Rust
Raw Normal View History

// In expression, `&a..=b` is treated as `(&a)..=(b)` and `box a..=b` is
// `(box a)..=(b)`. In a pattern, however, `&a..=b` means `&(a..=b)`. This may
// lead to confusion.
2020-07-02 00:32:12 -05:00
// run-rustfix
2020-07-02 00:32:12 -05:00
#![warn(ellipsis_inclusive_range_patterns)]
pub fn main() {
match &12 {
&0...9 => {}
//~^ WARN `...` range patterns are deprecated
2021-06-16 07:27:44 -05:00
//~| WARN this is accepted in the current edition
//~| HELP use `..=` for an inclusive range
&10..=15 => {}
//~^ ERROR the range pattern here has ambiguous interpretation
2021-04-16 04:06:51 -05:00
//~| HELP add parentheses to clarify the precedence
&(16..=20) => {}
_ => {}
}
}