Skip to content

Commit 021c334

Browse files
committed
derive Copy for WrappingRange and Scalar
1 parent 4c46296 commit 021c334

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
300300
let llval = operand.immediate();
301301

302302
let mut signed = false;
303-
if let Abi::Scalar(ref scalar) = operand.layout.abi {
303+
if let Abi::Scalar(scalar) = operand.layout.abi {
304304
if let Int(_, s) = scalar.value {
305305
// We use `i1` for bytes that are always `0` or `1`,
306306
// e.g., `#[repr(i8)] enum E { A, B }`, but we can't

compiler/rustc_target/src/abi/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ impl Primitive {
741741
///
742742
/// This is intended specifically to mirror LLVM’s `!range` metadata,
743743
/// semantics.
744-
#[derive(Clone, PartialEq, Eq, Hash)]
744+
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
745745
#[derive(HashStable_Generic)]
746746
pub struct WrappingRange {
747747
pub start: u128,
@@ -797,7 +797,7 @@ impl fmt::Debug for WrappingRange {
797797
}
798798

799799
/// Information about one scalar component of a Rust type.
800-
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
800+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
801801
#[derive(HashStable_Generic)]
802802
pub struct Scalar {
803803
pub value: Primitive,
@@ -1070,7 +1070,7 @@ impl Niche {
10701070
}
10711071

10721072
pub fn available<C: HasDataLayout>(&self, cx: &C) -> u128 {
1073-
let Scalar { value, valid_range: ref v } = self.scalar;
1073+
let Scalar { value, valid_range: v } = self.scalar;
10741074
let bits = value.size(cx).bits();
10751075
assert!(bits <= 128);
10761076
let max_value = !0u128 >> (128 - bits);
@@ -1083,7 +1083,7 @@ impl Niche {
10831083
pub fn reserve<C: HasDataLayout>(&self, cx: &C, count: u128) -> Option<(u128, Scalar)> {
10841084
assert!(count > 0);
10851085

1086-
let Scalar { value, valid_range: v } = self.scalar.clone();
1086+
let Scalar { value, valid_range: v } = self.scalar;
10871087
let bits = value.size(cx).bits();
10881088
assert!(bits <= 128);
10891089
let max_value = !0u128 >> (128 - bits);
@@ -1137,7 +1137,7 @@ pub struct Layout {
11371137

11381138
impl Layout {
11391139
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
1140-
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar.clone());
1140+
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
11411141
let size = scalar.value.size(cx);
11421142
let align = scalar.value.align(cx);
11431143
Layout {

0 commit comments

Comments
 (0)