diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index ad9cbfcf4c05..37e144281760 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 000000000000..124a2ffc1854 --- /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 or the MIT license +// , 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 + }; +}