@@ -63,6 +63,8 @@ pub enum Data {
6363 VariableRefData ( VariableRefData ) ,
6464 /// Data for a reference to a type or trait.
6565 TypeRefData ( TypeRefData ) ,
66+ /// Data for a reference to a module.
67+ ModRefData ( ModRefData ) ,
6668 /// Data about a function call.
6769 FunctionCallData ( FunctionCallData ) ,
6870 /// Data about a method call.
@@ -143,6 +145,14 @@ pub struct TypeRefData {
143145 pub ref_id : DefId ,
144146}
145147
148+ /// Data for a reference to a module.
149+ #[ derive( Debug ) ]
150+ pub struct ModRefData {
151+ pub span : Span ,
152+ pub scope : NodeId ,
153+ pub ref_id : DefId ,
154+ }
155+
146156/// Data about a function call.
147157#[ derive( Debug ) ]
148158pub struct FunctionCallData {
@@ -498,7 +508,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
498508 } ) )
499509 }
500510 ast:: ExprPath ( _, ref path) => {
501- Some ( self . get_path_data ( expr. id , path) )
511+ self . get_path_data ( expr. id , path)
502512 }
503513 _ => {
504514 // FIXME
@@ -510,7 +520,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
510520 pub fn get_path_data ( & self ,
511521 id : NodeId ,
512522 path : & ast:: Path )
513- -> Data {
523+ -> Option < Data > {
514524 let def_map = self . tcx . def_map . borrow ( ) ;
515525 if !def_map. contains_key ( & id) {
516526 self . tcx . sess . span_bug ( path. span ,
@@ -525,22 +535,22 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
525535 def:: DefConst ( ..) |
526536 def:: DefAssociatedConst ( ..) |
527537 def:: DefVariant ( ..) => {
528- Data :: VariableRefData ( VariableRefData {
538+ Some ( Data :: VariableRefData ( VariableRefData {
529539 name : self . span_utils . snippet ( sub_span. unwrap ( ) ) ,
530540 span : sub_span. unwrap ( ) ,
531541 scope : self . enclosing_scope ( id) ,
532542 ref_id : def. def_id ( ) ,
533- } )
543+ } ) )
534544 }
535545 def:: DefStruct ( def_id) |
536546 def:: DefTy ( def_id, _) |
537547 def:: DefTrait ( def_id) |
538548 def:: DefTyParam ( _, _, def_id, _) => {
539- Data :: TypeRefData ( TypeRefData {
549+ Some ( Data :: TypeRefData ( TypeRefData {
540550 span : sub_span. unwrap ( ) ,
541551 ref_id : def_id,
542552 scope : self . enclosing_scope ( id) ,
543- } )
553+ } ) )
544554 }
545555 def:: DefMethod ( decl_id, provenence) => {
546556 let sub_span = self . span_utils . sub_span_for_meth_name ( path. span ) ;
@@ -571,25 +581,28 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
571581 } else {
572582 None
573583 } ;
574- Data :: MethodCallData ( MethodCallData {
584+ Some ( Data :: MethodCallData ( MethodCallData {
575585 span : sub_span. unwrap ( ) ,
576586 scope : self . enclosing_scope ( id) ,
577587 ref_id : def_id,
578588 decl_id : Some ( decl_id) ,
579- } )
589+ } ) )
580590 } ,
581591 def:: DefFn ( def_id, _) => {
582- Data :: FunctionCallData ( FunctionCallData {
592+ Some ( Data :: FunctionCallData ( FunctionCallData {
583593 ref_id : def_id,
584594 span : sub_span. unwrap ( ) ,
585595 scope : self . enclosing_scope ( id) ,
586- } )
596+ } ) )
597+ }
598+ def:: DefMod ( def_id) => {
599+ Some ( Data :: ModRefData ( ModRefData {
600+ ref_id : def_id,
601+ span : sub_span. unwrap ( ) ,
602+ scope : self . enclosing_scope ( id) ,
603+ } ) )
587604 }
588- _ => self . tcx . sess . span_bug ( path. span ,
589- & format ! ( "Unexpected def kind while looking \
590- up path in `{}`: `{:?}`",
591- self . span_utils. snippet( path. span) ,
592- def) ) ,
605+ _ => None ,
593606 }
594607 }
595608
0 commit comments