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

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

22 lines
659 B
Rust
Raw Normal View History

2020-07-02 05:32:12 +00:00
// 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.
// run-rustfix
#![warn(ellipsis_inclusive_range_patterns)]
pub fn main() {
match &12 {
&(0..=9) => {}
//~^ WARN `...` range patterns are deprecated
2021-06-16 12:27:44 +00:00
//~| WARN this is accepted in the current edition
2020-07-02 05:32:12 +00:00
//~| HELP use `..=` for an inclusive range
&(10..=15) => {}
2020-07-02 05:32:12 +00:00
//~^ ERROR the range pattern here has ambiguous interpretation
2021-04-16 09:06:51 +00:00
//~| HELP add parentheses to clarify the precedence
2020-07-02 05:32:12 +00:00
&(16..=20) => {}
_ => {}
}
}