Skip to content

Commit 571cc7f

Browse files
author
Jorge Aparicio
committed
remove all kind annotations from closures
1 parent ba2f13e commit 571cc7f

File tree

196 files changed

+396
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+396
-390
lines changed

src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::Test
359359
let config = (*config).clone();
360360
// FIXME (#9639): This needs to handle non-utf8 paths
361361
let testfile = testfile.as_str().unwrap().to_string();
362-
test::DynMetricFn(box move |: mm: &mut test::MetricMap| {
362+
test::DynMetricFn(box move |mm: &mut test::MetricMap| {
363363
runtest::run_metrics(config, testfile, mm)
364364
})
365365
}

src/libcollections/str.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'a> Iterator for Decompositions<'a> {
199199
let buffer = &mut self.buffer;
200200
let sorted = &mut self.sorted;
201201
{
202-
let callback = |&mut: d| {
202+
let callback = |d| {
203203
let class =
204204
unicode::char::canonical_combining_class(d);
205205
if class == 0 && !*sorted {
@@ -592,7 +592,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
592592
/// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect();
593593
/// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]);
594594
///
595-
/// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).collect();
595+
/// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).collect();
596596
/// assert_eq!(v, vec!["abc", "def", "ghi"]);
597597
///
598598
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
@@ -616,7 +616,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
616616
/// let v: Vec<&str> = "Mary had a little lambda".splitn(2, ' ').collect();
617617
/// assert_eq!(v, vec!["Mary", "had", "a little lambda"]);
618618
///
619-
/// let v: Vec<&str> = "abc1def2ghi".splitn(1, |&: c: char| c.is_numeric()).collect();
619+
/// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_numeric()).collect();
620620
/// assert_eq!(v, vec!["abc", "def2ghi"]);
621621
///
622622
/// let v: Vec<&str> = "lionXXtigerXleopard".splitn(2, 'X').collect();
@@ -651,7 +651,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
651651
/// let v: Vec<&str> = "Mary had a little lamb".split(' ').rev().collect();
652652
/// assert_eq!(v, vec!["lamb", "little", "a", "had", "Mary"]);
653653
///
654-
/// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).rev().collect();
654+
/// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).rev().collect();
655655
/// assert_eq!(v, vec!["ghi", "def", "abc"]);
656656
///
657657
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').rev().collect();
@@ -672,7 +672,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
672672
/// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
673673
/// assert_eq!(v, vec!["lamb", "little", "Mary had a"]);
674674
///
675-
/// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |&: c: char| c.is_numeric()).collect();
675+
/// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_numeric()).collect();
676676
/// assert_eq!(v, vec!["ghi", "abc1def"]);
677677
///
678678
/// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
@@ -853,7 +853,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
853853
/// assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
854854
/// let x: &[_] = &['1', '2'];
855855
/// assert_eq!("12foo1bar12".trim_matches(x), "foo1bar");
856-
/// assert_eq!("123foo1bar123".trim_matches(|&: c: char| c.is_numeric()), "foo1bar");
856+
/// assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
857857
/// ```
858858
#[stable(feature = "rust1", since = "1.0.0")]
859859
fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
@@ -873,7 +873,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
873873
/// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
874874
/// let x: &[_] = &['1', '2'];
875875
/// assert_eq!("12foo1bar12".trim_left_matches(x), "foo1bar12");
876-
/// assert_eq!("123foo1bar123".trim_left_matches(|&: c: char| c.is_numeric()), "foo1bar123");
876+
/// assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
877877
/// ```
878878
#[stable(feature = "rust1", since = "1.0.0")]
879879
fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
@@ -893,7 +893,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
893893
/// assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
894894
/// let x: &[_] = &['1', '2'];
895895
/// assert_eq!("12foo1bar12".trim_right_matches(x), "12foo1bar");
896-
/// assert_eq!("123foo1bar123".trim_right_matches(|&: c: char| c.is_numeric()), "123foo1bar");
896+
/// assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
897897
/// ```
898898
#[stable(feature = "rust1", since = "1.0.0")]
899899
fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str {
@@ -1066,7 +1066,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
10661066
/// assert_eq!(s.find('é'), Some(14));
10671067
///
10681068
/// // the first space
1069-
/// assert_eq!(s.find(|&: c: char| c.is_whitespace()), Some(5));
1069+
/// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5));
10701070
///
10711071
/// // neither are found
10721072
/// let x: &[_] = &['1', '2'];
@@ -1094,7 +1094,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
10941094
/// assert_eq!(s.rfind('é'), Some(14));
10951095
///
10961096
/// // the second space
1097-
/// assert_eq!(s.rfind(|&: c: char| c.is_whitespace()), Some(12));
1097+
/// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12));
10981098
///
10991099
/// // searches for an occurrence of either `1` or `2`, but neither are found
11001100
/// let x: &[_] = &['1', '2'];
@@ -1387,21 +1387,21 @@ mod tests {
13871387
#[test]
13881388
fn test_find() {
13891389
assert_eq!("hello".find('l'), Some(2u));
1390-
assert_eq!("hello".find(|&: c:char| c == 'o'), Some(4u));
1390+
assert_eq!("hello".find(|c:char| c == 'o'), Some(4u));
13911391
assert!("hello".find('x').is_none());
1392-
assert!("hello".find(|&: c:char| c == 'x').is_none());
1392+
assert!("hello".find(|c:char| c == 'x').is_none());
13931393
assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u));
1394-
assert_eq!("ประเทศไทย中华Việt Nam".find(|&: c: char| c == '华'), Some(30u));
1394+
assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u));
13951395
}
13961396

13971397
#[test]
13981398
fn test_rfind() {
13991399
assert_eq!("hello".rfind('l'), Some(3u));
1400-
assert_eq!("hello".rfind(|&: c:char| c == 'o'), Some(4u));
1400+
assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4u));
14011401
assert!("hello".rfind('x').is_none());
1402-
assert!("hello".rfind(|&: c:char| c == 'x').is_none());
1402+
assert!("hello".rfind(|c:char| c == 'x').is_none());
14031403
assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u));
1404-
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|&: c: char| c == '华'), Some(30u));
1404+
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u));
14051405
}
14061406

14071407
#[test]
@@ -1723,7 +1723,7 @@ mod tests {
17231723
assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
17241724
let chars: &[char] = &['1', '2'];
17251725
assert_eq!("12foo1bar12".trim_left_matches(chars), "foo1bar12");
1726-
assert_eq!("123foo1bar123".trim_left_matches(|&: c: char| c.is_numeric()), "foo1bar123");
1726+
assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
17271727
}
17281728

17291729
#[test]
@@ -1738,7 +1738,7 @@ mod tests {
17381738
assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
17391739
let chars: &[char] = &['1', '2'];
17401740
assert_eq!("12foo1bar12".trim_right_matches(chars), "12foo1bar");
1741-
assert_eq!("123foo1bar123".trim_right_matches(|&: c: char| c.is_numeric()), "123foo1bar");
1741+
assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
17421742
}
17431743

17441744
#[test]
@@ -1753,7 +1753,7 @@ mod tests {
17531753
assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
17541754
let chars: &[char] = &['1', '2'];
17551755
assert_eq!("12foo1bar12".trim_matches(chars), "foo1bar");
1756-
assert_eq!("123foo1bar123".trim_matches(|&: c: char| c.is_numeric()), "foo1bar");
1756+
assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
17571757
}
17581758

17591759
#[test]
@@ -2222,14 +2222,14 @@ mod tests {
22222222
let split: Vec<&str> = data.splitn(3, ' ').collect();
22232223
assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
22242224

2225-
let split: Vec<&str> = data.splitn(3, |&: c: char| c == ' ').collect();
2225+
let split: Vec<&str> = data.splitn(3, |c: char| c == ' ').collect();
22262226
assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
22272227

22282228
// Unicode
22292229
let split: Vec<&str> = data.splitn(3, 'ä').collect();
22302230
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
22312231

2232-
let split: Vec<&str> = data.splitn(3, |&: c: char| c == 'ä').collect();
2232+
let split: Vec<&str> = data.splitn(3, |c: char| c == 'ä').collect();
22332233
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
22342234
}
22352235

@@ -2940,7 +2940,7 @@ mod bench {
29402940
let s = "Mary had a little lamb, Little lamb, little-lamb.";
29412941
let len = s.split(' ').count();
29422942

2943-
b.iter(|| assert_eq!(s.split(|&: c: char| c == ' ').count(), len));
2943+
b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
29442944
}
29452945

29462946
#[bench]

src/libcore/finally.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//!
2424
//! use std::finally::Finally;
2525
//!
26-
//! (|&mut:| {
26+
//! (|| {
2727
//! // ...
2828
//! }).finally(|| {
2929
//! // this code is always run

src/libcore/fmt/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
225225
// cut off the one extra digit, and depending on its value
226226
// round the remaining ones.
227227
if limit_digits && dig == digit_count {
228-
let ascii2value = |&: chr: u8| {
228+
let ascii2value = |chr: u8| {
229229
(chr as char).to_digit(radix).unwrap()
230230
};
231-
let value2ascii = |&: val: uint| {
231+
let value2ascii = |val: uint| {
232232
char::from_digit(val, radix).unwrap() as u8
233233
};
234234

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ impl<'a> Formatter<'a> {
483483
}
484484

485485
// Writes the sign if it exists, and then the prefix if it was requested
486-
let write_prefix = |&: f: &mut Formatter| {
486+
let write_prefix = |f: &mut Formatter| {
487487
if let Some(c) = sign {
488488
let mut b = [0; 4];
489489
let n = c.encode_utf8(&mut b).unwrap_or(0);

src/libcore/str/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,11 +1518,11 @@ impl StrExt for str {
15181518

15191519
#[inline]
15201520
fn trim_matches<P: CharEq>(&self, mut pat: P) -> &str {
1521-
let cur = match self.find(|&mut: c: char| !pat.matches(c)) {
1521+
let cur = match self.find(|c: char| !pat.matches(c)) {
15221522
None => "",
15231523
Some(i) => unsafe { self.slice_unchecked(i, self.len()) }
15241524
};
1525-
match cur.rfind(|&mut: c: char| !pat.matches(c)) {
1525+
match cur.rfind(|c: char| !pat.matches(c)) {
15261526
None => "",
15271527
Some(i) => {
15281528
let right = cur.char_range_at(i).next;
@@ -1533,15 +1533,15 @@ impl StrExt for str {
15331533

15341534
#[inline]
15351535
fn trim_left_matches<P: CharEq>(&self, mut pat: P) -> &str {
1536-
match self.find(|&mut: c: char| !pat.matches(c)) {
1536+
match self.find(|c: char| !pat.matches(c)) {
15371537
None => "",
15381538
Some(first) => unsafe { self.slice_unchecked(first, self.len()) }
15391539
}
15401540
}
15411541

15421542
#[inline]
15431543
fn trim_right_matches<P: CharEq>(&self, mut pat: P) -> &str {
1544-
match self.rfind(|&mut: c: char| !pat.matches(c)) {
1544+
match self.rfind(|c: char| !pat.matches(c)) {
15451545
None => "",
15461546
Some(last) => {
15471547
let next = self.char_range_at(last).next;

src/libcoretest/finally.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ fn test_fail() {
4747

4848
#[test]
4949
fn test_retval() {
50-
let mut closure = |&mut:| 10;
51-
let i = closure.finally(|| { });
50+
let mut closure = || 10;
51+
// FIXME(#16640) `: i32` annotation shouldn't be necessary
52+
let i: i32 = closure.finally(|| { });
5253
assert_eq!(i, 10);
5354
}
5455

src/libcoretest/str.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn test_rsplitn_char_iterator() {
5454
split.reverse();
5555
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
5656

57-
let mut split: Vec<&str> = data.rsplitn(3, |&: c: char| c == ' ').collect();
57+
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == ' ').collect();
5858
split.reverse();
5959
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
6060

@@ -63,7 +63,7 @@ fn test_rsplitn_char_iterator() {
6363
split.reverse();
6464
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
6565

66-
let mut split: Vec<&str> = data.rsplitn(3, |&: c: char| c == 'ä').collect();
66+
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == 'ä').collect();
6767
split.reverse();
6868
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
6969
}
@@ -79,10 +79,10 @@ fn test_split_char_iterator() {
7979
rsplit.reverse();
8080
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
8181

82-
let split: Vec<&str> = data.split(|&: c: char| c == ' ').collect();
82+
let split: Vec<&str> = data.split(|c: char| c == ' ').collect();
8383
assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
8484

85-
let mut rsplit: Vec<&str> = data.split(|&: c: char| c == ' ').rev().collect();
85+
let mut rsplit: Vec<&str> = data.split(|c: char| c == ' ').rev().collect();
8686
rsplit.reverse();
8787
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
8888

@@ -94,10 +94,10 @@ fn test_split_char_iterator() {
9494
rsplit.reverse();
9595
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
9696

97-
let split: Vec<&str> = data.split(|&: c: char| c == 'ä').collect();
97+
let split: Vec<&str> = data.split(|c: char| c == 'ä').collect();
9898
assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
9999

100-
let mut rsplit: Vec<&str> = data.split(|&: c: char| c == 'ä').rev().collect();
100+
let mut rsplit: Vec<&str> = data.split(|c: char| c == 'ä').rev().collect();
101101
rsplit.reverse();
102102
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
103103
}

src/libgetopts/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
889889
lim = fake_i;
890890
}
891891

892-
let mut machine = |&mut: cont: &mut bool, (i, c): (uint, char)| -> bool {
892+
let mut machine = |cont: &mut bool, (i, c): (uint, char)| -> bool {
893893
let whitespace = if c.is_whitespace() { Ws } else { Cr };
894894
let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim };
895895

src/liblog/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ fn init() {
428428
DIRECTIVES = mem::transmute(box directives);
429429

430430
// Schedule the cleanup for the globals for when the runtime exits.
431-
rt::at_exit(move |:| {
431+
rt::at_exit(move || {
432432
assert!(!DIRECTIVES.is_null());
433433
let _directives: Box<Vec<directive::LogDirective>> =
434434
mem::transmute(DIRECTIVES);

0 commit comments

Comments
 (0)