Skip to content

Commit 69bc614

Browse files
committed
---
yaml --- r: 56943 b: refs/heads/try c: c2f5a87 h: refs/heads/master i: 56941: 3702434 56939: 601d017 56935: 9f599a0 56927: f5da378 v: v3
1 parent d741b1a commit 69bc614

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
5-
refs/heads/try: c6f7b595f0bb3d8388a6bb89afc457a4702ec374
5+
refs/heads/try: c2f5a87cdd79e5531b751749827d2e8a3d269c9e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/const_eval.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -371,32 +371,31 @@ pub fn eval_const_expr_partial(tcx: middle::ty::ctxt, e: @expr)
371371
expr_cast(base, _) => {
372372
let ety = ty::expr_ty(tcx, e);
373373
let base = eval_const_expr_partial(tcx, base);
374-
match ty::get(ety).sty {
375-
ty::ty_float(_) => {
376-
match base {
377-
Ok(const_uint(u)) => Ok(const_float(u as f64)),
378-
Ok(const_int(i)) => Ok(const_float(i as f64)),
379-
Ok(const_float(_)) => base,
380-
_ => Err(~"Can't cast float to str")
381-
}
382-
}
383-
ty::ty_uint(_) => {
384-
match base {
385-
Ok(const_uint(_)) => base,
386-
Ok(const_int(i)) => Ok(const_uint(i as u64)),
387-
Ok(const_float(f)) => Ok(const_uint(f as u64)),
388-
_ => Err(~"Can't cast str to uint")
389-
}
390-
}
391-
ty::ty_int(_) | ty::ty_bool => {
392-
match base {
393-
Ok(const_uint(u)) => Ok(const_int(u as i64)),
394-
Ok(const_int(_)) => base,
395-
Ok(const_float(f)) => Ok(const_int(f as i64)),
396-
_ => Err(~"Can't cast str to int")
374+
match /*bad*/copy base {
375+
Err(_) => base,
376+
Ok(val) => {
377+
match ty::get(ety).sty {
378+
ty::ty_float(_) => match val {
379+
const_uint(u) => Ok(const_float(u as f64)),
380+
const_int(i) => Ok(const_float(i as f64)),
381+
const_float(_) => base,
382+
_ => Err(~"Can't cast float to str"),
383+
},
384+
ty::ty_uint(_) => match val {
385+
const_uint(_) => base,
386+
const_int(i) => Ok(const_uint(i as u64)),
387+
const_float(f) => Ok(const_uint(f as u64)),
388+
_ => Err(~"Can't cast str to uint"),
389+
},
390+
ty::ty_int(_) | ty::ty_bool => match val {
391+
const_uint(u) => Ok(const_int(u as i64)),
392+
const_int(_) => base,
393+
const_float(f) => Ok(const_int(f as i64)),
394+
_ => Err(~"Can't cast str to int"),
395+
},
396+
_ => Err(~"Can't cast this type")
397+
}
397398
}
398-
}
399-
_ => Err(~"Can't cast this type")
400399
}
401400
}
402401
expr_path(_) => {

0 commit comments

Comments
 (0)