about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-13 21:27:07 +0000
committerbors <bors@rust-lang.org>2015-09-13 21:27:07 +0000
commit483600e65fa90bf62491e24ed88499fe4fee819a (patch)
tree6a891ba1ca05248f983b46c6eec83d62bdf8ac72 /src
parentcedbd998a4669e026b2a1b34de95d91cd0fde1a5 (diff)
parent4611308751ebd77df0411669f469e12d960ee538 (diff)
downloadrust-483600e65fa90bf62491e24ed88499fe4fee819a.tar.gz
rust-483600e65fa90bf62491e24ed88499fe4fee819a.zip
Auto merge of #28178 - christopherdumas:fix_ice, r=nikomatsakis
This fixes the ICE, and makes it just a compiler error/warning. I'm not exactly sure that's whats wanted, so tell me if it isn't.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/middle/check_const.rs4
-rw-r--r--src/test/compile-fail/non-constant-in-const-path.rs18
2 files changed, 20 insertions, 2 deletions
diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs
index ad9cbfcf4c0..37e14428176 100644
--- a/src/librustc/middle/check_const.rs
+++ b/src/librustc/middle/check_const.rs
@@ -378,8 +378,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
                             "lower range bound must be less than or equal to upper");
                     }
                     None => {
-                        self.tcx.sess.span_bug(
-                            start.span, "literals of different types in range pat");
+                        self.tcx.sess.delay_span_bug(start.span,
+                                                     "non-constant path in constant expr");
                     }
                 }
             }
diff --git a/src/test/compile-fail/non-constant-in-const-path.rs b/src/test/compile-fail/non-constant-in-const-path.rs
new file mode 100644
index 00000000000..124a2ffc185
--- /dev/null
+++ b/src/test/compile-fail/non-constant-in-const-path.rs
@@ -0,0 +1,18 @@
+// Copyright 2015 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 x = 0;
+    match 1 {
+        0 ... x => {}
+        //~^ ERROR non-constant path in constant expr
+        //~| ERROR paths in constants may only refer to constants or functions
+    };
+}