fn err_dotdotdot_syntax(&self, span: Span) {
self.diagnostic().struct_span_err(span, {
- "`...` syntax cannot be used in expressions"
- }).help({
- "Use `..` if you need an exclusive range (a < b)"
- }).help({
- "or `..=` if you need an inclusive range (a <= b)"
- }).emit();
+ "unexpected token: `...`"
+ }).span_suggestion_with_applicability(
+ span, "use `..` for an exclusive range", "..".to_owned(),
+ Applicability::MaybeIncorrect
+ ).span_suggestion_with_applicability(
+ span, "or `..=` for an inclusive range", "..=".to_owned(),
+ Applicability::MaybeIncorrect
+ ).emit();
}
// Parse bounds of a type parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`.
use std::ops::RangeToInclusive;
fn return_range_to() -> RangeToInclusive<i32> {
- return ...1; //~ERROR `...` syntax cannot be used in expressions
- //~^HELP Use `..` if you need an exclusive range (a < b)
- //~^^HELP or `..=` if you need an inclusive range (a <= b)
+ return ...1; //~ERROR unexpected token: `...`
+ //~^HELP use `..` for an exclusive range
+ //~^^HELP or `..=` for an inclusive range
}
pub fn main() {
- let x = ...0; //~ERROR `...` syntax cannot be used in expressions
- //~^HELP Use `..` if you need an exclusive range (a < b)
- //~^^HELP or `..=` if you need an inclusive range (a <= b)
+ let x = ...0; //~ERROR unexpected token: `...`
+ //~^HELP use `..` for an exclusive range
+ //~^^HELP or `..=` for an inclusive range
- let x = 5...5; //~ERROR `...` syntax cannot be used in expressions
- //~^HELP Use `..` if you need an exclusive range (a < b)
- //~^^HELP or `..=` if you need an inclusive range (a <= b)
+ let x = 5...5; //~ERROR unexpected token: `...`
+ //~^HELP use `..` for an exclusive range
+ //~^^HELP or `..=` for an inclusive range
- for _ in 0...1 {} //~ERROR `...` syntax cannot be used in expressions
- //~^HELP Use `..` if you need an exclusive range (a < b)
- //~^^HELP or `..=` if you need an inclusive range (a <= b)
+ for _ in 0...1 {} //~ERROR unexpected token: `...`
+ //~^HELP use `..` for an exclusive range
+ //~^^HELP or `..=` for an inclusive range
}
-
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+ let _redemptive = 1...21;
+ //~^ ERROR unexpected token
+}
--- /dev/null
+error: unexpected token: `...`
+ --> $DIR/dotdotdot-expr.rs:12:24
+ |
+LL | let _redemptive = 1...21;
+ | ^^^
+help: use `..` for an exclusive range
+ |
+LL | let _redemptive = 1..21;
+ | ^^
+help: or `..=` for an inclusive range
+ |
+LL | let _redemptive = 1..=21;
+ | ^^^
+
+error: aborting due to previous error
+