From 9963bd24138999e745584a138f8381f91e3a308c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 8 Apr 2013 22:54:49 -0700 Subject: Cleanup substitutions and treatment of generics around traits in a number of ways. - In a TraitRef, use the self type consistently to refer to the Self type: - trait ref in `impl Trait for S` has a self type of `S`. - trait ref in `A:Trait` has the self type `A` - trait ref associated with a trait decl has self type `Self` - trait ref associated with a supertype has self type `Self` - trait ref in an object type `@Trait` has no self type - Rewrite `each_bound_traits_and_supertraits` to perform substitutions as it goes, and thus yield a series of trait refs that are always in the same 'namespace' as the type parameter bound given as input. Before, we left this to the caller, but this doesn't work because the caller lacks adequare information to perform the type substitutions correctly. - For provided methods, substitute the generics involved in the provided method correctly. - Introduce TypeParameterDef, which tracks the bounds declared on a type parameter and brings them together with the def_id and (in the future) other information (maybe even the parameter's name!). - Introduce Subst trait, which helps to cleanup a lot of the repetitive code involved with doing type substitution. - Introduce Repr trait, which makes debug printouts far more convenient. Fixes #4183. Needed for #5656. --- src/libsyntax/opt_vec.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 67c3d19dd0f..fd54746f3dc 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -102,6 +102,16 @@ impl OptVec { self.push(copy *e); } } + + #[inline(always)] + fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { + let mut index = 0; + iter::map_to_vec(self, |a| { + let i = index; + index += 1; + op(i, a) + }) + } } impl Eq for OptVec { -- cgit 1.4.1-3-g733a5