diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-06-30 08:16:05 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-09-06 14:18:32 +0000 |
| commit | 3f076451202409bca6262d7b5bf9a4fee3d18fb9 (patch) | |
| tree | caa5cf3deff3fb465f57d9a2a01641048bd60d1a /compiler/rustc_const_eval/src/interpret | |
| parent | 3c7278846102bb829c9a789e91bc43f0ed612943 (diff) | |
| download | rust-3f076451202409bca6262d7b5bf9a4fee3d18fb9.tar.gz rust-3f076451202409bca6262d7b5bf9a4fee3d18fb9.zip | |
Lower the assume intrinsic to a MIR statement
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/step.rs | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index adda9639990..8157ae2e5b8 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -506,12 +506,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // These just return their argument self.copy_op(&args[0], dest, /*allow_transmute*/ false)?; } - sym::assume => { - let cond = self.read_scalar(&args[0])?.to_bool()?; - if !cond { - throw_ub_format!("`assume` intrinsic called with `false`"); - } - } sym::raw_eq => { let result = self.raw_eq_intrinsic(&args[0], &args[1])?; self.write_scalar(result, dest)?; diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 6b827149f50..3ac1d1b3198 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -122,6 +122,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.copy_intrinsic(&src, &dst, &count, /* nonoverlapping */ true)?; } + // Call Assume + Assume(box op) => { + let op = self.eval_operand(op, None)?; + let cond = self.read_scalar(&op)?.to_bool()?; + if !cond { + throw_ub_format!("`assume` called with `false`"); + } + } + // Statements we do not track. AscribeUserType(..) => {} |
