Skip to content

Commit 883932c

Browse files
committedJan 11, 2020
Ban ...X pats, harden tests, and improve diagnostics.
Also fix a bug with the span passed in `mk_range`.
·
1.88.01.42.0
1 parent e621797 commit 883932c

19 files changed

+260
-121
lines changed
 

‎src/librustc_parse/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,7 @@ impl<'a> Parser<'a> {
19661966
limits: RangeLimits,
19671967
) -> PResult<'a, ExprKind> {
19681968
if end.is_none() && limits == RangeLimits::Closed {
1969-
self.error_inclusive_range_with_no_end(self.token.span);
1969+
self.error_inclusive_range_with_no_end(self.prev_span);
19701970
Ok(ExprKind::Err)
19711971
} else {
19721972
Ok(ExprKind::Range(start, end, limits))

‎src/librustc_parse/parser/pat.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,14 +661,34 @@ impl<'a> Parser<'a> {
661661
pub(super) fn error_inclusive_range_with_no_end(&self, span: Span) {
662662
use rustc_error_codes::E0586;
663663
struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end")
664-
.help("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
664+
.span_suggestion_short(
665+
span,
666+
"use `..` instead",
667+
"..".to_string(),
668+
Applicability::MachineApplicable,
669+
)
670+
.note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
665671
.emit();
666672
}
667673

668-
/// Parse a range-to pattern, e.g. `..X` and `..=X` where `X` remains to be parsed.
669-
fn parse_pat_range_to(&mut self, re: Spanned<RangeEnd>) -> PResult<'a, PatKind> {
674+
/// Parse a range-to pattern, `..X` or `..=X` where `X` remains to be parsed.
675+
///
676+
/// The form `...X` is prohibited to reduce confusion with the potential
677+
/// expression syntax `...expr` for splatting in expressions.
678+
fn parse_pat_range_to(&mut self, mut re: Spanned<RangeEnd>) -> PResult<'a, PatKind> {
670679
let end = self.parse_pat_range_end()?;
671680
self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_span));
681+
if let RangeEnd::Included(ref mut syn @ RangeSyntax::DotDotDot) = &mut re.node {
682+
*syn = RangeSyntax::DotDotEq;
683+
self.struct_span_err(re.span, "range-to patterns with `...` are not allowed")
684+
.span_suggestion_short(
685+
re.span,
686+
"use `..=` instead",
687+
"..=".to_string(),
688+
Applicability::MachineApplicable,
689+
)
690+
.emit();
691+
}
672692
Ok(PatKind::Range(None, Some(end), re))
673693
}
674694

‎src/test/ui/error-codes/E0586.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0586]: inclusive range with no end
2-
--> $DIR/E0586.rs:3:22
2+
--> $DIR/E0586.rs:3:19
33
|
44
LL | let x = &tmp[1..=];
5-
| ^
5+
| ^^^ help: use `..` instead
66
|
7-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
7+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
88

99
error: aborting due to previous error
1010

‎src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn foo() {
88
//~^ ERROR half-open range patterns are unstable
99
if let ...5 = 0 {}
1010
//~^ ERROR half-open range patterns are unstable
11+
//~| ERROR range-to patterns with `...` are not allowed
1112
if let ..5 = 0 {}
1213
//~^ ERROR half-open range patterns are unstable
1314
if let 5.. = 0 {}

‎src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
error: range-to patterns with `...` are not allowed
2+
--> $DIR/feature-gate-half-open-range-patterns.rs:9:12
3+
|
4+
LL | if let ...5 = 0 {}
5+
| ^^^ help: use `..=` instead
6+
17
error[E0586]: inclusive range with no end
2-
--> $DIR/feature-gate-half-open-range-patterns.rs:15:13
8+
--> $DIR/feature-gate-half-open-range-patterns.rs:16:13
39
|
410
LL | if let 5..= = 0 {}
5-
| ^^^
11+
| ^^^ help: use `..` instead
612
|
7-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
13+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
814

915
error[E0586]: inclusive range with no end
10-
--> $DIR/feature-gate-half-open-range-patterns.rs:18:13
16+
--> $DIR/feature-gate-half-open-range-patterns.rs:19:13
1117
|
1218
LL | if let 5... = 0 {}
13-
| ^^^
19+
| ^^^ help: use `..` instead
1420
|
15-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
21+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
1622

1723
error[E0658]: half-open range patterns are unstable
1824
--> $DIR/feature-gate-half-open-range-patterns.rs:7:12
@@ -33,7 +39,7 @@ LL | if let ...5 = 0 {}
3339
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
3440

3541
error[E0658]: half-open range patterns are unstable
36-
--> $DIR/feature-gate-half-open-range-patterns.rs:11:12
42+
--> $DIR/feature-gate-half-open-range-patterns.rs:12:12
3743
|
3844
LL | if let ..5 = 0 {}
3945
| ^^^
@@ -42,7 +48,7 @@ LL | if let ..5 = 0 {}
4248
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
4349

4450
error[E0658]: half-open range patterns are unstable
45-
--> $DIR/feature-gate-half-open-range-patterns.rs:13:12
51+
--> $DIR/feature-gate-half-open-range-patterns.rs:14:12
4652
|
4753
LL | if let 5.. = 0 {}
4854
| ^^^
@@ -51,7 +57,7 @@ LL | if let 5.. = 0 {}
5157
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
5258

5359
error[E0658]: half-open range patterns are unstable
54-
--> $DIR/feature-gate-half-open-range-patterns.rs:15:12
60+
--> $DIR/feature-gate-half-open-range-patterns.rs:16:12
5561
|
5662
LL | if let 5..= = 0 {}
5763
| ^^^^
@@ -60,15 +66,15 @@ LL | if let 5..= = 0 {}
6066
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
6167

6268
error[E0658]: half-open range patterns are unstable
63-
--> $DIR/feature-gate-half-open-range-patterns.rs:18:12
69+
--> $DIR/feature-gate-half-open-range-patterns.rs:19:12
6470
|
6571
LL | if let 5... = 0 {}
6672
| ^^^^
6773
|
6874
= note: for more information, see https://github.com/rust-lang/rust/issues/67264
6975
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
7076

71-
error: aborting due to 8 previous errors
77+
error: aborting due to 9 previous errors
7278

7379
Some errors have detailed explanations: E0586, E0658.
7480
For more information about an error, try `rustc --explain E0586`.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Test that `...X` range-to patterns are syntactically invalid.
2+
//
3+
// See https://github.com/rust-lang/rust/pull/67258#issuecomment-565656155
4+
// for the reason why. To summarize, we might want to introduce `...expr` as
5+
// an expression form for splatting (or "untupling") in an expression context.
6+
// While there is no syntactic ambiguity with `...X` in a pattern context,
7+
// there's a potential confusion factor here, and we would prefer to keep patterns
8+
// and expressions in-sync. As such, we do not allow `...X` in patterns either.
9+
10+
#![feature(half_open_range_patterns)]
11+
12+
fn main() {}
13+
14+
#[cfg(FALSE)]
15+
fn syntax() {
16+
match scrutinee {
17+
...X => {} //~ ERROR range-to patterns with `...` are not allowed
18+
...0 => {} //~ ERROR range-to patterns with `...` are not allowed
19+
...'a' => {} //~ ERROR range-to patterns with `...` are not allowed
20+
...0.0f32 => {} //~ ERROR range-to patterns with `...` are not allowed
21+
}
22+
}
23+
24+
fn syntax2() {
25+
macro_rules! mac {
26+
($e:expr) => {
27+
let ...$e; //~ ERROR range-to patterns with `...` are not allowed
28+
}
29+
}
30+
31+
mac!(0);
32+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error: range-to patterns with `...` are not allowed
2+
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:17:9
3+
|
4+
LL | ...X => {}
5+
| ^^^ help: use `..=` instead
6+
7+
error: range-to patterns with `...` are not allowed
8+
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:18:9
9+
|
10+
LL | ...0 => {}
11+
| ^^^ help: use `..=` instead
12+
13+
error: range-to patterns with `...` are not allowed
14+
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:19:9
15+
|
16+
LL | ...'a' => {}
17+
| ^^^ help: use `..=` instead
18+
19+
error: range-to patterns with `...` are not allowed
20+
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:20:9
21+
|
22+
LL | ...0.0f32 => {}
23+
| ^^^ help: use `..=` instead
24+
25+
error: range-to patterns with `...` are not allowed
26+
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:27:17
27+
|
28+
LL | let ...$e;
29+
| ^^^ help: use `..=` instead
30+
...
31+
LL | mac!(0);
32+
| -------- in this macro invocation
33+
34+
error: aborting due to 5 previous errors
35+

‎src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,14 @@ fn foo() {
1313
if let X... = 1 {} //~ ERROR inclusive range with no end
1414
if let X..= = 1 {} //~ ERROR inclusive range with no end
1515
}
16+
17+
fn bar() {
18+
macro_rules! mac {
19+
($e:expr) => {
20+
let $e...; //~ ERROR inclusive range with no end
21+
let $e..=; //~ ERROR inclusive range with no end
22+
}
23+
}
24+
25+
mac!(0);
26+
}

‎src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,56 @@ error[E0586]: inclusive range with no end
22
--> $DIR/half-open-range-pats-inclusive-no-end.rs:10:13
33
|
44
LL | if let 0... = 1 {}
5-
| ^^^
5+
| ^^^ help: use `..` instead
66
|
7-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
7+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
88

99
error[E0586]: inclusive range with no end
1010
--> $DIR/half-open-range-pats-inclusive-no-end.rs:11:13
1111
|
1212
LL | if let 0..= = 1 {}
13-
| ^^^
13+
| ^^^ help: use `..` instead
1414
|
15-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
15+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
1616

1717
error[E0586]: inclusive range with no end
1818
--> $DIR/half-open-range-pats-inclusive-no-end.rs:13:13
1919
|
2020
LL | if let X... = 1 {}
21-
| ^^^
21+
| ^^^ help: use `..` instead
2222
|
23-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
23+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
2424

2525
error[E0586]: inclusive range with no end
2626
--> $DIR/half-open-range-pats-inclusive-no-end.rs:14:13
2727
|
2828
LL | if let X..= = 1 {}
29-
| ^^^
29+
| ^^^ help: use `..` instead
3030
|
31-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
31+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
3232

33-
error: aborting due to 4 previous errors
33+
error[E0586]: inclusive range with no end
34+
--> $DIR/half-open-range-pats-inclusive-no-end.rs:20:19
35+
|
36+
LL | let $e...;
37+
| ^^^ help: use `..` instead
38+
...
39+
LL | mac!(0);
40+
| -------- in this macro invocation
41+
|
42+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
43+
44+
error[E0586]: inclusive range with no end
45+
--> $DIR/half-open-range-pats-inclusive-no-end.rs:21:19
46+
|
47+
LL | let $e..=;
48+
| ^^^ help: use `..` instead
49+
...
50+
LL | mac!(0);
51+
| -------- in this macro invocation
52+
|
53+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
54+
55+
error: aborting due to 6 previous errors
3456

3557
For more information about this error, try `rustc --explain E0586`.

‎src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ fn syntax() {
2020
&..=0 | _ => {}
2121
//~^ ERROR the range pattern here has ambiguous interpretation
2222
&...0 | _ => {}
23+
//~^ ERROR the range pattern here has ambiguous interpretation
24+
//~| ERROR range-to patterns with `...` are not allowed
2325
}
2426
}

‎src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.stderr

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ error[E0586]: inclusive range with no end
88
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:11
99
|
1010
LL | &0..= | _ => {}
11-
| ^^^
11+
| ^^^ help: use `..` instead
1212
|
13-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
13+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
1414

1515
error: the range pattern here has ambiguous interpretation
1616
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:10
@@ -22,9 +22,9 @@ error[E0586]: inclusive range with no end
2222
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:13:11
2323
|
2424
LL | &0... | _ => {}
25-
| ^^^
25+
| ^^^ help: use `..` instead
2626
|
27-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
27+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
2828

2929
error: the range pattern here has ambiguous interpretation
3030
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:18:10
@@ -38,6 +38,18 @@ error: the range pattern here has ambiguous interpretation
3838
LL | &..=0 | _ => {}
3939
| ^^^^ help: add parentheses to clarify the precedence: `(..=0)`
4040

41-
error: aborting due to 6 previous errors
41+
error: range-to patterns with `...` are not allowed
42+
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:22:10
43+
|
44+
LL | &...0 | _ => {}
45+
| ^^^ help: use `..=` instead
46+
47+
error: the range pattern here has ambiguous interpretation
48+
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:22:10
49+
|
50+
LL | &...0 | _ => {}
51+
| ^^^^ help: add parentheses to clarify the precedence: `(..=0)`
52+
53+
error: aborting due to 8 previous errors
4254

4355
For more information about this error, try `rustc --explain E0586`.

‎src/test/ui/half-open-range-patterns/half-open-range-pats-syntactic-pass.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,20 @@ fn main() {}
1111
fn syntax() {
1212
match scrutinee {
1313
X.. | 0.. | 'a'.. | 0.0f32.. => {}
14-
..=X | ...X | ..X => {}
15-
..=0 | ...0 | ..0 => {}
16-
..='a' | ...'a' | ..'a' => {}
17-
..=0.0f32 | ...0.0f32 | ..0.0f32 => {}
14+
..=X | ..X => {}
15+
..=0 | ..0 => {}
16+
..='a' | ..'a' => {}
17+
..=0.0f32 | ..0.0f32 => {}
1818
}
19+
}
1920

21+
fn syntax2() {
2022
macro_rules! mac {
2123
($e:expr) => {
22-
let ..$e;
23-
let ...$e;
24-
let ..=$e;
25-
let $e..;
26-
let $e...;
27-
let $e..=;
24+
match 0u8 { ..$e => {}, _ => {} }
25+
match 0u8 { ..=$e => {}, _ => {} }
26+
match 0u8 { $e.. => {}, _ => {} }
2827
}
2928
}
30-
31-
mac!(0);
29+
mac!(42u8);
3230
}

‎src/test/ui/impossible_range.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
// Make sure that invalid ranges generate an error during HIR lowering, not an ICE
1+
// Make sure that invalid ranges generate an error during parsing, not an ICE
22

33
pub fn main() {
44
..;
55
0..;
66
..1;
77
0..1;
88
..=; //~ERROR inclusive range with no end
9-
//~^HELP bounded at the end
9+
//~^HELP use `..` instead
1010
}
1111

1212
fn _foo1() {
1313
..=1;
1414
0..=1;
1515
0..=; //~ERROR inclusive range with no end
16-
//~^HELP bounded at the end
16+
//~^HELP use `..` instead
1717
}

‎src/test/ui/impossible_range.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
error[E0586]: inclusive range with no end
2-
--> $DIR/impossible_range.rs:8:8
2+
--> $DIR/impossible_range.rs:8:5
33
|
44
LL | ..=;
5-
| ^
5+
| ^^^ help: use `..` instead
66
|
7-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
7+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
88

99
error[E0586]: inclusive range with no end
10-
--> $DIR/impossible_range.rs:15:9
10+
--> $DIR/impossible_range.rs:15:6
1111
|
1212
LL | 0..=;
13-
| ^
13+
| ^^^ help: use `..` instead
1414
|
15-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
15+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
1616

1717
error: aborting due to 2 previous errors
1818

‎src/test/ui/parser/attr-stmt-expr-attr-bad.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ error[E0586]: inclusive range with no end
342342
--> $DIR/attr-stmt-expr-attr-bad.rs:94:35
343343
|
344344
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
345-
| ^^^
345+
| ^^^ help: use `..` instead
346346
|
347-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
347+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
348348

349349
error: expected one of `=>`, `if`, or `|`, found `#`
350350
--> $DIR/attr-stmt-expr-attr-bad.rs:94:38
@@ -356,9 +356,9 @@ error[E0586]: inclusive range with no end
356356
--> $DIR/attr-stmt-expr-attr-bad.rs:97:35
357357
|
358358
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
359-
| ^^^
359+
| ^^^ help: use `..` instead
360360
|
361-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
361+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
362362

363363
error: expected one of `=>`, `if`, or `|`, found `#`
364364
--> $DIR/attr-stmt-expr-attr-bad.rs:97:38
@@ -376,9 +376,9 @@ error[E0586]: inclusive range with no end
376376
--> $DIR/attr-stmt-expr-attr-bad.rs:102:35
377377
|
378378
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
379-
| ^^^
379+
| ^^^ help: use `..` instead
380380
|
381-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
381+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
382382

383383
error: expected one of `=>`, `if`, or `|`, found `#`
384384
--> $DIR/attr-stmt-expr-attr-bad.rs:102:38

‎src/test/ui/parser/range_inclusive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
pub fn main() {
44
for _ in 1..= {} //~ERROR inclusive range with no end
5-
//~^HELP bounded at the end
5+
//~^HELP use `..` instead
66
}

‎src/test/ui/parser/range_inclusive.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0586]: inclusive range with no end
2-
--> $DIR/range_inclusive.rs:4:19
2+
--> $DIR/range_inclusive.rs:4:15
33
|
44
LL | for _ in 1..= {}
5-
| ^
5+
| ^^^ help: use `..` instead
66
|
7-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
7+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
88

99
error: aborting due to previous error
1010

‎src/test/ui/parser/recover-range-pats.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ fn inclusive_to() {
107107

108108
fn inclusive2_to() {
109109
if let ...3 = 0 {}
110-
//~^ ERROR `...` range patterns are deprecated
110+
//~^ ERROR range-to patterns with `...` are not allowed
111111
if let ...Y = 0 {}
112-
//~^ ERROR `...` range patterns are deprecated
112+
//~^ ERROR range-to patterns with `...` are not allowed
113113
if let ...true = 0 {}
114-
//~^ ERROR `...` range patterns are deprecated
114+
//~^ ERROR range-to patterns with `...` are not allowed
115115
//~| ERROR only char and numeric types
116116
if let ....3 = 0 {}
117117
//~^ ERROR float literals must have an integer part
118-
//~| ERROR `...` range patterns are deprecated
118+
//~| ERROR range-to patterns with `...` are not allowed
119119
//~| ERROR mismatched types
120120
}
121121

@@ -135,7 +135,7 @@ fn with_macro_expr_var() {
135135
($e:expr) => {
136136
let ..$e;
137137
let ...$e;
138-
//~^ ERROR `...` range patterns are deprecated
138+
//~^ ERROR range-to patterns with `...` are not allowed
139139
let ..=$e;
140140
let $e..;
141141
let $e...; //~ ERROR inclusive range with no end

‎src/test/ui/parser/recover-range-pats.stderr

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ error[E0586]: inclusive range with no end
4444
--> $DIR/recover-range-pats.rs:69:13
4545
|
4646
LL | if let 0..= = 0 {}
47-
| ^^^
47+
| ^^^ help: use `..` instead
4848
|
49-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
49+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
5050

5151
error[E0586]: inclusive range with no end
5252
--> $DIR/recover-range-pats.rs:70:13
5353
|
5454
LL | if let X..= = 0 {}
55-
| ^^^
55+
| ^^^ help: use `..` instead
5656
|
57-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
57+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
5858

5959
error[E0586]: inclusive range with no end
6060
--> $DIR/recover-range-pats.rs:71:16
6161
|
6262
LL | if let true..= = 0 {}
63-
| ^^^
63+
| ^^^ help: use `..` instead
6464
|
65-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
65+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
6666

6767
error: float literals must have an integer part
6868
--> $DIR/recover-range-pats.rs:73:12
@@ -74,33 +74,33 @@ error[E0586]: inclusive range with no end
7474
--> $DIR/recover-range-pats.rs:73:14
7575
|
7676
LL | if let .0..= = 0 {}
77-
| ^^^
77+
| ^^^ help: use `..` instead
7878
|
79-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
79+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
8080

8181
error[E0586]: inclusive range with no end
8282
--> $DIR/recover-range-pats.rs:79:13
8383
|
8484
LL | if let 0... = 0 {}
85-
| ^^^
85+
| ^^^ help: use `..` instead
8686
|
87-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
87+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
8888

8989
error[E0586]: inclusive range with no end
9090
--> $DIR/recover-range-pats.rs:80:13
9191
|
9292
LL | if let X... = 0 {}
93-
| ^^^
93+
| ^^^ help: use `..` instead
9494
|
95-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
95+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
9696

9797
error[E0586]: inclusive range with no end
9898
--> $DIR/recover-range-pats.rs:81:16
9999
|
100100
LL | if let true... = 0 {}
101-
| ^^^
101+
| ^^^ help: use `..` instead
102102
|
103-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
103+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
104104

105105
error: float literals must have an integer part
106106
--> $DIR/recover-range-pats.rs:83:12
@@ -112,9 +112,9 @@ error[E0586]: inclusive range with no end
112112
--> $DIR/recover-range-pats.rs:83:14
113113
|
114114
LL | if let .0... = 0 {}
115-
| ^^^
115+
| ^^^ help: use `..` instead
116116
|
117-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
117+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
118118

119119
error: float literals must have an integer part
120120
--> $DIR/recover-range-pats.rs:93:15
@@ -128,33 +128,66 @@ error: float literals must have an integer part
128128
LL | if let ..=.0 = 0 {}
129129
| ^^ help: must have an integer part: `0.0`
130130

131+
error: range-to patterns with `...` are not allowed
132+
--> $DIR/recover-range-pats.rs:109:12
133+
|
134+
LL | if let ...3 = 0 {}
135+
| ^^^ help: use `..=` instead
136+
137+
error: range-to patterns with `...` are not allowed
138+
--> $DIR/recover-range-pats.rs:111:12
139+
|
140+
LL | if let ...Y = 0 {}
141+
| ^^^ help: use `..=` instead
142+
143+
error: range-to patterns with `...` are not allowed
144+
--> $DIR/recover-range-pats.rs:113:12
145+
|
146+
LL | if let ...true = 0 {}
147+
| ^^^ help: use `..=` instead
148+
131149
error: float literals must have an integer part
132150
--> $DIR/recover-range-pats.rs:116:15
133151
|
134152
LL | if let ....3 = 0 {}
135153
| ^^ help: must have an integer part: `0.3`
136154

155+
error: range-to patterns with `...` are not allowed
156+
--> $DIR/recover-range-pats.rs:116:12
157+
|
158+
LL | if let ....3 = 0 {}
159+
| ^^^ help: use `..=` instead
160+
161+
error: range-to patterns with `...` are not allowed
162+
--> $DIR/recover-range-pats.rs:137:17
163+
|
164+
LL | let ...$e;
165+
| ^^^ help: use `..=` instead
166+
...
167+
LL | mac!(0);
168+
| -------- in this macro invocation
169+
137170
error[E0586]: inclusive range with no end
138171
--> $DIR/recover-range-pats.rs:141:19
139172
|
140173
LL | let $e...;
141-
| ^^^
174+
| ^^^ help: use `..` instead
142175
...
143176
LL | mac!(0);
144177
| -------- in this macro invocation
145178
|
146-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
179+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
147180

148181
error[E0586]: inclusive range with no end
149182
--> $DIR/recover-range-pats.rs:142:19
150183
|
151184
LL | let $e..=;
152-
| ^^^
185+
| ^^^ help: use `..` instead
153186
...
154187
LL | mac!(0);
155188
| -------- in this macro invocation
156189
|
157-
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
190+
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
158191

159192
error: `...` range patterns are deprecated
160193
--> $DIR/recover-range-pats.rs:42:13
@@ -210,30 +243,6 @@ error: `...` range patterns are deprecated
210243
LL | if let X... .0 = 0 {}
211244
| ^^^ help: use `..=` for an inclusive range
212245

213-
error: `...` range patterns are deprecated
214-
--> $DIR/recover-range-pats.rs:109:12
215-
|
216-
LL | if let ...3 = 0 {}
217-
| ^^^ help: use `..=` for an inclusive range
218-
219-
error: `...` range patterns are deprecated
220-
--> $DIR/recover-range-pats.rs:111:12
221-
|
222-
LL | if let ...Y = 0 {}
223-
| ^^^ help: use `..=` for an inclusive range
224-
225-
error: `...` range patterns are deprecated
226-
--> $DIR/recover-range-pats.rs:113:12
227-
|
228-
LL | if let ...true = 0 {}
229-
| ^^^ help: use `..=` for an inclusive range
230-
231-
error: `...` range patterns are deprecated
232-
--> $DIR/recover-range-pats.rs:116:12
233-
|
234-
LL | if let ....3 = 0 {}
235-
| ^^^ help: use `..=` for an inclusive range
236-
237246
error: `...` range patterns are deprecated
238247
--> $DIR/recover-range-pats.rs:126:20
239248
|
@@ -243,15 +252,6 @@ LL | let $e1...$e2;
243252
LL | mac2!(0, 1);
244253
| ------------ in this macro invocation
245254

246-
error: `...` range patterns are deprecated
247-
--> $DIR/recover-range-pats.rs:137:17
248-
|
249-
LL | let ...$e;
250-
| ^^^ help: use `..=` for an inclusive range
251-
...
252-
LL | mac!(0);
253-
| -------- in this macro invocation
254-
255255
error[E0029]: only char and numeric types are allowed in range patterns
256256
--> $DIR/recover-range-pats.rs:20:12
257257
|

0 commit comments

Comments
 (0)
Please sign in to comment.