Skip to content

Commit 8de8580

Browse files
committed
Properly process ptr_op for const eval
1 parent 3d82b66 commit 8de8580

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/librustc_mir/interpret/const_eval.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ impl<'tcx> super::Machine<'tcx> for CompileTimeFunctionEvaluator {
179179
fn ptr_op<'a>(
180180
_ecx: &EvalContext<'a, 'tcx, Self>,
181181
_bin_op: mir::BinOp,
182-
_left: PrimVal,
182+
left: PrimVal,
183183
_left_ty: Ty<'tcx>,
184-
_right: PrimVal,
184+
right: PrimVal,
185185
_right_ty: Ty<'tcx>,
186186
) -> EvalResult<'tcx, Option<(PrimVal, bool)>> {
187-
Err(ConstEvalError::NeedsRfc("Pointer arithmetic or comparison".to_string()).into())
187+
if left.is_bytes() && right.is_bytes() {
188+
Ok(None)
189+
} else {
190+
Err(ConstEvalError::NeedsRfc("Pointer arithmetic or comparison".to_string()).into())
191+
}
188192
}
189193

190194
fn mark_static_initialized(m: !) -> EvalResult<'tcx> {

0 commit comments

Comments
 (0)