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/transform | |
| 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/transform')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/check.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/validate.rs | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index cbfdb47dd1a..347c31ceeeb 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -679,6 +679,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { | StatementKind::AscribeUserType(..) | StatementKind::Coverage(..) | StatementKind::CopyNonOverlapping(..) + | StatementKind::Assume(..) | StatementKind::Nop => {} } } diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index b7988625839..dea445f6066 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -636,6 +636,15 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ); } } + StatementKind::Assume(box ref op) => { + let ty = op.ty(&self.body.local_decls, self.tcx); + if !ty.is_bool() { + self.fail( + location, + format!("`assume` argument must be `bool`, but got: `{}`", ty), + ); + } + } StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping { ref src, ref dst, |
