diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-01-30 11:03:32 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-01-30 12:26:26 +0000 |
| commit | fd649a3cc5e9f17c8aee070227e8c71f094560b7 (patch) | |
| tree | b2d741c4f018a744f79877a8ca669a2617c652e1 /compiler/rustc_const_eval/src | |
| parent | f55b0022db8dccc6aa6bf3f650b562eaec0fdc54 (diff) | |
| download | rust-fd649a3cc5e9f17c8aee070227e8c71f094560b7.tar.gz rust-fd649a3cc5e9f17c8aee070227e8c71f094560b7.zip | |
Replace enum `==`s with `match`es where it makes sense
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/machine.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index a5bc121485d..d865d5bc974 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -622,10 +622,9 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, let alloc = alloc.inner(); if is_write { // Write access. These are never allowed, but we give a targeted error message. - if alloc.mutability == Mutability::Not { - Err(err_ub!(WriteToReadOnly(alloc_id)).into()) - } else { - Err(ConstEvalErrKind::ModifiedGlobal.into()) + match alloc.mutability { + Mutability::Not => Err(err_ub!(WriteToReadOnly(alloc_id)).into()), + Mutability::Mut => Err(ConstEvalErrKind::ModifiedGlobal.into()), } } else { // Read access. These are usually allowed, with some exceptions. |
