about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreas Liljeqvist <bonega@gmail.com>2021-08-24 19:41:58 +0200
committerAndreas Liljeqvist <bonega@gmail.com>2021-08-24 19:41:58 +0200
commitf17e384a43dd8ca0aefb36bfcd8a69d9ad7f12cf (patch)
treeceab8cc96a4c987f26b0a2e8ab7f78793edcb5bb
parente3f07b2e30eb29a737b13ab127db927d3825c22b (diff)
downloadrust-f17e384a43dd8ca0aefb36bfcd8a69d9ad7f12cf.tar.gz
rust-f17e384a43dd8ca0aefb36bfcd8a69d9ad7f12cf.zip
use convention for with_* methods
-rw-r--r--compiler/rustc_target/src/abi/mod.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs
index 49c06fca85a..d206df46120 100644
--- a/compiler/rustc_target/src/abi/mod.rs
+++ b/compiler/rustc_target/src/abi/mod.rs
@@ -713,16 +713,18 @@ impl WrappingRange {
         self.start > self.end || self.start == 0
     }
 
-    /// Returns new `WrappingRange` with replaced `start`
+    /// Returns `self` with replaced `start`
     #[inline(always)]
-    pub fn with_start(&self, start: u128) -> Self {
-        Self { start, end: self.end }
+    pub fn with_start(mut self, start: u128) -> Self {
+        self.start = start;
+        self
     }
 
-    /// Returns new `WrappingRange` with replaced `end`
+    /// Returns `self` with replaced `end`
     #[inline(always)]
-    pub fn with_end(&self, end: u128) -> Self {
-        Self { start: self.start, end }
+    pub fn with_end(mut self, end: u128) -> Self {
+        self.end = end;
+        self
     }
 }
 
@@ -1024,7 +1026,7 @@ impl Niche {
     pub fn reserve<C: HasDataLayout>(&self, cx: &C, count: u128) -> Option<(u128, Scalar)> {
         assert!(count > 0);
 
-        let Scalar { value, valid_range: ref v } = self.scalar;
+        let Scalar { value, valid_range: v } = self.scalar.clone();
         let bits = value.size(cx).bits();
         assert!(bits <= 128);
         let max_value = !0u128 >> (128 - bits);