From ef83e689a82682ba9547de1b921d72b5a3d75b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Tue, 24 May 2022 00:00:00 +0000 Subject: [PATCH] rustc_codegen_ssa: derive copy and clone for various enums --- compiler/rustc_codegen_gcc/src/builder.rs | 21 ++------------------- compiler/rustc_codegen_ssa/src/common.rs | 5 +++++ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs index 62eeb373821..479328a557c 100644 --- a/compiler/rustc_codegen_gcc/src/builder.rs +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -61,23 +61,6 @@ enum ExtremumOperation { Min, } -trait EnumClone { - fn clone(&self) -> Self; -} - -impl EnumClone for AtomicOrdering { - fn clone(&self) -> Self { - match *self { - AtomicOrdering::Unordered => AtomicOrdering::Unordered, - AtomicOrdering::Relaxed => AtomicOrdering::Relaxed, - AtomicOrdering::Acquire => AtomicOrdering::Acquire, - AtomicOrdering::Release => AtomicOrdering::Release, - AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease, - AtomicOrdering::SequentiallyConsistent => AtomicOrdering::SequentiallyConsistent, - } - } -} - pub struct Builder<'a: 'gcc, 'gcc, 'tcx> { pub cx: &'a CodegenCx<'gcc, 'tcx>, pub block: Block<'gcc>, @@ -102,9 +85,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { match order { // TODO(antoyo): does this make sense? AtomicOrdering::AcquireRelease | AtomicOrdering::Release => AtomicOrdering::Acquire, - _ => order.clone(), + _ => order, }; - let previous_value = self.atomic_load(dst.get_type(), dst, load_ordering.clone(), Size::from_bytes(size)); + let previous_value = self.atomic_load(dst.get_type(), dst, load_ordering, Size::from_bytes(size)); let previous_var = func.new_local(None, previous_value.get_type(), "previous_value"); let return_value = func.new_local(None, previous_value.get_type(), "return_value"); self.llbb().add_assignment(None, previous_var, previous_value); diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index 517cdd1e8de..8ca1a6084cf 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -11,6 +11,7 @@ use rustc_span::Span; use crate::base; use crate::traits::*; +#[derive(Copy, Clone)] pub enum IntPredicate { IntEQ, IntNE, @@ -24,6 +25,7 @@ pub enum IntPredicate { IntSLE, } +#[derive(Copy, Clone)] pub enum RealPredicate { RealPredicateFalse, RealOEQ, @@ -43,6 +45,7 @@ pub enum RealPredicate { RealPredicateTrue, } +#[derive(Copy, Clone)] pub enum AtomicRmwBinOp { AtomicXchg, AtomicAdd, @@ -57,6 +60,7 @@ pub enum AtomicRmwBinOp { AtomicUMin, } +#[derive(Copy, Clone)] pub enum AtomicOrdering { Unordered, Relaxed, @@ -66,6 +70,7 @@ pub enum AtomicOrdering { SequentiallyConsistent, } +#[derive(Copy, Clone)] pub enum SynchronizationScope { SingleThread, CrossThread,