Auto merge of #21843 - japaric:kindless, r=alexcrichton

This needs a snapshot that includes #21805 before it can be merged.

There are some places where type inference regressed after I removed the annotations (see `FIXME`s). cc @nikomatsakis.

r? @eddyb or anyone
(I'll remove the `FIXME`s before merging, as they are only intended to point out regressions)
This commit is contained in:
bors 2015-02-05 15:22:48 +00:00
commit 2c05354211
198 changed files with 408 additions and 395 deletions

View File

@ -359,7 +359,7 @@ pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::Test
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_string();
test::DynMetricFn(box move |: mm: &mut test::MetricMap| {
test::DynMetricFn(box move |mm: &mut test::MetricMap| {
runtest::run_metrics(config, testfile, mm)
})
}

View File

@ -199,7 +199,7 @@ impl<'a> Iterator for Decompositions<'a> {
let buffer = &mut self.buffer;
let sorted = &mut self.sorted;
{
let callback = |&mut: d| {
let callback = |d| {
let class =
unicode::char::canonical_combining_class(d);
if class == 0 && !*sorted {
@ -592,7 +592,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect();
/// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]);
///
/// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).collect();
/// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).collect();
/// assert_eq!(v, vec!["abc", "def", "ghi"]);
///
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
@ -616,7 +616,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// let v: Vec<&str> = "Mary had a little lambda".splitn(2, ' ').collect();
/// assert_eq!(v, vec!["Mary", "had", "a little lambda"]);
///
/// let v: Vec<&str> = "abc1def2ghi".splitn(1, |&: c: char| c.is_numeric()).collect();
/// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_numeric()).collect();
/// assert_eq!(v, vec!["abc", "def2ghi"]);
///
/// let v: Vec<&str> = "lionXXtigerXleopard".splitn(2, 'X').collect();
@ -651,7 +651,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// let v: Vec<&str> = "Mary had a little lamb".split(' ').rev().collect();
/// assert_eq!(v, vec!["lamb", "little", "a", "had", "Mary"]);
///
/// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).rev().collect();
/// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).rev().collect();
/// assert_eq!(v, vec!["ghi", "def", "abc"]);
///
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').rev().collect();
@ -672,7 +672,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
/// assert_eq!(v, vec!["lamb", "little", "Mary had a"]);
///
/// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |&: c: char| c.is_numeric()).collect();
/// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_numeric()).collect();
/// assert_eq!(v, vec!["ghi", "abc1def"]);
///
/// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
@ -853,7 +853,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_matches(x), "foo1bar");
/// assert_eq!("123foo1bar123".trim_matches(|&: c: char| c.is_numeric()), "foo1bar");
/// assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
@ -873,7 +873,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_left_matches(x), "foo1bar12");
/// assert_eq!("123foo1bar123".trim_left_matches(|&: c: char| c.is_numeric()), "foo1bar123");
/// assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
@ -893,7 +893,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_right_matches(x), "12foo1bar");
/// assert_eq!("123foo1bar123".trim_right_matches(|&: c: char| c.is_numeric()), "123foo1bar");
/// assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str {
@ -1066,7 +1066,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// assert_eq!(s.find('é'), Some(14));
///
/// // the first space
/// assert_eq!(s.find(|&: c: char| c.is_whitespace()), Some(5));
/// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5));
///
/// // neither are found
/// let x: &[_] = &['1', '2'];
@ -1094,7 +1094,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// assert_eq!(s.rfind('é'), Some(14));
///
/// // the second space
/// assert_eq!(s.rfind(|&: c: char| c.is_whitespace()), Some(12));
/// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12));
///
/// // searches for an occurrence of either `1` or `2`, but neither are found
/// let x: &[_] = &['1', '2'];
@ -1387,21 +1387,21 @@ mod tests {
#[test]
fn test_find() {
assert_eq!("hello".find('l'), Some(2u));
assert_eq!("hello".find(|&: c:char| c == 'o'), Some(4u));
assert_eq!("hello".find(|c:char| c == 'o'), Some(4u));
assert!("hello".find('x').is_none());
assert!("hello".find(|&: c:char| c == 'x').is_none());
assert!("hello".find(|c:char| c == 'x').is_none());
assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u));
assert_eq!("ประเทศไทย中华Việt Nam".find(|&: c: char| c == '华'), Some(30u));
assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u));
}
#[test]
fn test_rfind() {
assert_eq!("hello".rfind('l'), Some(3u));
assert_eq!("hello".rfind(|&: c:char| c == 'o'), Some(4u));
assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4u));
assert!("hello".rfind('x').is_none());
assert!("hello".rfind(|&: c:char| c == 'x').is_none());
assert!("hello".rfind(|c:char| c == 'x').is_none());
assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u));
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|&: c: char| c == '华'), Some(30u));
assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u));
}
#[test]
@ -1723,7 +1723,7 @@ mod tests {
assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
let chars: &[char] = &['1', '2'];
assert_eq!("12foo1bar12".trim_left_matches(chars), "foo1bar12");
assert_eq!("123foo1bar123".trim_left_matches(|&: c: char| c.is_numeric()), "foo1bar123");
assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
}
#[test]
@ -1738,7 +1738,7 @@ mod tests {
assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
let chars: &[char] = &['1', '2'];
assert_eq!("12foo1bar12".trim_right_matches(chars), "12foo1bar");
assert_eq!("123foo1bar123".trim_right_matches(|&: c: char| c.is_numeric()), "123foo1bar");
assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
}
#[test]
@ -1753,7 +1753,7 @@ mod tests {
assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
let chars: &[char] = &['1', '2'];
assert_eq!("12foo1bar12".trim_matches(chars), "foo1bar");
assert_eq!("123foo1bar123".trim_matches(|&: c: char| c.is_numeric()), "foo1bar");
assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
}
#[test]
@ -2222,14 +2222,14 @@ mod tests {
let split: Vec<&str> = data.splitn(3, ' ').collect();
assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
let split: Vec<&str> = data.splitn(3, |&: c: char| c == ' ').collect();
let split: Vec<&str> = data.splitn(3, |c: char| c == ' ').collect();
assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
// Unicode
let split: Vec<&str> = data.splitn(3, 'ä').collect();
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
let split: Vec<&str> = data.splitn(3, |&: c: char| c == 'ä').collect();
let split: Vec<&str> = data.splitn(3, |c: char| c == 'ä').collect();
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
}
@ -2940,7 +2940,7 @@ mod bench {
let s = "Mary had a little lamb, Little lamb, little-lamb.";
let len = s.split(' ').count();
b.iter(|| assert_eq!(s.split(|&: c: char| c == ' ').count(), len));
b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
}
#[bench]

View File

@ -23,7 +23,7 @@
//!
//! use std::finally::Finally;
//!
//! (|&mut:| {
//! (|| {
//! // ...
//! }).finally(|| {
//! // this code is always run

View File

@ -225,10 +225,10 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
// cut off the one extra digit, and depending on its value
// round the remaining ones.
if limit_digits && dig == digit_count {
let ascii2value = |&: chr: u8| {
let ascii2value = |chr: u8| {
(chr as char).to_digit(radix).unwrap()
};
let value2ascii = |&: val: uint| {
let value2ascii = |val: uint| {
char::from_digit(val, radix).unwrap() as u8
};

View File

@ -483,7 +483,7 @@ impl<'a> Formatter<'a> {
}
// Writes the sign if it exists, and then the prefix if it was requested
let write_prefix = |&: f: &mut Formatter| {
let write_prefix = |f: &mut Formatter| {
if let Some(c) = sign {
let mut b = [0; 4];
let n = c.encode_utf8(&mut b).unwrap_or(0);

View File

@ -1518,11 +1518,11 @@ impl StrExt for str {
#[inline]
fn trim_matches<P: CharEq>(&self, mut pat: P) -> &str {
let cur = match self.find(|&mut: c: char| !pat.matches(c)) {
let cur = match self.find(|c: char| !pat.matches(c)) {
None => "",
Some(i) => unsafe { self.slice_unchecked(i, self.len()) }
};
match cur.rfind(|&mut: c: char| !pat.matches(c)) {
match cur.rfind(|c: char| !pat.matches(c)) {
None => "",
Some(i) => {
let right = cur.char_range_at(i).next;
@ -1533,7 +1533,7 @@ impl StrExt for str {
#[inline]
fn trim_left_matches<P: CharEq>(&self, mut pat: P) -> &str {
match self.find(|&mut: c: char| !pat.matches(c)) {
match self.find(|c: char| !pat.matches(c)) {
None => "",
Some(first) => unsafe { self.slice_unchecked(first, self.len()) }
}
@ -1541,7 +1541,7 @@ impl StrExt for str {
#[inline]
fn trim_right_matches<P: CharEq>(&self, mut pat: P) -> &str {
match self.rfind(|&mut: c: char| !pat.matches(c)) {
match self.rfind(|c: char| !pat.matches(c)) {
None => "",
Some(last) => {
let next = self.char_range_at(last).next;

View File

@ -47,8 +47,9 @@ fn test_fail() {
#[test]
fn test_retval() {
let mut closure = |&mut:| 10;
let i = closure.finally(|| { });
let mut closure = || 10;
// FIXME(#16640) `: i32` annotation shouldn't be necessary
let i: i32 = closure.finally(|| { });
assert_eq!(i, 10);
}

View File

@ -54,7 +54,7 @@ fn test_rsplitn_char_iterator() {
split.reverse();
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
let mut split: Vec<&str> = data.rsplitn(3, |&: c: char| c == ' ').collect();
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == ' ').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
@ -63,7 +63,7 @@ fn test_rsplitn_char_iterator() {
split.reverse();
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
let mut split: Vec<&str> = data.rsplitn(3, |&: c: char| c == 'ä').collect();
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == 'ä').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
}
@ -79,10 +79,10 @@ fn test_split_char_iterator() {
rsplit.reverse();
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let split: Vec<&str> = data.split(|&: c: char| c == ' ').collect();
let split: Vec<&str> = data.split(|c: char| c == ' ').collect();
assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let mut rsplit: Vec<&str> = data.split(|&: c: char| c == ' ').rev().collect();
let mut rsplit: Vec<&str> = data.split(|c: char| c == ' ').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
@ -94,10 +94,10 @@ fn test_split_char_iterator() {
rsplit.reverse();
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let split: Vec<&str> = data.split(|&: c: char| c == 'ä').collect();
let split: Vec<&str> = data.split(|c: char| c == 'ä').collect();
assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let mut rsplit: Vec<&str> = data.split(|&: c: char| c == 'ä').rev().collect();
let mut rsplit: Vec<&str> = data.split(|c: char| c == 'ä').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
}

View File

@ -889,7 +889,7 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
lim = fake_i;
}
let mut machine = |&mut: cont: &mut bool, (i, c): (uint, char)| -> bool {
let mut machine = |cont: &mut bool, (i, c): (uint, char)| -> bool {
let whitespace = if c.is_whitespace() { Ws } else { Cr };
let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim };

View File

@ -428,7 +428,7 @@ fn init() {
DIRECTIVES = mem::transmute(box directives);
// Schedule the cleanup for the globals for when the runtime exits.
rt::at_exit(move |:| {
rt::at_exit(move || {
assert!(!DIRECTIVES.is_null());
let _directives: Box<Vec<directive::LogDirective>> =
mem::transmute(DIRECTIVES);

View File

@ -949,7 +949,7 @@ impl NonSnakeCase {
fn to_snake_case(mut str: &str) -> String {
let mut words = vec![];
// Preserve leading underscores
str = str.trim_left_matches(|&mut: c: char| {
str = str.trim_left_matches(|c: char| {
if c == '_' {
words.push(String::new());
true

View File

@ -72,7 +72,7 @@ struct CrateInfo {
}
pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
let err = |&: s: &str| {
let err = |s: &str| {
match (sp, sess) {
(_, None) => panic!("{}", s),
(Some(sp), Some(sess)) => sess.span_err(sp, s),

View File

@ -59,7 +59,7 @@ pub fn each_child_of_item<F>(cstore: &cstore::CStore,
F: FnMut(decoder::DefLike, ast::Name, ast::Visibility),
{
let crate_data = cstore.get_crate_data(def_id.krate);
let get_crate_data = |&mut: cnum| {
let get_crate_data = |cnum| {
cstore.get_crate_data(cnum)
};
decoder::each_child_of_item(cstore.intr.clone(),
@ -76,7 +76,7 @@ pub fn each_top_level_item_of_crate<F>(cstore: &cstore::CStore,
F: FnMut(decoder::DefLike, ast::Name, ast::Visibility),
{
let crate_data = cstore.get_crate_data(cnum);
let get_crate_data = |&mut: cnum| {
let get_crate_data = |cnum| {
cstore.get_crate_data(cnum)
};
decoder::each_top_level_item_of_crate(cstore.intr.clone(),

View File

@ -1409,7 +1409,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_parent_sort(rbml_w, 't');
let trait_item = &ms[i];
let encode_trait_item = |&: rbml_w: &mut Encoder| {
let encode_trait_item = |rbml_w: &mut Encoder| {
// If this is a static method, we've already
// encoded this.
if is_nonstatic_method {

View File

@ -138,7 +138,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) {
ast::ExprBlock(ref block) => {
// Check all statements in the block
for stmt in &block.stmts {
let block_span_err = |&: span|
let block_span_err = |span|
span_err!(v.tcx.sess, span, E0016,
"blocks in constants are limited to items and \
tail expressions");

View File

@ -1024,7 +1024,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
})
}
let check_move = |&: p: &Pat, sub: Option<&Pat>| {
let check_move = |p: &Pat, sub: Option<&Pat>| {
// check legality of moving out of the enum
// x @ Foo(..) is legal, but x @ Foo(y) isn't.

View File

@ -135,7 +135,7 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
let mut i = 0;
let mut node_ids = FnvHashMap();
{
let mut add_node = |&mut : node| {
let mut add_node = |node| {
if let Vacant(e) = node_ids.entry(node) {
e.insert(i);
i += 1;

View File

@ -666,7 +666,7 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
{
let region_maps = &mut visitor.region_maps;
let terminating = |&: id| {
let terminating = |id| {
let scope = CodeExtent::from_node_id(id);
region_maps.mark_as_terminating_scope(scope)
};

View File

@ -6087,7 +6087,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
macro_rules! byte { ($b:expr) => { ($b as u8).hash(state) } }
macro_rules! hash { ($e:expr) => { $e.hash(state) } }
let region = |&: state: &mut SipHasher, r: Region| {
let region = |state: &mut SipHasher, r: Region| {
match r {
ReStatic => {}
ReLateBound(db, BrAnon(i)) => {
@ -6104,7 +6104,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
}
}
};
let did = |&: state: &mut SipHasher, did: DefId| {
let did = |state: &mut SipHasher, did: DefId| {
let h = if ast_util::is_local(did) {
svh.clone()
} else {
@ -6113,10 +6113,10 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
h.as_str().hash(state);
did.node.hash(state);
};
let mt = |&: state: &mut SipHasher, mt: mt| {
let mt = |state: &mut SipHasher, mt: mt| {
mt.mutbl.hash(state);
};
let fn_sig = |&: state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
let fn_sig = |state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
let sig = anonymize_late_bound_regions(tcx, sig).0;
for a in &sig.inputs { helper(tcx, *a, svh, state); }
if let ty::FnConverging(output) = sig.output {

View File

@ -187,8 +187,8 @@ pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
/// ```
/// pub fn memoized<T: Clone, U: Clone, M: MutableMap<T, U>>(
/// cache: &RefCell<M>,
/// f: &|&: T| -> U
/// ) -> impl |&: T| -> U {
/// f: &|T| -> U
/// ) -> impl |T| -> U {
/// ```
/// but currently it is not possible.
///

View File

@ -86,7 +86,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
return match region {
ReScope(scope) => {
let new_string;
let on_unknown_scope = |&:| {
let on_unknown_scope = || {
(format!("unknown scope: {:?}. Please report a bug.", scope), None)
};
let span = match scope.span(&cx.map) {

View File

@ -227,7 +227,7 @@ impl Target {
let handler = diagnostic::default_handler(diagnostic::Auto, None, true);
let get_req_field = |&: name: &str| {
let get_req_field = |name: &str| {
match obj.find(name)
.map(|s| s.as_string())
.and_then(|os| os.map(|s| s.to_string())) {

View File

@ -43,7 +43,7 @@ enum Fragment {
impl Fragment {
fn loan_path_repr<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String {
let repr = |&: mpi| move_data.path_loan_path(mpi).repr(tcx);
let repr = |mpi| move_data.path_loan_path(mpi).repr(tcx);
match *self {
Just(mpi) => repr(mpi),
AllButOneFrom(mpi) => format!("$(allbutone {})", repr(mpi)),
@ -53,7 +53,7 @@ impl Fragment {
fn loan_path_user_string<'tcx>(&self,
move_data: &MoveData<'tcx>,
tcx: &ty::ctxt<'tcx>) -> String {
let user_string = |&: mpi| move_data.path_loan_path(mpi).user_string(tcx);
let user_string = |mpi| move_data.path_loan_path(mpi).user_string(tcx);
match *self {
Just(mpi) => user_string(mpi),
AllButOneFrom(mpi) => format!("$(allbutone {})", user_string(mpi)),
@ -139,9 +139,9 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
if !span_err && !print { return; }
let instrument_all_paths = |&: kind, vec_rc: &Vec<MovePathIndex>| {
let instrument_all_paths = |kind, vec_rc: &Vec<MovePathIndex>| {
for (i, mpi) in vec_rc.iter().enumerate() {
let render = |&:| this.path_loan_path(*mpi).user_string(tcx);
let render = || this.path_loan_path(*mpi).user_string(tcx);
if span_err {
tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())[]);
}
@ -151,9 +151,9 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
}
};
let instrument_all_fragments = |&: kind, vec_rc: &Vec<Fragment>| {
let instrument_all_fragments = |kind, vec_rc: &Vec<Fragment>| {
for (i, f) in vec_rc.iter().enumerate() {
let render = |&:| f.loan_path_user_string(this, tcx);
let render = || f.loan_path_user_string(this, tcx);
if span_err {
tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())[]);
}
@ -186,11 +186,11 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
let mut moved = mem::replace(&mut fragments.moved_leaf_paths, vec![]);
let mut assigned = mem::replace(&mut fragments.assigned_leaf_paths, vec![]);
let path_lps = |&: mpis: &[MovePathIndex]| -> Vec<String> {
let path_lps = |mpis: &[MovePathIndex]| -> Vec<String> {
mpis.iter().map(|mpi| this.path_loan_path(*mpi).repr(tcx)).collect()
};
let frag_lps = |&: fs: &[Fragment]| -> Vec<String> {
let frag_lps = |fs: &[Fragment]| -> Vec<String> {
fs.iter().map(|f| f.loan_path_repr(this, tcx)).collect()
};
@ -343,7 +343,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
Rc<LoanPath<'tcx>>)>) {
let parent_ty = parent_lp.to_type();
let mut add_fragment_sibling_local = |&mut : field_name, variant_did| {
let mut add_fragment_sibling_local = |field_name, variant_did| {
add_fragment_sibling_core(
this, tcx, gathered_fragments, parent_lp.clone(), mc, field_name, origin_lp,
variant_did);

View File

@ -58,7 +58,7 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
cmt: mc::cmt<'tcx>) -> RestrictionResult<'tcx> {
debug!("restrict(cmt={})", cmt.repr(self.bccx.tcx));
let new_lp = |&: v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
match cmt.cat.clone() {
mc::cat_rvalue(..) => {

View File

@ -422,7 +422,7 @@ pub fn opt_loan_path<'tcx>(cmt: &mc::cmt<'tcx>) -> Option<Rc<LoanPath<'tcx>>> {
//! which allows it to share common loan path pieces as it
//! traverses the CMT.
let new_lp = |&: v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
match cmt.cat {
mc::cat_rvalue(..) |

View File

@ -99,7 +99,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
fn dataflow_loans_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
let dfcx = &self.analysis_data.loans;
let loan_index_to_path = |&mut: loan_index| {
let loan_index_to_path = |loan_index| {
let all_loans = &self.analysis_data.all_loans;
let l: &borrowck::Loan = &all_loans[loan_index];
l.loan_path()
@ -109,7 +109,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
fn dataflow_moves_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
let dfcx = &self.analysis_data.move_data.dfcx_moves;
let move_index_to_path = |&mut: move_index| {
let move_index_to_path = |move_index| {
let move_data = &self.analysis_data.move_data.move_data;
let moves = move_data.moves.borrow();
let the_move: &borrowck::move_data::Move = &(*moves)[move_index];
@ -120,7 +120,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
fn dataflow_assigns_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
let dfcx = &self.analysis_data.move_data.dfcx_assign;
let assign_index_to_path = |&mut: assign_index| {
let assign_index_to_path = |assign_index| {
let move_data = &self.analysis_data.move_data.move_data;
let assignments = move_data.var_assignments.borrow();
let assignment: &borrowck::move_data::Assignment = &(*assignments)[assign_index];

View File

@ -214,7 +214,7 @@ impl<'a> PhaseController<'a> {
pub fn basic() -> PhaseController<'a> {
PhaseController {
stop: false,
callback: box |&: _| {},
callback: box |_| {},
}
}
}
@ -794,7 +794,7 @@ fn write_out_deps(sess: &Session,
_ => return,
};
let result = (|&:| -> old_io::IoResult<()> {
let result = (|| -> old_io::IoResult<()> {
// Build a list of files used to compile the output and
// write Makefile-compatible dependency rules
let files: Vec<String> = sess.codemap().files.borrow()

View File

@ -93,7 +93,7 @@ pub mod driver;
pub mod pretty;
pub fn run(args: Vec<String>) -> int {
monitor(move |:| run_compiler(args.as_slice()));
monitor(move || run_compiler(args.as_slice()));
0
}
@ -362,7 +362,7 @@ Available lint options:
let max_name_len = plugin.iter().chain(builtin.iter())
.map(|&s| s.name.width(true))
.max().unwrap_or(0);
let padded = |&: x: &str| {
let padded = |x: &str| {
let mut s = repeat(" ").take(max_name_len - x.chars().count())
.collect::<String>();
s.push_str(x);
@ -373,7 +373,7 @@ Available lint options:
println!(" {} {:7.7} {}", padded("name"), "default", "meaning");
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
let print_lints = |&: lints: Vec<&Lint>| {
let print_lints = |lints: Vec<&Lint>| {
for lint in lints {
let name = lint.name_lower().replace("_", "-");
println!(" {} {:7.7} {}",
@ -389,7 +389,7 @@ Available lint options:
let max_name_len = plugin_groups.iter().chain(builtin_groups.iter())
.map(|&(s, _)| s.width(true))
.max().unwrap_or(0);
let padded = |&: x: &str| {
let padded = |x: &str| {
let mut s = repeat(" ").take(max_name_len - x.chars().count())
.collect::<String>();
s.push_str(x);
@ -400,7 +400,7 @@ Available lint options:
println!(" {} {}", padded("name"), "sub-lints");
println!(" {} {}", padded("----"), "---------");
let print_lint_groups = |&: lints: Vec<(&'static str, Vec<lint::LintId>)>| {
let print_lint_groups = |lints: Vec<(&'static str, Vec<lint::LintId>)>| {
for (name, to) in lints {
let name = name.chars().map(|x| x.to_lowercase())
.collect::<String>().replace("_", "-");

View File

@ -388,7 +388,7 @@ impl UserIdentifiedItem {
}
fn to_one_node_id(self, user_option: &str, sess: &Session, map: &ast_map::Map) -> ast::NodeId {
let fail_because = |&: is_wrong_because| -> ast::NodeId {
let fail_because = |is_wrong_because| -> ast::NodeId {
let message =
format!("{} needs NodeId (int) or unique \
path suffix (b::c::d); got {}, which {}",

View File

@ -719,8 +719,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
debug!("privacy - path {}", self.nodestr(path_id));
let orig_def = self.tcx.def_map.borrow()[path_id].clone();
let ck = |&: tyname: &str| {
let ck_public = |&: def: ast::DefId| {
let ck = |tyname: &str| {
let ck_public = |def: ast::DefId| {
debug!("privacy - ck_public {:?}", def);
let name = token::get_ident(path.segments.last().unwrap().identifier);
let origdid = orig_def.def_id();
@ -924,7 +924,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
}
ast::ExprPath(_) | ast::ExprQPath(_) => {
let guard = |&: did: ast::DefId| {
let guard = |did: ast::DefId| {
let fields = ty::lookup_struct_fields(self.tcx, did);
let any_priv = fields.iter().any(|f| {
f.vis != ast::Public && (
@ -1076,7 +1076,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
/// later on down the road...
fn check_sane_privacy(&self, item: &ast::Item) {
let tcx = self.tcx;
let check_inherited = |&: sp: Span, vis: ast::Visibility, note: &str| {
let check_inherited = |sp: Span, vis: ast::Visibility, note: &str| {
if vis != ast::Inherited {
tcx.sess.span_err(sp, "unnecessary visibility qualifier");
if note.len() > 0 {
@ -1156,7 +1156,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
tcx.sess.span_err(sp, "visibility has no effect inside functions");
}
}
let check_struct = |&: def: &ast::StructDef| {
let check_struct = |def: &ast::StructDef| {
for f in &def.fields {
match f.node.kind {
ast::NamedField(_, p) => check_inherited(tcx, f.span, p),

View File

@ -1475,7 +1475,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let mut import_resolutions = module_.import_resolutions.borrow_mut();
let import_resolution = &mut (*import_resolutions)[target];
{
let mut check_and_write_import = |&mut: namespace, result: &_, used_public: &mut bool| {
let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
let namespace_name = match namespace {
TypeNS => "type",
ValueNS => "value",
@ -1714,7 +1714,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Merge the child item into the import resolution.
{
let mut merge_child_item = |&mut : namespace| {
let mut merge_child_item = |namespace| {
if name_bindings.defined_in_namespace_with(namespace, IMPORTABLE | PUBLIC) {
let namespace_name = match namespace {
TypeNS => "type",

View File

@ -126,7 +126,7 @@ pub const RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET: uint =
pub fn find_crate_name(sess: Option<&Session>,
attrs: &[ast::Attribute],
input: &Input) -> String {
let validate = |&: s: String, span: Option<Span>| {
let validate = |s: String, span: Option<Span>| {
creader::validate_crate_name(sess, &s[], span);
s
};
@ -1006,7 +1006,7 @@ fn link_args(cmd: &mut Command,
if sess.opts.cg.rpath {
let sysroot = sess.sysroot();
let target_triple = &sess.opts.target_triple[];
let get_install_prefix_lib_path = |:| {
let get_install_prefix_lib_path = || {
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
let mut path = Path::new(install_prefix);

View File

@ -439,7 +439,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
// If we're verifying or linting, add them to the function pass
// manager.
let addpass = |&: pass: &str| {
let addpass = |pass: &str| {
let pass = CString::from_slice(pass.as_bytes());
llvm::LLVMRustAddPass(fpm, pass.as_ptr())
};
@ -660,7 +660,7 @@ pub fn run_passes(sess: &Session,
// Produce final compile outputs.
let copy_if_one_unit = |&: ext: &str, output_type: config::OutputType, keep_numbered: bool| {
let copy_if_one_unit = |ext: &str, output_type: config::OutputType, keep_numbered: bool| {
// Three cases:
if sess.opts.cg.codegen_units == 1 {
// 1) Only one codegen unit. In this case it's no difficulty
@ -685,7 +685,7 @@ pub fn run_passes(sess: &Session,
}
};
let link_obj = |&: output_path: &Path| {
let link_obj = |output_path: &Path| {
// Running `ld -r` on a single input is kind of pointless.
if sess.opts.cg.codegen_units == 1 {
fs::copy(&crate_output.with_extension("0.o"),
@ -910,7 +910,7 @@ fn run_work_multithreaded(sess: &Session,
let mut tx = Some(tx);
futures.push(rx);
thread::Builder::new().name(format!("codegen-{}", i)).spawn(move |:| {
thread::Builder::new().name(format!("codegen-{}", i)).spawn(move || {
let diag_handler = mk_handler(true, box diag_emitter);
// Must construct cgcx inside the proc because it has non-Send
@ -1001,7 +1001,7 @@ unsafe fn configure_llvm(sess: &Session) {
let mut llvm_c_strs = Vec::new();
let mut llvm_args = Vec::new();
{
let mut add = |&mut : arg: &str| {
let mut add = |arg: &str| {
let s = CString::from_slice(arg.as_bytes());
llvm_args.push(s.as_ptr());
llvm_c_strs.push(s);

View File

@ -747,7 +747,7 @@ fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<uint> {
}
}
let column_score = |&: m: &[Match], col: uint| -> uint {
let column_score = |m: &[Match], col: uint| -> uint {
let total_score = m.iter()
.map(|row| row.pats[col])
.map(|pat| pat_score(def_map, pat))
@ -761,7 +761,7 @@ fn pick_column_to_specialize(def_map: &DefMap, m: &[Match]) -> Option<uint> {
}
};
let column_contains_any_nonwild_patterns = |&: &col: &uint| -> bool {
let column_contains_any_nonwild_patterns = |&col: &uint| -> bool {
m.iter().any(|row| match row.pats[col].node {
ast::PatWild(_) => false,
_ => true

View File

@ -540,7 +540,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
t: Ty<'tcx>,
op: ast::BinOp_)
-> Result<'blk, 'tcx> {
let f = |&: a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
match t.sty {
ty::ty_tup(ref tys) if tys.is_empty() => f(nil_type),
@ -2757,7 +2757,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
let val = match item {
ast_map::NodeItem(i) => {
let ty = ty::node_id_to_type(ccx.tcx(), i.id);
let sym = |&:| exported_name(ccx, id, ty, &i.attrs[]);
let sym = || exported_name(ccx, id, ty, &i.attrs[]);
let v = match i.node {
ast::ItemStatic(_, _, ref expr) => {
@ -3016,14 +3016,14 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
unsafe {
let mut declared = HashSet::new();
let iter_globals = |&: llmod| {
let iter_globals = |llmod| {
ValueIter {
cur: llvm::LLVMGetFirstGlobal(llmod),
step: llvm::LLVMGetNextGlobal,
}
};
let iter_functions = |&: llmod| {
let iter_functions = |llmod| {
ValueIter {
cur: llvm::LLVMGetFirstFunction(llmod),
step: llvm::LLVMGetNextFunction,

View File

@ -289,7 +289,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
// the bool returned is whether this expression can be inlined into other crates
// if it's assigned to a static.
fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
let map_list = |&: exprs: &[P<ast::Expr>]| {
let map_list = |exprs: &[P<ast::Expr>]| {
exprs.iter().map(|e| const_expr(cx, &**e).0)
.fold(Vec::new(), |mut l, val| { l.push(val); l })
};

View File

@ -2453,7 +2453,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
})
.collect();
let discriminant_type_metadata = |&: inttype| {
let discriminant_type_metadata = |inttype| {
// We can reuse the type of the discriminant for all monomorphized
// instances of an enum because it doesn't depend on any type parameters.
// The def_id, uniquely identifying the enum's polytype acts as key in

View File

@ -350,7 +350,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
debug!("dest_ty={}", unsized_ty.repr(bcx.tcx()));
// Closures for extracting and manipulating the data and payload parts of
// the fat pointer.
let info = |: bcx, _val| unsized_info(bcx,
let info = |bcx, _val| unsized_info(bcx,
k,
expr.id,
datum_ty,
@ -382,8 +382,8 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
-> DatumBlock<'blk, 'tcx, Expr> {
let tcx = bcx.tcx();
let dest_ty = ty::close_type(tcx, datum.ty);
let base = |: bcx, val| Load(bcx, get_dataptr(bcx, val));
let len = |: bcx, val| Load(bcx, get_len(bcx, val));
let base = |bcx, val| Load(bcx, get_dataptr(bcx, val));
let len = |bcx, val| Load(bcx, get_len(bcx, val));
into_fat_ptr(bcx, expr, datum, dest_ty, base, len)
}

View File

@ -431,7 +431,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// ABIs are handled at all correctly.
fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
if !tcx.sess.features.borrow().simd_ffi {
let check = |&: ast_ty: &ast::Ty, ty: ty::Ty| {
let check = |ast_ty: &ast::Ty, ty: ty::Ty| {
if ty::type_is_simd(tcx, ty) {
tcx.sess.span_err(ast_ty.span,
&format!("use of SIMD type `{}` in FFI is highly experimental and \
@ -649,7 +649,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// Array for the arguments we will pass to the rust function.
let mut llrust_args = Vec::new();
let mut next_foreign_arg_counter: c_uint = 0;
let mut next_foreign_arg = |&mut : pad: bool| -> c_uint {
let mut next_foreign_arg = |pad: bool| -> c_uint {
next_foreign_arg_counter += if pad {
2
} else {

View File

@ -183,7 +183,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
// This should be caught by the intrinsicck pass
assert_eq!(in_type_size, out_type_size);
let nonpointer_nonaggregate = |&: llkind: TypeKind| -> bool {
let nonpointer_nonaggregate = |llkind: TypeKind| -> bool {
use llvm::TypeKind::*;
match llkind {
Half | Float | Double | X86_FP80 | FP128 |

View File

@ -139,7 +139,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// This shouldn't need to option dance.
let mut hash_id = Some(hash_id);
let mut mk_lldecl = |&mut : abi: abi::Abi| {
let mut mk_lldecl = |abi: abi::Abi| {
let lldecl = if abi != abi::Rust {
foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, &s[])
} else {
@ -149,7 +149,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
lldecl
};
let setup_lldecl = |&: lldecl, attrs: &[ast::Attribute]| {
let setup_lldecl = |lldecl, attrs: &[ast::Attribute]| {
base::update_linkage(ccx, lldecl, None, base::OriginalTranslation);
set_llvm_fn_attrs(ccx, attrs, lldecl);

View File

@ -342,7 +342,7 @@ pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> {
}
}
let cstore = &ccx.tcx.sess.cstore;
cstore.iter_crate_data(|&mut: cnum, _| {
cstore.iter_crate_data(|cnum, _| {
csearch::each_top_level_item_of_crate(cstore, cnum, |dl, _, _| {
handle_external_def(&mut traits, ccx, cstore, dl)
})

View File

@ -801,7 +801,7 @@ pub fn check_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
generics: &ast::Generics,
item: &ast::Item) {
if let Some(ref attr) = item.attrs.iter().find(|&: a| {
if let Some(ref attr) = item.attrs.iter().find(|a| {
a.check_name("rustc_on_unimplemented")
}) {
if let Some(ref istring) = attr.value_str() {
@ -1715,7 +1715,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let raw_ty = self.expr_ty(expr);
let raw_ty = self.infcx().shallow_resolve(raw_ty);
let resolve_ty = |&: ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
let resolve_ty = |ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
ty::adjust_ty(self.tcx(),
expr.span,
expr.id,

View File

@ -597,7 +597,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
// parameter (by inspecting parent of its binding declaration
// to see if it is introduced by a type or by a fn/impl).
let check_result = |&: this:&ConstraintContext| -> bool {
let check_result = |this:&ConstraintContext| -> bool {
let tcx = this.terms_cx.tcx;
let decl_id = this.find_binding_for_lifetime(param_id);
// Currently only called on lifetimes; double-checking that.

View File

@ -61,7 +61,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
loop {
let next = lexer.next_token();
let snip = |&: sp| sess.span_diagnostic.cm.span_to_snippet(sp).unwrap();
let snip = |sp| sess.span_diagnostic.cm.span_to_snippet(sp).unwrap();
if next.tok == token::Eof { break }

View File

@ -420,7 +420,7 @@ impl LangString {
let mut seen_other_tags = false;
let mut data = LangString::all_false();
let tokens = string.split(|&: c: char|
let tokens = string.split(|c: char|
!(c == '_' || c == '-' || c.is_alphanumeric())
);

View File

@ -365,7 +365,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
let cr = Path::new(cratefile);
info!("starting to run rustc");
let (mut krate, analysis) = std::thread::Thread::scoped(move |:| {
let (mut krate, analysis) = std::thread::Thread::scoped(move || {
use rustc::session::config::Input;
let cr = cr;

View File

@ -148,7 +148,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
let w1 = old_io::ChanWriter::new(tx);
let w2 = w1.clone();
let old = old_io::stdio::set_stderr(box w1);
Thread::spawn(move |:| {
Thread::spawn(move || {
let mut p = old_io::ChanReader::new(rx);
let mut err = match old {
Some(old) => {

View File

@ -321,10 +321,10 @@ pub fn float_to_str_bytes_common<T: Float>(
// cut off the one extra digit, and depending on its value
// round the remaining ones.
if limit_digits && dig == digit_count {
let ascii2value = |&: chr: u8| {
let ascii2value = |chr: u8| {
(chr as char).to_digit(radix).unwrap()
};
let value2ascii = |&: val: uint| {
let value2ascii = |val: uint| {
char::from_digit(val, radix).unwrap() as u8
};

View File

@ -323,25 +323,25 @@ impl<'a> Parser<'a> {
}
fn read_ip_addr(&mut self) -> Option<IpAddr> {
let ipv4_addr = |&mut: p: &mut Parser| p.read_ipv4_addr();
let ipv6_addr = |&mut: p: &mut Parser| p.read_ipv6_addr();
let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr();
let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr();
self.read_or(&mut [box ipv4_addr, box ipv6_addr])
}
fn read_socket_addr(&mut self) -> Option<SocketAddr> {
let ip_addr = |&: p: &mut Parser| {
let ipv4_p = |&mut: p: &mut Parser| p.read_ip_addr();
let ipv6_p = |&mut: p: &mut Parser| {
let open_br = |&: p: &mut Parser| p.read_given_char('[');
let ip_addr = |&: p: &mut Parser| p.read_ipv6_addr();
let clos_br = |&: p: &mut Parser| p.read_given_char(']');
let ip_addr = |p: &mut Parser| {
let ipv4_p = |p: &mut Parser| p.read_ip_addr();
let ipv6_p = |p: &mut Parser| {
let open_br = |p: &mut Parser| p.read_given_char('[');
let ip_addr = |p: &mut Parser| p.read_ipv6_addr();
let clos_br = |p: &mut Parser| p.read_given_char(']');
p.read_seq_3::<char, IpAddr, char, _, _, _>(open_br, ip_addr, clos_br)
.map(|t| match t { (_, ip, _) => ip })
};
p.read_or(&mut [box ipv4_p, box ipv6_p])
};
let colon = |&: p: &mut Parser| p.read_given_char(':');
let port = |&: p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
let colon = |p: &mut Parser| p.read_given_char(':');
let port = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
// host, colon, port
self.read_seq_3::<IpAddr, char, u16, _, _, _>(ip_addr, colon, port)

View File

@ -703,7 +703,7 @@ impl Process {
let (tx, rx) = channel();
match stream {
Some(stream) => {
Thread::spawn(move |:| {
Thread::spawn(move || {
let mut stream = stream;
tx.send(stream.read_to_end()).unwrap();
});

View File

@ -125,7 +125,7 @@ mod imp {
assert!(take() == Some(expected.clone()));
assert!(take() == None);
(|&mut:| {
(|| {
}).finally(|| {
// Restore the actual global state.
match saved_value {

View File

@ -126,7 +126,7 @@ impl<A:Send> Future<A> {
* waiting for the result to be received on the port.
*/
Future::from_fn(move |:| {
Future::from_fn(move || {
rx.recv().unwrap()
})
}
@ -143,7 +143,7 @@ impl<A:Send> Future<A> {
let (tx, rx) = channel();
Thread::spawn(move |:| {
Thread::spawn(move || {
// Don't panic if the other end has hung up
let _ = tx.send(blk());
});

View File

@ -112,7 +112,7 @@ impl TaskPool {
}
fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) {
Thread::spawn(move |:| {
Thread::spawn(move || {
// Will spawn a new thread on panic unless it is cancelled.
let sentinel = Sentinel::new(&jobs);

View File

@ -95,14 +95,14 @@ impl<M: Send> Helper<M> {
let receive = RaceBox(receive);
let t = f();
Thread::spawn(move |:| {
Thread::spawn(move || {
helper(receive.0, rx, t);
let _g = self.lock.lock().unwrap();
*self.shutdown.get() = true;
self.cond.notify_one()
});
rt::at_exit(move|:| { self.shutdown() });
rt::at_exit(move|| { self.shutdown() });
*self.initialized.get() = true;
}
}

View File

@ -723,8 +723,8 @@ impl TcpStream {
pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
let fd = self.fd();
let dolock = |&:| self.lock_nonblocking();
let doread = |&mut: nb| unsafe {
let dolock = || self.lock_nonblocking();
let doread = |nb| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::recv(fd,
buf.as_mut_ptr() as *mut libc::c_void,
@ -736,8 +736,8 @@ impl TcpStream {
pub fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let fd = self.fd();
let dolock = |&:| self.lock_nonblocking();
let dowrite = |&: nb: bool, buf: *const u8, len: uint| unsafe {
let dolock = || self.lock_nonblocking();
let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::send(fd,
buf as *const _,
@ -871,7 +871,7 @@ impl UdpSocket {
let mut addrlen: libc::socklen_t =
mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;
let dolock = |&:| self.lock_nonblocking();
let dolock = || self.lock_nonblocking();
let n = try!(read(fd, self.read_deadline, dolock, |nb| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::recvfrom(fd,
@ -892,8 +892,8 @@ impl UdpSocket {
let dstp = &storage as *const _ as *const libc::sockaddr;
let fd = self.fd();
let dolock = |&: | self.lock_nonblocking();
let dowrite = |&mut: nb, buf: *const u8, len: uint| unsafe {
let dolock = || self.lock_nonblocking();
let dowrite = |nb, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::sendto(fd,
buf as *const libc::c_void,

View File

@ -151,8 +151,8 @@ impl UnixStream {
pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
let fd = self.fd();
let dolock = |&:| self.lock_nonblocking();
let doread = |&mut: nb| unsafe {
let dolock = || self.lock_nonblocking();
let doread = |nb| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::recv(fd,
buf.as_mut_ptr() as *mut libc::c_void,
@ -164,8 +164,8 @@ impl UnixStream {
pub fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let fd = self.fd();
let dolock = |&: | self.lock_nonblocking();
let dowrite = |&: nb: bool, buf: *const u8, len: uint| unsafe {
let dolock = || self.lock_nonblocking();
let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
let flags = if nb {c::MSG_DONTWAIT} else {0};
libc::send(fd,
buf as *const _,

View File

@ -84,8 +84,8 @@ impl Process {
mem::transmute::<&ProcessConfig<K,V>,&'static ProcessConfig<K,V>>(cfg)
};
with_envp(cfg.env(), move|: envp: *const c_void| {
with_argv(cfg.program(), cfg.args(), move|: argv: *const *const libc::c_char| unsafe {
with_envp(cfg.env(), move|envp: *const c_void| {
with_argv(cfg.program(), cfg.args(), move|argv: *const *const libc::c_char| unsafe {
let (input, mut output) = try!(sys::os::pipe());
// We may use this in the child, so perform allocations before the
@ -185,7 +185,7 @@ impl Process {
// up /dev/null into that file descriptor. Otherwise, the first file
// descriptor opened up in the child would be numbered as one of the
// stdio file descriptors, which is likely to wreak havoc.
let setup = |&: src: Option<P>, dst: c_int| {
let setup = |src: Option<P>, dst: c_int| {
let src = match src {
None => {
let flags = if dst == libc::STDIN_FILENO {

View File

@ -169,7 +169,7 @@ impl Process {
// Similarly to unix, we don't actually leave holes for the stdio file
// descriptors, but rather open up /dev/null equivalents. These
// equivalents are drawn from libuv's windows process spawning.
let set_fd = |&: fd: &Option<P>, slot: &mut HANDLE,
let set_fd = |fd: &Option<P>, slot: &mut HANDLE,
is_stdin: bool| {
match *fd {
None => {

View File

@ -246,7 +246,7 @@ impl Builder {
{
let my_packet = Packet(Arc::new(UnsafeCell::new(None)));
let their_packet = Packet(my_packet.0.clone());
let (native, thread) = self.spawn_inner(Thunk::new(f), Thunk::with_arg(move |: ret| unsafe {
let (native, thread) = self.spawn_inner(Thunk::new(f), Thunk::with_arg(move |ret| unsafe {
*their_packet.0.get() = Some(ret);
}));
@ -273,7 +273,7 @@ impl Builder {
// because by the time that this function is executing we've already
// consumed at least a little bit of stack (we don't know the exact byte
// address at which our stack started).
let main = move |:| {
let main = move || {
let something_around_the_top_of_the_stack = 1;
let addr = &something_around_the_top_of_the_stack as *const int;
let my_stack_top = addr as uint;
@ -289,7 +289,7 @@ impl Builder {
let mut output = None;
let f: Thunk<(), T> = if stdout.is_some() || stderr.is_some() {
Thunk::new(move |:| {
Thunk::new(move || {
let _ = stdout.map(stdio::set_stdout);
let _ = stderr.map(stdio::set_stderr);
f.invoke(())

View File

@ -24,7 +24,7 @@ impl<R> Thunk<(),R> {
pub fn new<F>(func: F) -> Thunk<(),R>
where F : FnOnce() -> R, F : Send
{
Thunk::with_arg(move|: ()| func())
Thunk::with_arg(move|()| func())
}
}

View File

@ -179,13 +179,13 @@ impl<'a> FnLikeNode<'a> {
}
pub fn kind(self) -> visit::FnKind<'a> {
let item = |: p: ItemFnParts<'a>| -> visit::FnKind<'a> {
let item = |p: ItemFnParts<'a>| -> visit::FnKind<'a> {
visit::FkItemFn(p.ident, p.generics, p.unsafety, p.abi)
};
let closure = |: _: ClosureParts| {
let closure = |_: ClosureParts| {
visit::FkFnBlock
};
let method = |: m: &'a ast::Method| {
let method = |m: &'a ast::Method| {
visit::FkMethod(m.pe_ident(), m.pe_generics(), m)
};
self.handle(item, method, closure)

View File

@ -63,7 +63,7 @@ fn cs_clone(
cx.ident_of("Clone"),
cx.ident_of("clone"),
];
let subcall = |&: field: &FieldInfo| {
let subcall = |field: &FieldInfo| {
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
cx.expr_call_global(field.span, fn_path.clone(), args)

View File

@ -57,7 +57,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur
cx.ident_of("Default"),
cx.ident_of("default")
);
let default_call = |&: span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
return match *substr.fields {
StaticStruct(_, ref summary) => {

View File

@ -957,7 +957,7 @@ impl<'a> MethodDef<'a> {
// where each tuple has length = self_args.len()
let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
.map(|(index, variant)| {
let mk_self_pat = |&: cx: &mut ExtCtxt, self_arg_name: &str| {
let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident,
&**variant,
self_arg_name,

View File

@ -66,7 +66,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
[ref state_expr] => state_expr,
_ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`")
};
let call_hash = |&: span, thing_expr| {
let call_hash = |span, thing_expr| {
let hash_path = {
let strs = vec![
cx.ident_of("std"),

View File

@ -70,7 +70,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
cx.ident_of("Rand"),
cx.ident_of("rand")
);
let rand_call = |&: cx: &mut ExtCtxt, span| {
let rand_call = |cx: &mut ExtCtxt, span| {
cx.expr_call_global(span,
rand_ident.clone(),
vec!(rng.clone()))

View File

@ -1089,7 +1089,7 @@ fn expand_annotatable(a: Annotatable,
// but that double-mut-borrows fld
let mut items: SmallVector<P<ast::Item>> = SmallVector::zero();
dec.expand(fld.cx, attr.span, &*attr.node.value, &**it,
box |&mut: item| items.push(item));
box |item| items.push(item));
decorator_items.extend(items.into_iter()
.flat_map(|item| expand_item(item, fld).into_iter()));
@ -1850,7 +1850,7 @@ mod test {
assert!((shouldmatch.len() == 0) ||
(varrefs.len() > *shouldmatch.iter().max().unwrap()));
for (idx,varref) in varrefs.iter().enumerate() {
let print_hygiene_debug_info = |&:| {
let print_hygiene_debug_info = || {
// good lord, you can't make a path with 0 segments, can you?
let final_varref_ident = match varref.segments.last() {
Some(pathsegment) => pathsegment.identifier,

View File

@ -307,7 +307,7 @@ impl<'a, 'b> Context<'a, 'b> {
fn trans_count(&self, c: parse::Count) -> P<ast::Expr> {
let sp = self.fmtsp;
let count = |: c, arg| {
let count = |c, arg| {
let mut path = Context::rtpath(self.ecx, "Count");
path.push(self.ecx.ident_of(c));
match arg {
@ -353,7 +353,7 @@ impl<'a, 'b> Context<'a, 'b> {
parse::NextArgument(ref arg) => {
// Translate the position
let pos = {
let pos = |: c, arg| {
let pos = |c, arg| {
let mut path = Context::rtpath(self.ecx, "Position");
path.push(self.ecx.ident_of(c));
match arg {
@ -404,7 +404,7 @@ impl<'a, 'b> Context<'a, 'b> {
// Translate the format
let fill = self.ecx.expr_lit(sp, ast::LitChar(fill));
let align = |:name| {
let align = |name| {
let mut p = Context::rtpath(self.ecx, "Alignment");
p.push(self.ecx.ident_of(name));
self.ecx.path_global(sp, p)

View File

@ -791,11 +791,11 @@ fn expand_parse_call(cx: &ExtCtxt,
tts: &[ast::TokenTree]) -> P<ast::Expr> {
let (cx_expr, tts_expr) = expand_tts(cx, sp, tts);
let cfg_call = |&:| cx.expr_method_call(
let cfg_call = || cx.expr_method_call(
sp, cx.expr_ident(sp, id_ext("ext_cx")),
id_ext("cfg"), Vec::new());
let parse_sess_call = |&:| cx.expr_method_call(
let parse_sess_call = || cx.expr_method_call(
sp, cx.expr_ident(sp, id_ext("ext_cx")),
id_ext("parse_sess"), Vec::new());

View File

@ -244,7 +244,7 @@ pub fn new_parser_from_tts<'a>(sess: &'a ParseSess,
/// add the path to the session's codemap and return the new filemap.
pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
-> Rc<FileMap> {
let err = |&: msg: &str| {
let err = |msg: &str| {
match spanopt {
Some(sp) => sess.span_diagnostic.span_fatal(sp, msg),
None => sess.span_diagnostic.handler().fatal(msg),
@ -406,7 +406,7 @@ pub fn char_lit(lit: &str) -> (char, isize) {
.map(|x| (x, len as isize))
}
let unicode_escape = |&: | -> Option<(char, isize)>
let unicode_escape = || -> Option<(char, isize)>
if lit.as_bytes()[2] == b'{' {
let idx = lit.find('}').expect(msg2);
let subslice = &lit[3..idx];
@ -433,7 +433,7 @@ pub fn str_lit(lit: &str) -> String {
let mut res = String::with_capacity(lit.len());
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
let error = |&: i| format!("lexer should have rejected {} at {}", lit, i);
let error = |i| format!("lexer should have rejected {} at {}", lit, i);
/// Eat everything up to a non-whitespace
fn eat<'a>(it: &mut iter::Peekable<str::CharIndices<'a>>) {
@ -568,7 +568,7 @@ pub fn float_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> a
/// Parse a string representing a byte literal into its final form. Similar to `char_lit`
pub fn byte_lit(lit: &str) -> (u8, usize) {
let err = |&: i| format!("lexer accepted invalid byte literal {} step {}", lit, i);
let err = |i| format!("lexer accepted invalid byte literal {} step {}", lit, i);
if lit.len() == 1 {
(lit.as_bytes()[0], 1)
@ -602,7 +602,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> {
let mut res = Vec::with_capacity(lit.len());
// FIXME #8372: This could be a for-loop if it didn't borrow the iterator
let error = |&: i| format!("lexer should have rejected {} at {}", lit, i);
let error = |i| format!("lexer should have rejected {} at {}", lit, i);
/// Eat everything up to a non-whitespace
fn eat<'a, I: Iterator<Item=(usize, u8)>>(it: &mut iter::Peekable<I>) {

View File

@ -1139,7 +1139,7 @@ impl<'a> Parser<'a> {
/// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
pub fn parse_obsolete_closure_kind(&mut self) {
// let lo = self.span.lo;
let lo = self.span.lo;
if
self.check(&token::BinOp(token::And)) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Mut)) &&
@ -1163,10 +1163,8 @@ impl<'a> Parser<'a> {
return;
}
// SNAP 474b324
// Enable these obsolete errors after snapshot:
// let span = mk_sp(lo, self.span.hi);
// self.obsolete(span, ObsoleteSyntax::ClosureKind);
let span = mk_sp(lo, self.span.hi);
self.obsolete(span, ObsoleteSyntax::ClosureKind);
}
pub fn parse_ty_bare_fn_or_ty_closure(&mut self, lifetime_defs: Vec<LifetimeDef>) -> Ty_ {

View File

@ -609,11 +609,11 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
let test_id = ecx.ident_of("test");
// creates self::test::$name
let test_path = |&: name| {
let test_path = |name| {
ecx.path(span, vec![self_id, test_id, ecx.ident_of(name)])
};
// creates $name: $expr
let field = |&: name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
let field = |name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
debug!("encoding {}", ast_util::path_name_i(&path[]));
@ -627,7 +627,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
vec![name_expr]);
let ignore_expr = ecx.expr_bool(span, test.ignore);
let should_fail_path = |&: name| {
let should_fail_path = |name| {
ecx.path(span, vec![self_id, test_id, ecx.ident_of("ShouldFail"), ecx.ident_of(name)])
};
let fail_expr = match test.should_fail {

View File

@ -89,12 +89,12 @@ impl UnicodeStr for str {
#[inline]
fn trim_left(&self) -> &str {
self.trim_left_matches(|&: c: char| c.is_whitespace())
self.trim_left_matches(|c: char| c.is_whitespace())
}
#[inline]
fn trim_right(&self) -> &str {
self.trim_right_matches(|&: c: char| c.is_whitespace())
self.trim_right_matches(|c: char| c.is_whitespace())
}
}

View File

@ -1,3 +1,12 @@
S 2015-02-04 ac134f7
freebsd-x86_64 483e37a02a7ebc12a872e3146145e342ba4a5c04
linux-i386 8af64e5df839cc945399484380a8b2ebe05a6751
linux-x86_64 9f485d79c1f0d273ed864eddadb1707f3e2df489
macos-i386 800f86abd589a1d46c37a8700211c7ba6b05decb
macos-x86_64 b9961faccf79dcfdc0b7a6909bef8b6769798d08
winnt-i386 2c56a7573f8d0f78271dab1c8e29d3ced7a44ed8
winnt-x86_64 f1736f47de2a6fad1ff881e51c176f71db5dc2a5
S 2015-01-31 474b324
freebsd-x86_64 c5b55eb488790ff8425d74afa3b37c49517bc55f
linux-i386 319f2f3573c058cb2c4dfc75faaf8ea3ae86ef11

View File

@ -12,5 +12,5 @@
#![crate_type = "rlib"]
pub fn inner<F>(f: F) -> F {
(move |:| f)()
(move || f)()
}

View File

@ -12,5 +12,5 @@
pub fn foo<T>() {
fn death() -> int { panic!() }
debug!("{}", (|&:|{ death() })());
debug!("{}", (||{ death() })());
}

View File

@ -15,14 +15,14 @@ use std::ops::Add;
#[inline]
pub fn has_closures() -> uint {
let x = 1u;
let mut f = move |&mut:| x;
let mut f = move || x;
let y = 1u;
let g = |:| y;
let g = || y;
f() + g()
}
pub fn has_generic_closures<T: Add<Output=T> + Copy>(x: T, y: T) -> T {
let mut f = move |&mut:| x;
let g = |:| y;
let mut f = move || x;
let g = || y;
f() + g()
}

View File

@ -251,6 +251,6 @@ fn parallel<'a, I, T, F>(iter: I, f: F)
fn main() {
let mut data = read_to_end(&mut stdin_raw()).unwrap();
let tables = &Tables::new();
parallel(mut_dna_seqs(data.as_mut_slice()), |&: seq| reverse_complement(seq, tables));
parallel(mut_dna_seqs(data.as_mut_slice()), |seq| reverse_complement(seq, tables));
stdout_raw().write(data.as_mut_slice()).unwrap();
}

View File

@ -27,5 +27,5 @@ fn cat(in_x : usize, in_y : isize) -> cat {
fn main() {
let nyan : cat = cat(52us, 99);
nyan.speak = |&:| println!("meow"); //~ ERROR attempted to take value of method
nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
}

View File

@ -13,7 +13,7 @@ mod bar {
}
fn main() {
let foo = |&:| false;
let foo = || false;
use bar::foo;
//~^ ERROR imports are not allowed after non-item statements
assert_eq!(foo(), false);

View File

@ -49,15 +49,15 @@ fn test5(f: &mut Test) {
}
fn test6() {
let mut f = |&mut:| {};
(|&mut:| {
let mut f = || {};
(|| {
f();
})();
}
fn test7() {
fn foo<F>(_: F) where F: FnMut(Box<FnMut(isize)>, isize) {}
let mut f = |&mut: g: Box<FnMut(isize)>, b: isize| {};
let mut f = |g: Box<FnMut(isize)>, b: isize| {};
f(box |a| {
foo(f);
//~^ ERROR cannot move `f` into closure because it is borrowed

View File

@ -23,37 +23,37 @@ fn set(x: &mut isize) {
fn a() {
let mut x = 3;
let c1 = |&mut:| x = 4;
let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
let c1 = || x = 4;
let c2 = || x * 5; //~ ERROR cannot borrow `x`
}
fn b() {
let mut x = 3;
let c1 = |&mut:| set(&mut x);
let c2 = |&mut:| get(&x); //~ ERROR cannot borrow `x`
let c1 = || set(&mut x);
let c2 = || get(&x); //~ ERROR cannot borrow `x`
}
fn c() {
let mut x = 3;
let c1 = |&mut:| set(&mut x);
let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
let c1 = || set(&mut x);
let c2 = || x * 5; //~ ERROR cannot borrow `x`
}
fn d() {
let mut x = 3;
let c2 = |&mut:| x * 5;
let c2 = || x * 5;
x = 5; //~ ERROR cannot assign
}
fn e() {
let mut x = 3;
let c1 = |&mut:| get(&x);
let c1 = || get(&x);
x = 5; //~ ERROR cannot assign
}
fn f() {
let mut x = box 3;
let c1 = |&mut:| get(&*x);
let c1 = || get(&*x);
*x = 5; //~ ERROR cannot assign
}
@ -63,7 +63,7 @@ fn g() {
}
let mut x = box Foo { f: box 3 };
let c1 = |&mut:| get(&*x.f);
let c1 = || get(&*x.f);
*x.f = 5; //~ ERROR cannot assign to `*x.f`
}
@ -73,8 +73,8 @@ fn h() {
}
let mut x = box Foo { f: box 3 };
let c1 = |&mut:| get(&*x.f);
let c2 = |&mut:| *x.f = 5; //~ ERROR cannot borrow `x` as mutable
let c1 = || get(&*x.f);
let c2 = || *x.f = 5; //~ ERROR cannot borrow `x` as mutable
}
fn main() {

View File

@ -20,9 +20,9 @@ fn set(x: &mut isize) {
}
fn a(x: &isize) {
let c1 = |&mut:| set(&mut *x);
let c1 = || set(&mut *x);
//~^ ERROR cannot borrow
let c2 = |&mut:| set(&mut *x);
let c2 = || set(&mut *x);
//~^ ERROR cannot borrow
//~| ERROR closure requires unique access
}

View File

@ -14,10 +14,12 @@
#![feature(box_syntax)]
fn to_fn_mut<F: FnMut()>(f: F) -> F { f }
fn a() {
let mut x = 3;
let c1 = |&mut:| x = 4;
let c2 = |&mut:| x = 5; //~ ERROR cannot borrow `x` as mutable more than once
let c1 = to_fn_mut(|| x = 4);
let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
}
fn set(x: &mut isize) {
@ -26,20 +28,20 @@ fn set(x: &mut isize) {
fn b() {
let mut x = 3;
let c1 = |&mut:| set(&mut x);
let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
let c1 = to_fn_mut(|| set(&mut x));
let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
}
fn c() {
let mut x = 3;
let c1 = |&mut:| x = 5;
let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
let c1 = to_fn_mut(|| x = 5);
let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
}
fn d() {
let mut x = 3;
let c1 = |&mut:| x = 5;
let c2 = |&mut:| { let _y = |&mut:| set(&mut x); }; // (nested closure)
let c1 = to_fn_mut(|| x = 5);
let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
//~^ ERROR cannot borrow `x` as mutable more than once
}
@ -49,8 +51,8 @@ fn g() {
}
let mut x = box Foo { f: box 3 };
let c1 = |&mut:| set(&mut *x.f);
let c2 = |&mut:| set(&mut *x.f);
let c1 = to_fn_mut(|| set(&mut *x.f));
let c2 = to_fn_mut(|| set(&mut *x.f));
//~^ ERROR cannot borrow `x` as mutable more than once
}

View File

@ -16,7 +16,7 @@ pub fn main() {
let mut this = &mut Foo {
x: 1,
};
let mut r = |&mut:| {
let mut r = || {
let p = &this.x;
&mut this.x; //~ ERROR cannot borrow
};

View File

@ -23,27 +23,27 @@ fn set(x: &mut isize) -> isize {
}
fn a(x: &mut isize) {
let c1 = |&mut:| get(x);
let c2 = |&mut:| get(x);
let c1 = || get(x);
let c2 = || get(x);
}
fn b(x: &mut isize) {
let c1 = |&mut:| get(x);
let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
let c1 = || get(x);
let c2 = || set(x); //~ ERROR closure requires unique access to `x`
}
fn c(x: &mut isize) {
let c1 = |&mut:| get(x);
let c2 = |&mut:| { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
let c1 = || get(x);
let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
}
fn d(x: &mut isize) {
let c1 = |&mut:| set(x);
let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
let c1 = || set(x);
let c2 = || set(x); //~ ERROR closure requires unique access to `x`
}
fn e(x: &mut isize) {
let c1 = |&mut:| x = panic!(); //~ ERROR closure cannot assign to immutable local variable
let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable local variable
}
fn main() {

View File

@ -26,7 +26,7 @@ impl Drop for Foo {
fn main() {
let mut ptr = box Foo { x: 0 };
let mut test = |&mut: foo: &Foo| {
let mut test = |foo: &Foo| {
ptr = box Foo { x: ptr.x + 1 };
};
test(&*ptr); //~ ERROR cannot borrow `*ptr`

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let j = |&:| -> isize {
let j = || -> isize {
let i: isize;
i //~ ERROR use of possibly uninitialized variable: `i`
};

View File

@ -9,7 +9,7 @@
// except according to those terms.
fn main() {
let f = |&:| -> isize {
let f = || -> isize {
let i: isize;
i //~ ERROR use of possibly uninitialized variable: `i`
};

View File

@ -32,7 +32,7 @@ fn foo() {
fn bar() {
// Original borrow ends at end of closure
|&:| {
|| {
let mut x = 1us;
let y = &mut x;
let z = &mut x; //~ ERROR cannot borrow

View File

@ -14,10 +14,10 @@ fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
fn main() {
let x = 1;
to_fn_once(move|:| { x = 2; });
to_fn_once(move|| { x = 2; });
//~^ ERROR: cannot assign to immutable captured outer variable
let s = std::old_io::stdin();
to_fn_once(move|:| { s.read_to_end(); });
to_fn_once(move|| { s.read_to_end(); });
//~^ ERROR: cannot borrow immutable captured outer variable
}

View File

@ -17,7 +17,7 @@ fn call_bare(f: fn(&str)) {
fn main() {
let string = "world!";
let f = |&: s: &str| println!("{}{}", s, string);
let f = |s: &str| println!("{}{}", s, string);
call_bare(f) //~ ERROR mismatched types
}

View File

@ -13,7 +13,7 @@
#![deny(unreachable_code)]
fn main() {
let x = |:| panic!();
let x = || panic!();
x();
std::io::println("Foo bar"); //~ ERROR: unreachable statement
}

View File

@ -14,20 +14,20 @@
fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
fn main() {
let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>;
let _: () = (box |_: isize| {}) as Box<FnOnce(isize)>;
//~^ ERROR object-safe
//~| ERROR mismatched types
//~| expected `()`
//~| found `Box<core::ops::FnOnce(isize)>`
//~| expected ()
//~| found box
let _: () = (box |&:_: isize, isize| {}) as Box<Fn(isize, isize)>;
let _: () = (box |_: isize, isize| {}) as Box<Fn(isize, isize)>;
//~^ ERROR mismatched types
//~| expected `()`
//~| found `Box<core::ops::Fn(isize, isize)>`
//~| expected ()
//~| found box
let _: () = (box |&mut:| -> isize unimplemented!()) as Box<FnMut() -> isize>;
let _: () = (box || -> isize unimplemented!()) as Box<FnMut() -> isize>;
//~^ ERROR mismatched types
//~| expected `()`
//~| found `Box<core::ops::FnMut() -> isize>`

View File

@ -14,7 +14,7 @@ fn f(y: Box<isize>) {
}
fn g() {
let _frob = |&: q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
let _frob = |q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
}

View File

@ -12,7 +12,7 @@
fn main() {
let x = box 1;
let f = move|:| {
let f = move|| {
let _a = x;
drop(x);
//~^ ERROR: use of moved value: `x`

View File

@ -22,7 +22,7 @@ impl Drop for Foo {
fn main() {
let mut ptr = box Foo { x: 0 };
let mut test = |&mut: foo: &Foo| {
let mut test = |foo: &Foo| {
println!("access {}", foo.x);
ptr = box Foo { x: ptr.x + 1 };
println!("access {}", foo.x);

View File

@ -10,7 +10,7 @@
fn main() {
let mut v = vec!(1);
let mut f = |&mut:| v.push(2);
let mut f = || v.push(2);
let _w = v; //~ ERROR: cannot move out of `v`
f();

View File

@ -14,7 +14,7 @@
// wrong arity.
fn _foo<F: Fn()> (f: F) {
|&: t| f(t); //~ ERROR E0057
|t| f(t); //~ ERROR E0057
}
fn main() {}

Some files were not shown because too many files have changed in this diff Show More