From fd06ef24bb6e91a60dab2d1199acb810ff2875b3 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 2 Dec 2014 14:56:00 -0500 Subject: [PATCH] librustc: fix fallout --- src/librustc/lib.rs | 1 + src/librustc/middle/subst.rs | 6 ++++-- src/librustc/middle/traits/mod.rs | 12 ++++-------- src/librustc/util/ppaux.rs | 4 +++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 51cb7e193ffb..404c7edeb88d 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -25,6 +25,7 @@ #![feature(default_type_params, globs, import_shadowing, macro_rules, phase, quote)] #![feature(slicing_syntax, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] +#![feature(unboxed_closures)] extern crate arena; extern crate flate; diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index d3b1c2d2afc4..04ecaf2f483f 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -432,7 +432,7 @@ impl VecPerParamSpace { self.all_vecs(|v| v.is_empty()) } - pub fn map(&self, pred: |&T| -> U) -> VecPerParamSpace { + pub fn map(&self, pred: P) -> VecPerParamSpace where P: FnMut(&T) -> U { let result = self.iter().map(pred).collect(); VecPerParamSpace::new_internal(result, self.type_limit, @@ -440,7 +440,9 @@ impl VecPerParamSpace { self.assoc_limit) } - pub fn map_enumerated(&self, pred: |(ParamSpace, uint, &T)| -> U) -> VecPerParamSpace { + pub fn map_enumerated(&self, pred: P) -> VecPerParamSpace where + P: FnMut((ParamSpace, uint, &T)) -> U, + { let result = self.iter_enumerated().map(pred).collect(); VecPerParamSpace::new_internal(result, self.type_limit, diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 604a0607c0b4..52d331539820 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -312,7 +312,7 @@ impl<'tcx, N> Vtable<'tcx, N> { } } - pub fn map_nested(&self, op: |&N| -> M) -> Vtable<'tcx, M> { + pub fn map_nested(&self, op: F) -> Vtable<'tcx, M> where F: FnMut(&N) -> M { match *self { VtableImpl(ref i) => VtableImpl(i.map_nested(op)), VtableFnPointer(ref sig) => VtableFnPointer((*sig).clone()), @@ -338,9 +338,8 @@ impl<'tcx, N> VtableImplData<'tcx, N> { self.nested.iter() } - pub fn map_nested(&self, - op: |&N| -> M) - -> VtableImplData<'tcx, M> + pub fn map_nested(&self, op: F) -> VtableImplData<'tcx, M> where + F: FnMut(&N) -> M, { VtableImplData { impl_def_id: self.impl_def_id, @@ -365,10 +364,7 @@ impl VtableBuiltinData { self.nested.iter() } - pub fn map_nested(&self, - op: |&N| -> M) - -> VtableBuiltinData - { + pub fn map_nested(&self, op: F) -> VtableBuiltinData where F: FnMut(&N) -> M { VtableBuiltinData { nested: self.nested.map(op) } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7a14ed9cca8c..5dbf3208595e 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -241,7 +241,9 @@ pub fn trait_store_to_string(cx: &ctxt, s: ty::TraitStore) -> String { } } -pub fn vec_map_to_string(ts: &[T], f: |t: &T| -> String) -> String { +pub fn vec_map_to_string(ts: &[T], f: F) -> String where + F: FnMut(&T) -> String, +{ let tstrs = ts.iter().map(f).collect::>(); format!("[{}]", tstrs.connect(", ")) }