Skip to content

Commit b106480

Browse files
committed
Repair various cases where values of distinct types were being operated
upon (e.g., `&int` added to `int`).
1 parent 065caf3 commit b106480

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/libarena/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl Drop for Arena {
130130

131131
#[inline]
132132
fn round_up(base: uint, align: uint) -> uint {
133-
(base.checked_add(&(align - 1))).unwrap() & !(&(align - 1))
133+
(base.checked_add(&(align - 1))).unwrap() & !(align - 1)
134134
}
135135

136136
// Walk down a chunk, running the destructors for any objects stored

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl<T> Vec<T> {
927927
///
928928
/// ```
929929
/// let mut vec = vec![1i, 2, 3, 4];
930-
/// vec.retain(|x| x%2 == 0);
930+
/// vec.retain(|&x| x%2 == 0);
931931
/// assert_eq!(vec, vec![2, 4]);
932932
/// ```
933933
#[unstable = "the closure argument may become an unboxed closure"]

src/libcoretest/iter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ fn test_iterator_size_hint() {
356356
assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3)));
357357
assert_eq!(vi.scan(0i, |_,_| Some(0i)).size_hint(), (0, Some(10)));
358358
assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10)));
359-
assert_eq!(vi.map(|i| i+1).size_hint(), (10, Some(10)));
359+
assert_eq!(vi.map(|&i| i+1).size_hint(), (10, Some(10)));
360360
assert_eq!(vi.filter_map(|_| Some(0i)).size_hint(), (0, Some(10)));
361361
}
362362

@@ -388,9 +388,9 @@ fn test_any() {
388388
#[test]
389389
fn test_find() {
390390
let v: &[int] = &[1i, 3, 9, 27, 103, 14, 11];
391-
assert_eq!(*v.iter().find(|x| *x & 1 == 0).unwrap(), 14);
392-
assert_eq!(*v.iter().find(|x| *x % 3 == 0).unwrap(), 3);
393-
assert!(v.iter().find(|x| *x % 12 == 0).is_none());
391+
assert_eq!(*v.iter().find(|&&x| x & 1 == 0).unwrap(), 14);
392+
assert_eq!(*v.iter().find(|&&x| x % 3 == 0).unwrap(), 3);
393+
assert!(v.iter().find(|&&x| x % 12 == 0).is_none());
394394
}
395395

396396
#[test]

src/libstd/bitflags.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ macro_rules! bitflags {
177177
/// Returns `true` if there are flags common to both `self` and `other`.
178178
#[inline]
179179
pub fn intersects(&self, other: $BitFlags) -> bool {
180-
!(self & other).is_empty()
180+
!(*self & other).is_empty()
181181
}
182182

183183
/// Returns `true` all of the flags in `other` are contained within `self`.
184184
#[inline]
185185
pub fn contains(&self, other: $BitFlags) -> bool {
186-
(self & other) == other
186+
(*self & other) == other
187187
}
188188

189189
/// Inserts the specified flags in-place.

src/libstd/time/duration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl fmt::Show for Duration {
319319
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
320320
// technically speaking, negative duration is not valid ISO 8601,
321321
// but we need to print it anyway.
322-
let (abs, sign) = if self.secs < 0 { (-self, "-") } else { (*self, "") };
322+
let (abs, sign) = if self.secs < 0 { (-*self, "-") } else { (*self, "") };
323323

324324
let days = abs.secs / SECS_PER_DAY;
325325
let secs = abs.secs - days * SECS_PER_DAY;

src/libtime/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Add<Duration, Timespec> for Timespec {
9696
let d_sec = other.num_seconds();
9797
// It is safe to unwrap the nanoseconds, because there cannot be
9898
// more than one second left, which fits in i64 and in i32.
99-
let d_nsec = (other - Duration::seconds(d_sec))
99+
let d_nsec = (*other - Duration::seconds(d_sec))
100100
.num_nanoseconds().unwrap() as i32;
101101
let mut sec = self.sec + d_sec;
102102
let mut nsec = self.nsec + d_nsec;

0 commit comments

Comments
 (0)