diff options
| author | bors <bors@rust-lang.org> | 2017-11-10 01:40:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-10 01:40:21 +0000 |
| commit | d5ff0e6422061c390a141354af8eacd540dca10b (patch) | |
| tree | 4ad997935d27db7d5a0dc758415f757d62fe12fb /src/test/parse-fail | |
| parent | aa1b0b239127ee379c5b3041240bc5ae247cf280 (diff) | |
| parent | b81a7b333abce1d5de85406947db5007d19730c4 (diff) | |
| download | rust-d5ff0e6422061c390a141354af8eacd540dca10b.tar.gz rust-d5ff0e6422061c390a141354af8eacd540dca10b.zip | |
Auto merge of #45773 - Badel2:dotdoteq, r=petrochenkov
Add error for `...` in expressions Follow-up to https://github.com/rust-lang/rust/pull/44709 Tracking issue: https://github.com/rust-lang/rust/issues/28237 * Using `...` in expressions was a warning, now it's an error * The error message suggests using `..` or `..=` instead, and explains the difference * Updated remaining occurrences of `...` to `..=` r? petrochenkov
Diffstat (limited to 'src/test/parse-fail')
| -rw-r--r-- | src/test/parse-fail/range_inclusive_dotdotdot.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/parse-fail/range_inclusive_dotdotdot.rs b/src/test/parse-fail/range_inclusive_dotdotdot.rs new file mode 100644 index 00000000000..a4c36a2f0ba --- /dev/null +++ b/src/test/parse-fail/range_inclusive_dotdotdot.rs @@ -0,0 +1,38 @@ +// Copyright 2017 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. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +// Make sure that inclusive ranges with `...` syntax don't parse. + +#![feature(inclusive_range_syntax, inclusive_range)] + +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) +} + +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 = 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) + + 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) +} + |
