@@ -108,7 +108,7 @@ pub type ExportMap2 = NodeMap<Vec<Export2>>;
108108
109109pub struct Export2 {
110110 pub name : String , // The name of the target.
111- pub def_id : DefId , // The definition of the target.
111+ pub def_id : DefId , // The definition of the target.
112112}
113113
114114// This set contains all exported definitions from external crates. The set does
@@ -314,7 +314,7 @@ impl<'a> Copy for TypeParameters<'a> {}
314314
315315// The rib kind controls the translation of local
316316// definitions (`DefLocal`) to upvars (`DefUpvar`).
317-
317+ # [ deriving ( Show ) ]
318318enum RibKind {
319319 // No translation needs to be applied.
320320 NormalRibKind ,
@@ -340,6 +340,7 @@ enum RibKind {
340340impl Copy for RibKind { }
341341
342342// Methods can be required or provided. RequiredMethod methods only occur in traits.
343+ #[ deriving( Show ) ]
343344enum MethodSort {
344345 RequiredMethod ,
345346 ProvidedMethod ( NodeId )
@@ -414,6 +415,7 @@ enum DuplicateCheckingMode {
414415impl Copy for DuplicateCheckingMode { }
415416
416417/// One local scope.
418+ #[ deriving( Show ) ]
417419struct Rib {
418420 bindings : HashMap < Name , DefLike > ,
419421 kind : RibKind ,
@@ -728,8 +730,11 @@ impl NameBindings {
728730 let type_def = self . type_def . borrow ( ) . clone ( ) ;
729731 match type_def {
730732 None => {
731- let module = Module :: new ( parent_link, def_id, kind,
732- external, is_public) ;
733+ let module = Module :: new ( parent_link,
734+ def_id,
735+ kind,
736+ external,
737+ is_public) ;
733738 * self . type_def . borrow_mut ( ) = Some ( TypeNsDef {
734739 modifiers : modifiers,
735740 module_def : Some ( Rc :: new ( module) ) ,
@@ -774,9 +779,9 @@ impl NameBindings {
774779 }
775780 Some ( type_def) => {
776781 * self . type_def . borrow_mut ( ) = Some ( TypeNsDef {
782+ module_def : type_def. module_def ,
777783 type_def : Some ( def) ,
778784 type_span : Some ( sp) ,
779- module_def : type_def. module_def ,
780785 modifiers : modifiers,
781786 } ) ;
782787 }
@@ -1286,7 +1291,7 @@ impl<'a> Resolver<'a> {
12861291 }
12871292
12881293 fn get_parent_link ( & mut self , parent : ReducedGraphParent , name : Name )
1289- -> ParentLink {
1294+ -> ParentLink {
12901295 match parent {
12911296 ModuleReducedGraphParent ( module_) => {
12921297 return ModuleParentLink ( module_. downgrade ( ) , name) ;
@@ -1578,14 +1583,14 @@ impl<'a> Resolver<'a> {
15781583
15791584 ItemImpl ( _, Some ( _) , _, _) => parent,
15801585
1581- ItemTrait ( _, _, _, ref methods ) => {
1586+ ItemTrait ( _, _, _, ref items ) => {
15821587 let name_bindings =
15831588 self . add_child ( name,
15841589 parent. clone ( ) ,
15851590 ForbidDuplicateTypesAndModules ,
15861591 sp) ;
15871592
1588- // Add all the methods within to a new module.
1593+ // Add all the items within to a new module.
15891594 let parent_link = self . get_parent_link ( parent. clone ( ) , name) ;
15901595 name_bindings. define_module ( parent_link,
15911596 Some ( local_def ( item. id ) ) ,
@@ -1598,13 +1603,12 @@ impl<'a> Resolver<'a> {
15981603
15991604 let def_id = local_def ( item. id ) ;
16001605
1601- // Add the names of all the methods to the trait info.
1602- for method in methods . iter ( ) {
1603- let ( name, kind) = match * method {
1606+ // Add the names of all the items to the trait info.
1607+ for trait_item in items . iter ( ) {
1608+ let ( name, kind) = match * trait_item {
16041609 ast:: RequiredMethod ( _) |
16051610 ast:: ProvidedMethod ( _) => {
1606- let ty_m =
1607- ast_util:: trait_item_to_ty_method ( method) ;
1611+ let ty_m = ast_util:: trait_item_to_ty_method ( trait_item) ;
16081612
16091613 let name = ty_m. ident . name ;
16101614
@@ -3353,7 +3357,7 @@ impl<'a> Resolver<'a> {
33533357 use_lexical_scope : UseLexicalScopeFlag ,
33543358 span : Span ,
33553359 name_search_type : NameSearchType )
3356- -> ResolveResult < ( Rc < Module > , LastPrivate ) > {
3360+ -> ResolveResult < ( Rc < Module > , LastPrivate ) > {
33573361 let module_path_len = module_path. len ( ) ;
33583362 assert ! ( module_path_len > 0 ) ;
33593363
@@ -3382,7 +3386,9 @@ impl<'a> Resolver<'a> {
33823386 mpath. slice_to( idx - 1 ) ) ;
33833387 return Failed ( Some ( ( span, msg) ) ) ;
33843388 } ,
3385- None => return Failed ( None ) ,
3389+ None => {
3390+ return Failed ( None )
3391+ }
33863392 }
33873393 }
33883394 Failed ( err) => return Failed ( err) ,
@@ -3407,9 +3413,8 @@ impl<'a> Resolver<'a> {
34073413 // This is not a crate-relative path. We resolve the
34083414 // first component of the path in the current lexical
34093415 // scope and then proceed to resolve below that.
3410- match self . resolve_module_in_lexical_scope (
3411- module_,
3412- module_path[ 0 ] ) {
3416+ match self . resolve_module_in_lexical_scope ( module_,
3417+ module_path[ 0 ] ) {
34133418 Failed ( err) => return Failed ( err) ,
34143419 Indeterminate => {
34153420 debug ! ( "(resolving module path for import) \
@@ -3576,8 +3581,7 @@ impl<'a> Resolver<'a> {
35763581 -> ResolveResult < Rc < Module > > {
35773582 // If this module is an anonymous module, resolve the item in the
35783583 // lexical scope. Otherwise, resolve the item from the crate root.
3579- let resolve_result = self . resolve_item_in_lexical_scope (
3580- module_, name, TypeNS ) ;
3584+ let resolve_result = self . resolve_item_in_lexical_scope ( module_, name, TypeNS ) ;
35813585 match resolve_result {
35823586 Success ( ( target, _) ) => {
35833587 let bindings = & * target. bindings ;
@@ -4590,25 +4594,42 @@ impl<'a> Resolver<'a> {
45904594
45914595 fn resolve_where_clause ( & mut self , where_clause : & ast:: WhereClause ) {
45924596 for predicate in where_clause. predicates . iter ( ) {
4593- match self . resolve_identifier ( predicate. ident ,
4594- TypeNS ,
4595- true ,
4596- predicate. span ) {
4597- Some ( ( def @ DefTyParam ( _, _, _) , last_private) ) => {
4598- self . record_def ( predicate. id , ( def, last_private) ) ;
4599- }
4600- _ => {
4601- self . resolve_error (
4602- predicate. span ,
4603- format ! ( "undeclared type parameter `{}`" ,
4604- token:: get_ident(
4605- predicate. ident) ) . as_slice ( ) ) ;
4597+ match predicate {
4598+ & ast:: WherePredicate :: BoundPredicate ( ref bound_pred) => {
4599+ match self . resolve_identifier ( bound_pred. ident ,
4600+ TypeNS ,
4601+ true ,
4602+ bound_pred. span ) {
4603+ Some ( ( def @ DefTyParam ( ..) , last_private) ) => {
4604+ self . record_def ( bound_pred. id , ( def, last_private) ) ;
4605+ }
4606+ _ => {
4607+ self . resolve_error (
4608+ bound_pred. span ,
4609+ format ! ( "undeclared type parameter `{}`" ,
4610+ token:: get_ident(
4611+ bound_pred. ident) ) . as_slice ( ) ) ;
4612+ }
4613+ }
4614+
4615+ for bound in bound_pred. bounds . iter ( ) {
4616+ self . resolve_type_parameter_bound ( bound_pred. id , bound,
4617+ TraitBoundingTypeParameter ) ;
4618+ }
46064619 }
4607- }
4620+ & ast:: WherePredicate :: EqPredicate ( ref eq_pred) => {
4621+ match self . resolve_path ( eq_pred. id , & eq_pred. path , TypeNS , true ) {
4622+ Some ( ( def @ DefTyParam ( ..) , last_private) ) => {
4623+ self . record_def ( eq_pred. id , ( def, last_private) ) ;
4624+ }
4625+ _ => {
4626+ self . resolve_error ( eq_pred. path . span ,
4627+ "undeclared associated type" ) ;
4628+ }
4629+ }
46084630
4609- for bound in predicate. bounds . iter ( ) {
4610- self . resolve_type_parameter_bound ( predicate. id , bound,
4611- TraitBoundingTypeParameter ) ;
4631+ self . resolve_type ( & * eq_pred. ty ) ;
4632+ }
46124633 }
46134634 }
46144635 }
@@ -5269,15 +5290,19 @@ impl<'a> Resolver<'a> {
52695290 path : & Path ,
52705291 namespace : Namespace ,
52715292 check_ribs : bool ) -> Option < ( Def , LastPrivate ) > {
5272- // First, resolve the types.
5293+ // First, resolve the types and associated type bindings .
52735294 for ty in path. segments . iter ( ) . flat_map ( |s| s. parameters . types ( ) . into_iter ( ) ) {
52745295 self . resolve_type ( & * * ty) ;
52755296 }
5297+ for binding in path. segments . iter ( ) . flat_map ( |s| s. parameters . bindings ( ) . into_iter ( ) ) {
5298+ self . resolve_type ( & * binding. ty ) ;
5299+ }
52765300
52775301 if path. global {
52785302 return self . resolve_crate_relative_path ( path, namespace) ;
52795303 }
52805304
5305+ // Try to find a path to an item in a module.
52815306 let unqualified_def =
52825307 self . resolve_identifier ( path. segments
52835308 . last ( ) . unwrap ( )
@@ -5307,15 +5332,15 @@ impl<'a> Resolver<'a> {
53075332
53085333 // resolve a single identifier (used as a varref)
53095334 fn resolve_identifier ( & mut self ,
5310- identifier : Ident ,
5311- namespace : Namespace ,
5312- check_ribs : bool ,
5313- span : Span )
5314- -> Option < ( Def , LastPrivate ) > {
5335+ identifier : Ident ,
5336+ namespace : Namespace ,
5337+ check_ribs : bool ,
5338+ span : Span )
5339+ -> Option < ( Def , LastPrivate ) > {
53155340 if check_ribs {
53165341 match self . resolve_identifier_in_local_ribs ( identifier,
5317- namespace,
5318- span) {
5342+ namespace,
5343+ span) {
53195344 Some ( def) => {
53205345 return Some ( ( def, LastMod ( AllPublic ) ) ) ;
53215346 }
@@ -5333,7 +5358,7 @@ impl<'a> Resolver<'a> {
53335358 containing_module : Rc < Module > ,
53345359 name : Name ,
53355360 namespace : Namespace )
5336- -> NameDefinition {
5361+ -> NameDefinition {
53375362 // First, search children.
53385363 self . populate_module_if_necessary ( & containing_module) ;
53395364
@@ -5403,9 +5428,9 @@ impl<'a> Resolver<'a> {
54035428
54045429 // resolve a "module-relative" path, e.g. a::b::c
54055430 fn resolve_module_relative_path ( & mut self ,
5406- path : & Path ,
5407- namespace : Namespace )
5408- -> Option < ( Def , LastPrivate ) > {
5431+ path : & Path ,
5432+ namespace : Namespace )
5433+ -> Option < ( Def , LastPrivate ) > {
54095434 let module_path = path. segments . init ( ) . iter ( )
54105435 . map ( |ps| ps. identifier . name )
54115436 . collect :: < Vec < _ > > ( ) ;
@@ -5422,9 +5447,8 @@ impl<'a> Resolver<'a> {
54225447 let ( span, msg) = match err {
54235448 Some ( ( span, msg) ) => ( span, msg) ,
54245449 None => {
5425- let msg = format ! ( "Use of undeclared module `{}`" ,
5426- self . names_to_string(
5427- module_path. as_slice( ) ) ) ;
5450+ let msg = format ! ( "Use of undeclared type or module `{}`" ,
5451+ self . names_to_string( module_path. as_slice( ) ) ) ;
54285452 ( path. span , msg)
54295453 }
54305454 } ;
@@ -5518,10 +5542,10 @@ impl<'a> Resolver<'a> {
55185542 }
55195543
55205544 fn resolve_identifier_in_local_ribs ( & mut self ,
5521- ident : Ident ,
5522- namespace : Namespace ,
5523- span : Span )
5524- -> Option < Def > {
5545+ ident : Ident ,
5546+ namespace : Namespace ,
5547+ span : Span )
5548+ -> Option < Def > {
55255549 // Check the local set of ribs.
55265550 let search_result = match namespace {
55275551 ValueNS => {
0 commit comments