diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index b4d2be83827..858479eaa64 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -139,7 +139,6 @@ fn generic_fields_of(cx: @CrateContext, r: &Repr, sizing: bool) fn load_discr(bcx: block, scrutinee: ValueRef, min: int, max: int) -> ValueRef { let ptr = GEPi(bcx, scrutinee, [0, 0]); - // XXX: write tests for the edge cases here if max + 1 == min { // i.e., if the range is everything. The lo==hi case would be // rejected by the LLVM verifier (it would mean either an diff --git a/src/test/run-pass/enum-discrim-range-overflow.rs b/src/test/run-pass/enum-discrim-range-overflow.rs new file mode 100644 index 00000000000..a6806fba142 --- /dev/null +++ b/src/test/run-pass/enum-discrim-range-overflow.rs @@ -0,0 +1,31 @@ +// Copyright 2013 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. + +pub enum E64 { + H64 = 0x7FFF_FFFF_FFFF_FFFF, + L64 = 0x8000_0000_0000_0000 +} +pub enum E32 { + H32 = 0x7FFF_FFFF, + L32 = 0x8000_0000 +} + +pub fn f(e64: E64, e32: E32) -> (bool,bool) { + (match e64 { + H64 => true, + L64 => false + }, + match e32 { + H32 => true, + L32 => false + }) +} + +pub fn main() { }