@@ -63,6 +63,8 @@ pub enum Data {
63
63
VariableRefData ( VariableRefData ) ,
64
64
/// Data for a reference to a type or trait.
65
65
TypeRefData ( TypeRefData ) ,
66
+ /// Data for a reference to a module.
67
+ ModRefData ( ModRefData ) ,
66
68
/// Data about a function call.
67
69
FunctionCallData ( FunctionCallData ) ,
68
70
/// Data about a method call.
@@ -143,6 +145,14 @@ pub struct TypeRefData {
143
145
pub ref_id : DefId ,
144
146
}
145
147
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
+
146
156
/// Data about a function call.
147
157
#[ derive( Debug ) ]
148
158
pub struct FunctionCallData {
@@ -498,7 +508,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
498
508
} ) )
499
509
}
500
510
ast:: ExprPath ( _, ref path) => {
501
- Some ( self . get_path_data ( expr. id , path) )
511
+ self . get_path_data ( expr. id , path)
502
512
}
503
513
_ => {
504
514
// FIXME
@@ -510,7 +520,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
510
520
pub fn get_path_data ( & self ,
511
521
id : NodeId ,
512
522
path : & ast:: Path )
513
- -> Data {
523
+ -> Option < Data > {
514
524
let def_map = self . tcx . def_map . borrow ( ) ;
515
525
if !def_map. contains_key ( & id) {
516
526
self . tcx . sess . span_bug ( path. span ,
@@ -525,22 +535,22 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
525
535
def:: DefConst ( ..) |
526
536
def:: DefAssociatedConst ( ..) |
527
537
def:: DefVariant ( ..) => {
528
- Data :: VariableRefData ( VariableRefData {
538
+ Some ( Data :: VariableRefData ( VariableRefData {
529
539
name : self . span_utils . snippet ( sub_span. unwrap ( ) ) ,
530
540
span : sub_span. unwrap ( ) ,
531
541
scope : self . enclosing_scope ( id) ,
532
542
ref_id : def. def_id ( ) ,
533
- } )
543
+ } ) )
534
544
}
535
545
def:: DefStruct ( def_id) |
536
546
def:: DefTy ( def_id, _) |
537
547
def:: DefTrait ( def_id) |
538
548
def:: DefTyParam ( _, _, def_id, _) => {
539
- Data :: TypeRefData ( TypeRefData {
549
+ Some ( Data :: TypeRefData ( TypeRefData {
540
550
span : sub_span. unwrap ( ) ,
541
551
ref_id : def_id,
542
552
scope : self . enclosing_scope ( id) ,
543
- } )
553
+ } ) )
544
554
}
545
555
def:: DefMethod ( decl_id, provenence) => {
546
556
let sub_span = self . span_utils . sub_span_for_meth_name ( path. span ) ;
@@ -571,25 +581,28 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
571
581
} else {
572
582
None
573
583
} ;
574
- Data :: MethodCallData ( MethodCallData {
584
+ Some ( Data :: MethodCallData ( MethodCallData {
575
585
span : sub_span. unwrap ( ) ,
576
586
scope : self . enclosing_scope ( id) ,
577
587
ref_id : def_id,
578
588
decl_id : Some ( decl_id) ,
579
- } )
589
+ } ) )
580
590
} ,
581
591
def:: DefFn ( def_id, _) => {
582
- Data :: FunctionCallData ( FunctionCallData {
592
+ Some ( Data :: FunctionCallData ( FunctionCallData {
583
593
ref_id : def_id,
584
594
span : sub_span. unwrap ( ) ,
585
595
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
+ } ) )
587
604
}
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 ,
593
606
}
594
607
}
595
608
0 commit comments