Skip to content

Commit 7d72719

Browse files
author
Jorge Aparicio
committed
fix the &mut _ patterns
1 parent ed4bebd commit 7d72719

File tree

15 files changed

+23
-23
lines changed

15 files changed

+23
-23
lines changed

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ mod tests {
20302030
v.push(());
20312031
assert_eq!(v.iter_mut().count(), 4);
20322032

2033-
for &() in v.iter_mut() {}
2033+
for &mut () in v.iter_mut() {}
20342034
unsafe { v.set_len(0); }
20352035
assert_eq!(v.iter_mut().count(), 0);
20362036
}

src/libcore/iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,7 @@ impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where
23442344
///
23452345
/// // This iterator will yield up to the last Fibonacci number before the max value of `u32`.
23462346
/// // You can simply change `u32` to `u64` in this line if you want higher values than that.
2347-
/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)), |&(ref mut x2, ref mut x1)| {
2347+
/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)), |&mut (ref mut x2, ref mut x1)| {
23482348
/// // Attempt to get the next Fibonacci number
23492349
/// // `x1` will be `None` if previously overflowed.
23502350
/// let next = match (*x2, *x1) {

src/libcore/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ impl<T> Option<T> {
533533
/// ```
534534
/// let mut x = Some(4u);
535535
/// match x.iter_mut().next() {
536-
/// Some(&ref mut v) => *v = 42u,
536+
/// Some(&mut ref mut v) => *v = 42u,
537537
/// None => {},
538538
/// }
539539
/// assert_eq!(x, Some(42));

src/libcore/result.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ impl<T, E> Result<T, E> {
383383
/// ```
384384
/// fn mutate(r: &mut Result<int, int>) {
385385
/// match r.as_mut() {
386-
/// Ok(&ref mut v) => *v = 42,
387-
/// Err(&ref mut e) => *e = 0,
386+
/// Ok(&mut ref mut v) => *v = 42,
387+
/// Err(&mut ref mut e) => *e = 0,
388388
/// }
389389
/// }
390390
///
@@ -529,7 +529,7 @@ impl<T, E> Result<T, E> {
529529
/// ```
530530
/// let mut x: Result<uint, &str> = Ok(7);
531531
/// match x.iter_mut().next() {
532-
/// Some(&ref mut x) => *x = 40,
532+
/// Some(&mut ref mut x) => *x = 40,
533533
/// None => {},
534534
/// }
535535
/// assert_eq!(x, Ok(40));

src/libcoretest/any.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ fn any_downcast_mut() {
101101
}
102102

103103
match a_r.downcast_mut::<uint>() {
104-
Some(&612) => {}
104+
Some(&mut 612) => {}
105105
x => panic!("Unexpected value {:?}", x)
106106
}
107107

108108
match b_r.downcast_mut::<uint>() {
109-
Some(&413) => {}
109+
Some(&mut 413) => {}
110110
x => panic!("Unexpected value {:?}", x)
111111
}
112112
}

src/librustc_driver/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ impl<'a, 'ast> Iterator for NodesMatchingUII<'a, 'ast> {
350350

351351
fn next(&mut self) -> Option<ast::NodeId> {
352352
match self {
353-
&NodesMatchingDirect(ref mut iter) => iter.next(),
354-
&NodesMatchingSuffix(ref mut iter) => iter.next(),
353+
&mut NodesMatchingDirect(ref mut iter) => iter.next(),
354+
&mut NodesMatchingSuffix(ref mut iter) => iter.next(),
355355
}
356356
}
357357
}

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17091709
/// ! gets replaced with (), unconstrained ints with i32, and unconstrained floats with f64.
17101710
pub fn default_type_parameters(&self) {
17111711
use middle::ty::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat, Neither};
1712-
for (_, &ref ty) in self.inh.node_types.borrow_mut().iter_mut() {
1712+
for (_, &mut ref ty) in self.inh.node_types.borrow_mut().iter_mut() {
17131713
let resolved = self.infcx().resolve_type_vars_if_possible(ty);
17141714
if self.infcx().type_var_diverges(resolved) {
17151715
demand::eqtype(self, codemap::DUMMY_SP, *ty, ty::mk_nil(self.tcx()));

src/libstd/sync/mpsc/stream.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<T: Send> Packet<T> {
338338
// upgrade pending, then go through the whole recv rigamarole to update
339339
// the internal state.
340340
match self.queue.peek() {
341-
Some(&GoUp(..)) => {
341+
Some(&mut GoUp(..)) => {
342342
match self.recv() {
343343
Err(Upgraded(port)) => Err(port),
344344
_ => unreachable!(),
@@ -367,7 +367,7 @@ impl<T: Send> Packet<T> {
367367
Ok(()) => SelSuccess,
368368
Err(token) => {
369369
let ret = match self.queue.peek() {
370-
Some(&GoUp(..)) => {
370+
Some(&mut GoUp(..)) => {
371371
match self.queue.pop() {
372372
Some(GoUp(port)) => SelUpgraded(token, port),
373373
_ => unreachable!(),
@@ -457,7 +457,7 @@ impl<T: Send> Packet<T> {
457457
// upgraded port.
458458
if has_data {
459459
match self.queue.peek() {
460-
Some(&GoUp(..)) => {
460+
Some(&mut GoUp(..)) => {
461461
match self.queue.pop() {
462462
Some(GoUp(port)) => Err(port),
463463
_ => unreachable!(),

src/libsyntax/ast_map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'a, T: Copy> Iterator for Values<'a, T> {
9090
type Item = T;
9191

9292
fn next(&mut self) -> Option<T> {
93-
let &Values(ref mut items) = self;
93+
let &mut Values(ref mut items) = self;
9494
items.next().map(|&x| x)
9595
}
9696
}

src/test/bench/shootout-meteor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn transform(piece: Vec<(int, int)> , all: bool) -> Vec<Vec<(int, int)>> {
118118
// translating to (0, 0) as minimum coordinates.
119119
for cur_piece in res.iter_mut() {
120120
let (dy, dx) = *cur_piece.iter().min_by(|e| *e).unwrap();
121-
for &(ref mut y, ref mut x) in cur_piece.iter_mut() {
121+
for &mut (ref mut y, ref mut x) in cur_piece.iter_mut() {
122122
*y -= dy; *x -= dx;
123123
}
124124
}

src/test/compile-fail/issue-15756.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::slice::ChunksMut;
1414
fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>)
1515
{
1616
for
17-
&something
17+
&mut something
1818
//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[T]`
1919
in arg2
2020
{

src/test/compile-fail/mut-pattern-mismatched.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313

1414
// (separate lines to ensure the spans are accurate)
1515

16-
let &_ // ~ ERROR expected `&mut isize`, found `&_`
16+
let &_ //~ ERROR expected `&mut isize`, found `&_`
1717
= foo;
1818
let &mut _ = foo;
1919

src/test/compile-fail/pattern-bindings-after-at.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum Option<T> {
1515

1616
fn main() {
1717
match &mut Some(1i) {
18-
ref mut z @ &Some(ref a) => {
18+
ref mut z @ &mut Some(ref a) => {
1919
//~^ ERROR pattern bindings are not allowed after an `@`
2020
**z = None;
2121
println!("{}", *a);

src/test/run-pass/drop-trait-enum.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ enum Foo {
3636
impl Drop for Foo {
3737
fn drop(&mut self) {
3838
match self {
39-
&Foo::SimpleVariant(ref mut sender) => {
39+
&mut Foo::SimpleVariant(ref mut sender) => {
4040
sender.send(Message::DestructorRan).unwrap();
4141
}
42-
&Foo::NestedVariant(_, _, ref mut sender) => {
42+
&mut Foo::NestedVariant(_, _, ref mut sender) => {
4343
sender.send(Message::DestructorRan).unwrap();
4444
}
45-
&Foo::FailingVariant { .. } => {
45+
&mut Foo::FailingVariant { .. } => {
4646
panic!("Failed");
4747
}
4848
}

src/test/run-pass/issue-16774.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Deref for X {
3636

3737
impl DerefMut for X {
3838
fn deref_mut(&mut self) -> &mut int {
39-
let &X(box ref mut x) = self;
39+
let &mut X(box ref mut x) = self;
4040
x
4141
}
4242
}

0 commit comments

Comments
 (0)