diff options
| author | bors <bors@rust-lang.org> | 2016-03-28 15:08:49 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-03-28 15:08:49 -0700 |
| commit | 44a77f67696e855a9841eaf7c7bf7639131cfec6 (patch) | |
| tree | 02c42e937d6c0b11e6bf21151f3328a1169dc7a4 /src/test | |
| parent | 221c940bf34887bb3f1900b757f8245ad23e8ef4 (diff) | |
| parent | 861644f2af5421f5aa55d4e7fddfc8dba54bcb70 (diff) | |
| download | rust-44a77f67696e855a9841eaf7c7bf7639131cfec6.tar.gz rust-44a77f67696e855a9841eaf7c7bf7639131cfec6.zip | |
Auto merge of #32267 - durka:inclusive-range-error, r=nrc
melt the ICE when lowering an impossible range Emit a fatal error instead of panicking when HIR lowering encounters a range with no `end` point. This involved adding a method to wire up `LoweringContext::span_fatal`. Fixes #32245 (cc @nodakai). r? @nrc
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/impossible_range.rs | 29 | ||||
| -rw-r--r-- | src/test/parse-fail/range_inclusive.rs | 5 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/test/compile-fail/impossible_range.rs b/src/test/compile-fail/impossible_range.rs new file mode 100644 index 00000000000..94e048fed65 --- /dev/null +++ b/src/test/compile-fail/impossible_range.rs @@ -0,0 +1,29 @@ +// Copyright 2016 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. + +// Make sure that invalid ranges generate an error during HIR lowering, not an ICE + +#![feature(inclusive_range_syntax)] + +pub fn main() { + ..; + 0..; + ..1; + 0..1; + + ...; //~ERROR inclusive range with no end + //~^HELP bounded at the end + 0...; //~ERROR inclusive range with no end + //~^HELP bounded at the end + ...1; + 0...1; +} + + diff --git a/src/test/parse-fail/range_inclusive.rs b/src/test/parse-fail/range_inclusive.rs index 5fd6f1834e0..ce97372c668 100644 --- a/src/test/parse-fail/range_inclusive.rs +++ b/src/test/parse-fail/range_inclusive.rs @@ -13,6 +13,7 @@ #![feature(inclusive_range_syntax, inclusive_range)] pub fn main() { - for _ in 1... {} -} //~ ERROR expected one of + for _ in 1... {} //~ERROR inclusive range with no end + //~^HELP bounded at the end +} |
