Skip to content

Commit 7fee392

Browse files
committed
Handle differing signedness in constant shifts. Closes #2426.
1 parent ccb54f0 commit 7fee392

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/rustc/middle/const_eval.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
4949
le { fromb(a <= b) } ne { fromb(a != b) }
5050
ge { fromb(a >= b) } gt { fromb(a > b) }
5151
}
52-
5352
}
5453
(const_uint(a), const_uint(b)) {
5554
alt check op {
@@ -63,6 +62,17 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
6362
ge { fromb(a >= b) } gt { fromb(a > b) }
6463
}
6564
}
65+
// shifts can have any integral type as their rhs
66+
(const_int(a), const_uint(b)) {
67+
alt check op {
68+
shl { const_int(a << b) } shr { const_int(a >> b) }
69+
}
70+
}
71+
(const_uint(a), const_int(b)) {
72+
alt check op {
73+
shl { const_uint(a << b) } shr { const_uint(a >> b) }
74+
}
75+
}
6676
}
6777
}
6878
expr_cast(base, _) {

0 commit comments

Comments
 (0)