Update ui and run-pass for ellipsis_inclusive_range_patterns lint
This commit is contained in:
parent
bf0da6c6ce
commit
e18885e21f
@ -1,5 +1,6 @@
|
||||
// run-pass
|
||||
#![allow(dead_code, unreachable_patterns)]
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
|
||||
struct Foo;
|
||||
|
||||
@ -23,4 +24,17 @@ fn main() {
|
||||
<Foo as HasNum>::NUM ... <Foo>::NUM => true,
|
||||
_ => false,
|
||||
});
|
||||
|
||||
assert!(match 2 {
|
||||
Foo::NUM ..= 3 => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(match 0 {
|
||||
-1 ..= <Foo as HasNum>::NUM => true,
|
||||
_ => false,
|
||||
});
|
||||
assert!(match 1 {
|
||||
<Foo as HasNum>::NUM ..= <Foo>::NUM => true,
|
||||
_ => false,
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// run-pass
|
||||
// Parsing of range patterns
|
||||
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
|
||||
const NUM1: i32 = 10;
|
||||
|
||||
mod m {
|
||||
@ -11,4 +13,8 @@ fn main() {
|
||||
if let NUM1 ... m::NUM2 = 10 {} else { panic!() }
|
||||
if let ::NUM1 ... ::m::NUM2 = 11 {} else { panic!() }
|
||||
if let -13 ... -10 = 12 { panic!() } else {}
|
||||
|
||||
if let NUM1 ..= m::NUM2 = 10 {} else { panic!() }
|
||||
if let ::NUM1 ..= ::m::NUM2 = 11 {} else { panic!() }
|
||||
if let -13 ..= -10 = 12 { panic!() } else {}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
// Test old and new syntax for inclusive range patterns.
|
||||
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
|
||||
fn main() {
|
||||
assert!(match 42 { 0 ... 100 => true, _ => false });
|
||||
assert!(match 42 { 0 ..= 100 => true, _ => false });
|
||||
|
@ -1,5 +1,6 @@
|
||||
// run-pass
|
||||
#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
|
||||
// regression test for the model lexer handling the DOTDOTDOT syntax (#15877)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![allow(dead_code)]
|
||||
fn test1(x: i8) -> i32 {
|
||||
match x {
|
||||
1...10 => 0,
|
||||
1..=10 => 0,
|
||||
_ => 1,
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,32 @@
|
||||
// compile-pass
|
||||
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
#![allow(unreachable_patterns)]
|
||||
#![allow(unused_variables)]
|
||||
#![warn(unused_parens)]
|
||||
|
||||
fn main() {
|
||||
match 1 {
|
||||
(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
(y) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
(ref r) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
(e @ 1...2) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||
(1...2) => {} // Non ambiguous range pattern should not warn
|
||||
e @ (3...4) => {} // Non ambiguous range pattern should not warn
|
||||
}
|
||||
|
||||
match &1 {
|
||||
(e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||
&(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
e @ &(1...2) => {} // Ambiguous range pattern should not warn
|
||||
&(1...2) => {} // Ambiguous range pattern should not warn
|
||||
}
|
||||
|
||||
match &1 {
|
||||
e @ &(1...2) | e @ &(3...4) => {} // Complex ambiguous pattern should not warn
|
||||
&_ => {}
|
||||
}
|
||||
|
||||
match 1 {
|
||||
(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
(y) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
@ -15,14 +37,14 @@ fn main() {
|
||||
}
|
||||
|
||||
match &1 {
|
||||
(e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||
(e @ &(1..=2)) => {} //~ WARNING: unnecessary parentheses around outer pattern
|
||||
&(_) => {} //~ WARNING: unnecessary parentheses around pattern
|
||||
e @ &(1...2) => {} // Ambiguous range pattern should not warn
|
||||
e @ &(1..=2) => {} // Ambiguous range pattern should not warn
|
||||
&(1..=2) => {} // Ambiguous range pattern should not warn
|
||||
}
|
||||
|
||||
match &1 {
|
||||
e @ &(1...2) | e @ &(3..=4) => {} // Complex ambiguous pattern should not warn
|
||||
e @ &(1..=2) | e @ &(3..=4) => {} // Complex ambiguous pattern should not warn
|
||||
&_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,77 @@
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:9:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:10:9
|
||||
|
|
||||
LL | (_) => {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:5:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:6:9
|
||||
|
|
||||
LL | #![warn(unused_parens)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:10:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:11:9
|
||||
|
|
||||
LL | (y) => {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:11:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:12:9
|
||||
|
|
||||
LL | (ref r) => {}
|
||||
| ^^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:12:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:13:9
|
||||
|
|
||||
LL | (e @ 1..=2) => {}
|
||||
LL | (e @ 1...2) => {}
|
||||
| ^^^^^^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:18:9
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:19:9
|
||||
|
|
||||
LL | (e @ &(1...2)) => {}
|
||||
| ^^^^^^^^^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:19:10
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:20:10
|
||||
|
|
||||
LL | &(_) => {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:31:9
|
||||
|
|
||||
LL | (_) => {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:32:9
|
||||
|
|
||||
LL | (y) => {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:33:9
|
||||
|
|
||||
LL | (ref r) => {}
|
||||
| ^^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:34:9
|
||||
|
|
||||
LL | (e @ 1..=2) => {}
|
||||
| ^^^^^^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:40:9
|
||||
|
|
||||
LL | (e @ &(1..=2)) => {}
|
||||
| ^^^^^^^^^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: unnecessary parentheses around pattern
|
||||
--> $DIR/issue-54538-unused-parens-lint.rs:41:10
|
||||
|
|
||||
LL | &(_) => {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
@ -8,31 +8,31 @@
|
||||
|
||||
fn main() {
|
||||
match 5 {
|
||||
1 ... 10 => { }
|
||||
5 ... 6 => { }
|
||||
1 ..= 10 => { }
|
||||
5 ..= 6 => { }
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match 5 {
|
||||
3 ... 6 => { }
|
||||
4 ... 6 => { }
|
||||
3 ..= 6 => { }
|
||||
4 ..= 6 => { }
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match 5 {
|
||||
4 ... 6 => { }
|
||||
4 ... 6 => { }
|
||||
4 ..= 6 => { }
|
||||
4 ..= 6 => { }
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match 'c' {
|
||||
'A' ... 'z' => {}
|
||||
'a' ... 'z' => {}
|
||||
'A' ..= 'z' => {}
|
||||
'a' ..= 'z' => {}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match 1.0f64 {
|
||||
0.01f64 ... 6.5f64 => {}
|
||||
0.01f64 ..= 6.5f64 => {}
|
||||
0.02f64 => {}
|
||||
_ => {}
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-range-fail-dominate.rs:12:7
|
||||
|
|
||||
LL | 5 ... 6 => { }
|
||||
LL | 5 ..= 6 => { }
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,25 +13,25 @@ LL | #![deny(unreachable_patterns)]
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-range-fail-dominate.rs:18:7
|
||||
|
|
||||
LL | 4 ... 6 => { }
|
||||
LL | 4 ..= 6 => { }
|
||||
| ^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-range-fail-dominate.rs:24:7
|
||||
|
|
||||
LL | 4 ... 6 => { }
|
||||
LL | 4 ..= 6 => { }
|
||||
| ^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/match-range-fail-dominate.rs:30:7
|
||||
|
|
||||
LL | 'a' ... 'z' => {}
|
||||
LL | 'a' ..= 'z' => {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
warning: floating-point types cannot be used in patterns
|
||||
--> $DIR/match-range-fail-dominate.rs:35:7
|
||||
|
|
||||
LL | 0.01f64 ... 6.5f64 => {}
|
||||
LL | 0.01f64 ..= 6.5f64 => {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: #[warn(illegal_floating_point_literal_pattern)] on by default
|
||||
@ -41,7 +41,7 @@ LL | 0.01f64 ... 6.5f64 => {}
|
||||
warning: floating-point types cannot be used in patterns
|
||||
--> $DIR/match-range-fail-dominate.rs:35:19
|
||||
|
|
||||
LL | 0.01f64 ... 6.5f64 => {}
|
||||
LL | 0.01f64 ..= 6.5f64 => {}
|
||||
| ^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
@ -65,7 +65,7 @@ LL | 0.02f64 => {}
|
||||
warning: floating-point types cannot be used in patterns
|
||||
--> $DIR/match-range-fail-dominate.rs:35:7
|
||||
|
|
||||
LL | 0.01f64 ... 6.5f64 => {}
|
||||
LL | 0.01f64 ..= 6.5f64 => {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
@ -27,9 +27,9 @@ impl Range for ThreeDigits {
|
||||
|
||||
fn digits(x: u8) -> u32 {
|
||||
match x {
|
||||
OneDigit::FIRST...OneDigit::LAST => 1,
|
||||
TwoDigits::FIRST...TwoDigits::LAST => 2,
|
||||
ThreeDigits::FIRST...ThreeDigits::LAST => 3,
|
||||
OneDigit::FIRST..=OneDigit::LAST => 1,
|
||||
TwoDigits::FIRST..=TwoDigits::LAST => 2,
|
||||
ThreeDigits::FIRST..=ThreeDigits::LAST => 3,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user