diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 2d6a94ce620cf..bdb55a713f1dc 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -1966,7 +1966,7 @@ impl<'a> Parser<'a> { limits: RangeLimits, ) -> PResult<'a, ExprKind> { if end.is_none() && limits == RangeLimits::Closed { - self.error_inclusive_range_with_no_end(self.token.span); + self.error_inclusive_range_with_no_end(self.prev_span); Ok(ExprKind::Err) } else { Ok(ExprKind::Range(start, end, limits)) diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index 50756ddec9f2d..0c2cfc20daf0f 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -661,14 +661,34 @@ impl<'a> Parser<'a> { pub(super) fn error_inclusive_range_with_no_end(&self, span: Span) { use rustc_error_codes::E0586; struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end") - .help("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)") + .span_suggestion_short( + span, + "use `..` instead", + "..".to_string(), + Applicability::MachineApplicable, + ) + .note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)") .emit(); } - /// Parse a range-to pattern, e.g. `..X` and `..=X` where `X` remains to be parsed. - fn parse_pat_range_to(&mut self, re: Spanned) -> PResult<'a, PatKind> { + /// Parse a range-to pattern, `..X` or `..=X` where `X` remains to be parsed. + /// + /// The form `...X` is prohibited to reduce confusion with the potential + /// expression syntax `...expr` for splatting in expressions. + fn parse_pat_range_to(&mut self, mut re: Spanned) -> PResult<'a, PatKind> { let end = self.parse_pat_range_end()?; self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_span)); + if let RangeEnd::Included(ref mut syn @ RangeSyntax::DotDotDot) = &mut re.node { + *syn = RangeSyntax::DotDotEq; + self.struct_span_err(re.span, "range-to patterns with `...` are not allowed") + .span_suggestion_short( + re.span, + "use `..=` instead", + "..=".to_string(), + Applicability::MachineApplicable, + ) + .emit(); + } Ok(PatKind::Range(None, Some(end), re)) } diff --git a/src/test/ui/error-codes/E0586.stderr b/src/test/ui/error-codes/E0586.stderr index d1e7e3f47442f..0bbf9a6080349 100644 --- a/src/test/ui/error-codes/E0586.stderr +++ b/src/test/ui/error-codes/E0586.stderr @@ -1,10 +1,10 @@ error[E0586]: inclusive range with no end - --> $DIR/E0586.rs:3:22 + --> $DIR/E0586.rs:3:19 | LL | let x = &tmp[1..=]; - | ^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: aborting due to previous error diff --git a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs index 4cb8230a7b620..1733012b9c54f 100644 --- a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs +++ b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs @@ -8,6 +8,7 @@ fn foo() { //~^ ERROR half-open range patterns are unstable if let ...5 = 0 {} //~^ ERROR half-open range patterns are unstable + //~| ERROR range-to patterns with `...` are not allowed if let ..5 = 0 {} //~^ ERROR half-open range patterns are unstable if let 5.. = 0 {} diff --git a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr index 68ba654de76da..99db339cf74e1 100644 --- a/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr +++ b/src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr @@ -1,18 +1,24 @@ +error: range-to patterns with `...` are not allowed + --> $DIR/feature-gate-half-open-range-patterns.rs:9:12 + | +LL | if let ...5 = 0 {} + | ^^^ help: use `..=` instead + error[E0586]: inclusive range with no end - --> $DIR/feature-gate-half-open-range-patterns.rs:15:13 + --> $DIR/feature-gate-half-open-range-patterns.rs:16:13 | LL | if let 5..= = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end - --> $DIR/feature-gate-half-open-range-patterns.rs:18:13 + --> $DIR/feature-gate-half-open-range-patterns.rs:19:13 | LL | if let 5... = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0658]: half-open range patterns are unstable --> $DIR/feature-gate-half-open-range-patterns.rs:7:12 @@ -33,7 +39,7 @@ LL | if let ...5 = 0 {} = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable error[E0658]: half-open range patterns are unstable - --> $DIR/feature-gate-half-open-range-patterns.rs:11:12 + --> $DIR/feature-gate-half-open-range-patterns.rs:12:12 | LL | if let ..5 = 0 {} | ^^^ @@ -42,7 +48,7 @@ LL | if let ..5 = 0 {} = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable error[E0658]: half-open range patterns are unstable - --> $DIR/feature-gate-half-open-range-patterns.rs:13:12 + --> $DIR/feature-gate-half-open-range-patterns.rs:14:12 | LL | if let 5.. = 0 {} | ^^^ @@ -51,7 +57,7 @@ LL | if let 5.. = 0 {} = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable error[E0658]: half-open range patterns are unstable - --> $DIR/feature-gate-half-open-range-patterns.rs:15:12 + --> $DIR/feature-gate-half-open-range-patterns.rs:16:12 | LL | if let 5..= = 0 {} | ^^^^ @@ -60,7 +66,7 @@ LL | if let 5..= = 0 {} = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable error[E0658]: half-open range patterns are unstable - --> $DIR/feature-gate-half-open-range-patterns.rs:18:12 + --> $DIR/feature-gate-half-open-range-patterns.rs:19:12 | LL | if let 5... = 0 {} | ^^^^ @@ -68,7 +74,7 @@ LL | if let 5... = 0 {} = note: for more information, see https://github.com/rust-lang/rust/issues/67264 = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors Some errors have detailed explanations: E0586, E0658. For more information about an error, try `rustc --explain E0586`. diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs new file mode 100644 index 0000000000000..daed775cf7c01 --- /dev/null +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs @@ -0,0 +1,32 @@ +// Test that `...X` range-to patterns are syntactically invalid. +// +// See https://github.com/rust-lang/rust/pull/67258#issuecomment-565656155 +// for the reason why. To summarize, we might want to introduce `...expr` as +// an expression form for splatting (or "untupling") in an expression context. +// While there is no syntactic ambiguity with `...X` in a pattern context, +// there's a potential confusion factor here, and we would prefer to keep patterns +// and expressions in-sync. As such, we do not allow `...X` in patterns either. + +#![feature(half_open_range_patterns)] + +fn main() {} + +#[cfg(FALSE)] +fn syntax() { + match scrutinee { + ...X => {} //~ ERROR range-to patterns with `...` are not allowed + ...0 => {} //~ ERROR range-to patterns with `...` are not allowed + ...'a' => {} //~ ERROR range-to patterns with `...` are not allowed + ...0.0f32 => {} //~ ERROR range-to patterns with `...` are not allowed + } +} + +fn syntax2() { + macro_rules! mac { + ($e:expr) => { + let ...$e; //~ ERROR range-to patterns with `...` are not allowed + } + } + + mac!(0); +} diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr new file mode 100644 index 0000000000000..ba2e7ea8b5354 --- /dev/null +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr @@ -0,0 +1,35 @@ +error: range-to patterns with `...` are not allowed + --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:17:9 + | +LL | ...X => {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:18:9 + | +LL | ...0 => {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:19:9 + | +LL | ...'a' => {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:20:9 + | +LL | ...0.0f32 => {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:27:17 + | +LL | let ...$e; + | ^^^ help: use `..=` instead +... +LL | mac!(0); + | -------- in this macro invocation + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs index 03166e3675571..9ace0c357b2d4 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.rs @@ -13,3 +13,14 @@ fn foo() { if let X... = 1 {} //~ ERROR inclusive range with no end if let X..= = 1 {} //~ ERROR inclusive range with no end } + +fn bar() { + macro_rules! mac { + ($e:expr) => { + let $e...; //~ ERROR inclusive range with no end + let $e..=; //~ ERROR inclusive range with no end + } + } + + mac!(0); +} diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr index 2b4d95f684284..2bdb8ea57668a 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr @@ -2,34 +2,56 @@ error[E0586]: inclusive range with no end --> $DIR/half-open-range-pats-inclusive-no-end.rs:10:13 | LL | if let 0... = 1 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/half-open-range-pats-inclusive-no-end.rs:11:13 | LL | if let 0..= = 1 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/half-open-range-pats-inclusive-no-end.rs:13:13 | LL | if let X... = 1 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/half-open-range-pats-inclusive-no-end.rs:14:13 | LL | if let X..= = 1 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) -error: aborting due to 4 previous errors +error[E0586]: inclusive range with no end + --> $DIR/half-open-range-pats-inclusive-no-end.rs:20:19 + | +LL | let $e...; + | ^^^ help: use `..` instead +... +LL | mac!(0); + | -------- in this macro invocation + | + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + +error[E0586]: inclusive range with no end + --> $DIR/half-open-range-pats-inclusive-no-end.rs:21:19 + | +LL | let $e..=; + | ^^^ help: use `..` instead +... +LL | mac!(0); + | -------- in this macro invocation + | + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0586`. diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.rs index e9a5361e63d27..f054bbea4e3e7 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.rs @@ -20,5 +20,7 @@ fn syntax() { &..=0 | _ => {} //~^ ERROR the range pattern here has ambiguous interpretation &...0 | _ => {} + //~^ ERROR the range pattern here has ambiguous interpretation + //~| ERROR range-to patterns with `...` are not allowed } } diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.stderr b/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.stderr index 5d3aded022224..a5f7c390627ba 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.stderr +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-ref-ambiguous-interp.stderr @@ -8,9 +8,9 @@ error[E0586]: inclusive range with no end --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:11 | LL | &0..= | _ => {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: the range pattern here has ambiguous interpretation --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:10 @@ -22,9 +22,9 @@ error[E0586]: inclusive range with no end --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:13:11 | LL | &0... | _ => {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: the range pattern here has ambiguous interpretation --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:18:10 @@ -38,6 +38,18 @@ error: the range pattern here has ambiguous interpretation LL | &..=0 | _ => {} | ^^^^ help: add parentheses to clarify the precedence: `(..=0)` -error: aborting due to 6 previous errors +error: range-to patterns with `...` are not allowed + --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:22:10 + | +LL | &...0 | _ => {} + | ^^^ help: use `..=` instead + +error: the range pattern here has ambiguous interpretation + --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:22:10 + | +LL | &...0 | _ => {} + | ^^^^ help: add parentheses to clarify the precedence: `(..=0)` + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0586`. diff --git a/src/test/ui/half-open-range-patterns/half-open-range-pats-syntactic-pass.rs b/src/test/ui/half-open-range-patterns/half-open-range-pats-syntactic-pass.rs index a663acd2d191c..8bb98d3b5c56f 100644 --- a/src/test/ui/half-open-range-patterns/half-open-range-pats-syntactic-pass.rs +++ b/src/test/ui/half-open-range-patterns/half-open-range-pats-syntactic-pass.rs @@ -11,22 +11,20 @@ fn main() {} fn syntax() { match scrutinee { X.. | 0.. | 'a'.. | 0.0f32.. => {} - ..=X | ...X | ..X => {} - ..=0 | ...0 | ..0 => {} - ..='a' | ...'a' | ..'a' => {} - ..=0.0f32 | ...0.0f32 | ..0.0f32 => {} + ..=X | ..X => {} + ..=0 | ..0 => {} + ..='a' | ..'a' => {} + ..=0.0f32 | ..0.0f32 => {} } +} +fn syntax2() { macro_rules! mac { ($e:expr) => { - let ..$e; - let ...$e; - let ..=$e; - let $e..; - let $e...; - let $e..=; + match 0u8 { ..$e => {}, _ => {} } + match 0u8 { ..=$e => {}, _ => {} } + match 0u8 { $e.. => {}, _ => {} } } } - - mac!(0); + mac!(42u8); } diff --git a/src/test/ui/impossible_range.rs b/src/test/ui/impossible_range.rs index 6345af001112f..21e5c03eb1605 100644 --- a/src/test/ui/impossible_range.rs +++ b/src/test/ui/impossible_range.rs @@ -1,4 +1,4 @@ -// Make sure that invalid ranges generate an error during HIR lowering, not an ICE +// Make sure that invalid ranges generate an error during parsing, not an ICE pub fn main() { ..; @@ -6,12 +6,12 @@ pub fn main() { ..1; 0..1; ..=; //~ERROR inclusive range with no end - //~^HELP bounded at the end + //~^HELP use `..` instead } fn _foo1() { ..=1; 0..=1; 0..=; //~ERROR inclusive range with no end - //~^HELP bounded at the end + //~^HELP use `..` instead } diff --git a/src/test/ui/impossible_range.stderr b/src/test/ui/impossible_range.stderr index 091fe37c7a1f7..ea2ab0f299d1b 100644 --- a/src/test/ui/impossible_range.stderr +++ b/src/test/ui/impossible_range.stderr @@ -1,18 +1,18 @@ error[E0586]: inclusive range with no end - --> $DIR/impossible_range.rs:8:8 + --> $DIR/impossible_range.rs:8:5 | LL | ..=; - | ^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end - --> $DIR/impossible_range.rs:15:9 + --> $DIR/impossible_range.rs:15:6 | LL | 0..=; - | ^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr index 654b49ab62022..4775b9b7bc003 100644 --- a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr +++ b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr @@ -342,9 +342,9 @@ error[E0586]: inclusive range with no end --> $DIR/attr-stmt-expr-attr-bad.rs:94:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` --> $DIR/attr-stmt-expr-attr-bad.rs:94:38 @@ -356,9 +356,9 @@ error[E0586]: inclusive range with no end --> $DIR/attr-stmt-expr-attr-bad.rs:97:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` --> $DIR/attr-stmt-expr-attr-bad.rs:97:38 @@ -376,9 +376,9 @@ error[E0586]: inclusive range with no end --> $DIR/attr-stmt-expr-attr-bad.rs:102:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` --> $DIR/attr-stmt-expr-attr-bad.rs:102:38 diff --git a/src/test/ui/parser/range_inclusive.rs b/src/test/ui/parser/range_inclusive.rs index bc61c5b49ea87..7c3b906b47f9f 100644 --- a/src/test/ui/parser/range_inclusive.rs +++ b/src/test/ui/parser/range_inclusive.rs @@ -2,5 +2,5 @@ pub fn main() { for _ in 1..= {} //~ERROR inclusive range with no end - //~^HELP bounded at the end + //~^HELP use `..` instead } diff --git a/src/test/ui/parser/range_inclusive.stderr b/src/test/ui/parser/range_inclusive.stderr index 12b7edae79f52..1dd4799459681 100644 --- a/src/test/ui/parser/range_inclusive.stderr +++ b/src/test/ui/parser/range_inclusive.stderr @@ -1,10 +1,10 @@ error[E0586]: inclusive range with no end - --> $DIR/range_inclusive.rs:4:19 + --> $DIR/range_inclusive.rs:4:15 | LL | for _ in 1..= {} - | ^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: aborting due to previous error diff --git a/src/test/ui/parser/recover-range-pats.rs b/src/test/ui/parser/recover-range-pats.rs index a5aae2861b282..e07ea6221d7c9 100644 --- a/src/test/ui/parser/recover-range-pats.rs +++ b/src/test/ui/parser/recover-range-pats.rs @@ -107,15 +107,15 @@ fn inclusive_to() { fn inclusive2_to() { if let ...3 = 0 {} - //~^ ERROR `...` range patterns are deprecated + //~^ ERROR range-to patterns with `...` are not allowed if let ...Y = 0 {} - //~^ ERROR `...` range patterns are deprecated + //~^ ERROR range-to patterns with `...` are not allowed if let ...true = 0 {} - //~^ ERROR `...` range patterns are deprecated + //~^ ERROR range-to patterns with `...` are not allowed //~| ERROR only char and numeric types if let ....3 = 0 {} //~^ ERROR float literals must have an integer part - //~| ERROR `...` range patterns are deprecated + //~| ERROR range-to patterns with `...` are not allowed //~| ERROR mismatched types } @@ -135,7 +135,7 @@ fn with_macro_expr_var() { ($e:expr) => { let ..$e; let ...$e; - //~^ ERROR `...` range patterns are deprecated + //~^ ERROR range-to patterns with `...` are not allowed let ..=$e; let $e..; let $e...; //~ ERROR inclusive range with no end diff --git a/src/test/ui/parser/recover-range-pats.stderr b/src/test/ui/parser/recover-range-pats.stderr index d3d3169022a65..f43f9bf301218 100644 --- a/src/test/ui/parser/recover-range-pats.stderr +++ b/src/test/ui/parser/recover-range-pats.stderr @@ -44,25 +44,25 @@ error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:69:13 | LL | if let 0..= = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:70:13 | LL | if let X..= = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:71:16 | LL | if let true..= = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: float literals must have an integer part --> $DIR/recover-range-pats.rs:73:12 @@ -74,33 +74,33 @@ error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:73:14 | LL | if let .0..= = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:79:13 | LL | if let 0... = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:80:13 | LL | if let X... = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:81:16 | LL | if let true... = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: float literals must have an integer part --> $DIR/recover-range-pats.rs:83:12 @@ -112,9 +112,9 @@ error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:83:14 | LL | if let .0... = 0 {} - | ^^^ + | ^^^ help: use `..` instead | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: float literals must have an integer part --> $DIR/recover-range-pats.rs:93:15 @@ -128,33 +128,66 @@ error: float literals must have an integer part LL | if let ..=.0 = 0 {} | ^^ help: must have an integer part: `0.0` +error: range-to patterns with `...` are not allowed + --> $DIR/recover-range-pats.rs:109:12 + | +LL | if let ...3 = 0 {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/recover-range-pats.rs:111:12 + | +LL | if let ...Y = 0 {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/recover-range-pats.rs:113:12 + | +LL | if let ...true = 0 {} + | ^^^ help: use `..=` instead + error: float literals must have an integer part --> $DIR/recover-range-pats.rs:116:15 | LL | if let ....3 = 0 {} | ^^ help: must have an integer part: `0.3` +error: range-to patterns with `...` are not allowed + --> $DIR/recover-range-pats.rs:116:12 + | +LL | if let ....3 = 0 {} + | ^^^ help: use `..=` instead + +error: range-to patterns with `...` are not allowed + --> $DIR/recover-range-pats.rs:137:17 + | +LL | let ...$e; + | ^^^ help: use `..=` instead +... +LL | mac!(0); + | -------- in this macro invocation + error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:141:19 | LL | let $e...; - | ^^^ + | ^^^ help: use `..` instead ... LL | mac!(0); | -------- in this macro invocation | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error[E0586]: inclusive range with no end --> $DIR/recover-range-pats.rs:142:19 | LL | let $e..=; - | ^^^ + | ^^^ help: use `..` instead ... LL | mac!(0); | -------- in this macro invocation | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:42:13 @@ -210,30 +243,6 @@ error: `...` range patterns are deprecated LL | if let X... .0 = 0 {} | ^^^ help: use `..=` for an inclusive range -error: `...` range patterns are deprecated - --> $DIR/recover-range-pats.rs:109:12 - | -LL | if let ...3 = 0 {} - | ^^^ help: use `..=` for an inclusive range - -error: `...` range patterns are deprecated - --> $DIR/recover-range-pats.rs:111:12 - | -LL | if let ...Y = 0 {} - | ^^^ help: use `..=` for an inclusive range - -error: `...` range patterns are deprecated - --> $DIR/recover-range-pats.rs:113:12 - | -LL | if let ...true = 0 {} - | ^^^ help: use `..=` for an inclusive range - -error: `...` range patterns are deprecated - --> $DIR/recover-range-pats.rs:116:12 - | -LL | if let ....3 = 0 {} - | ^^^ help: use `..=` for an inclusive range - error: `...` range patterns are deprecated --> $DIR/recover-range-pats.rs:126:20 | @@ -243,15 +252,6 @@ LL | let $e1...$e2; LL | mac2!(0, 1); | ------------ in this macro invocation -error: `...` range patterns are deprecated - --> $DIR/recover-range-pats.rs:137:17 - | -LL | let ...$e; - | ^^^ help: use `..=` for an inclusive range -... -LL | mac!(0); - | -------- in this macro invocation - error[E0029]: only char and numeric types are allowed in range patterns --> $DIR/recover-range-pats.rs:20:12 |