Skip to content

Commit a1f7565

Browse files
committed
---
yaml --- r: 52475 b: refs/heads/dist-snap c: ab13beb h: refs/heads/master i: 52473: 4387e0b 52471: dd1b214 v: v3
1 parent 6741dc3 commit a1f7565

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 154488df1999e4c42f96ebaa6ee6c08be3f999a6
10+
refs/heads/dist-snap: ab13beb05a04fe4031288530701db7012befeab8
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/const_eval.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
295295
add => Ok(const_int(a + b)),
296296
subtract => Ok(const_int(a - b)),
297297
mul => Ok(const_int(a * b)),
298+
div if b == 0 => Err(~"divide by zero"),
298299
div => Ok(const_int(a / b)),
300+
rem if b == 0 => Err(~"modulo zero"),
299301
rem => Ok(const_int(a % b)),
300302
and | bitand => Ok(const_int(a & b)),
301303
or | bitor => Ok(const_int(a | b)),
@@ -315,7 +317,9 @@ fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
315317
add => Ok(const_uint(a + b)),
316318
subtract => Ok(const_uint(a - b)),
317319
mul => Ok(const_uint(a * b)),
320+
div if b == 0 => Err(~"divide by zero"),
318321
div => Ok(const_uint(a / b)),
322+
rem if b == 0 => Err(~"modulo zero"),
319323
rem => Ok(const_uint(a % b)),
320324
and | bitand => Ok(const_uint(a & b)),
321325
or | bitor => Ok(const_uint(a | b)),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
enum test {
2+
div_zero = 1/0, //~ERROR expected constant: divide by zero
3+
rem_zero = 1%0 //~ERROR expected constant: modulo zero
4+
}
5+
6+
fn main() {}

0 commit comments

Comments
 (0)