2727use rustc:: hir:: def:: Def as HirDef ;
2828use rustc:: hir:: def_id:: DefId ;
2929use rustc:: hir:: map:: Node ;
30- use rustc:: session:: Session ;
3130use rustc:: ty:: { self , TyCtxt } ;
3231use rustc_data_structures:: fx:: FxHashSet ;
3332
@@ -62,7 +61,6 @@ macro_rules! down_cast_data {
6261
6362pub struct DumpVisitor < ' l , ' tcx : ' l , ' ll , O : DumpOutput + ' ll > {
6463 save_ctxt : SaveContext < ' l , ' tcx > ,
65- sess : & ' l Session ,
6664 tcx : TyCtxt < ' l , ' tcx , ' tcx > ,
6765 dumper : & ' ll mut JsonDumper < O > ,
6866
@@ -84,7 +82,6 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
8482 -> DumpVisitor < ' l , ' tcx , ' ll , O > {
8583 let span_utils = SpanUtils :: new ( & save_ctxt. tcx . sess ) ;
8684 DumpVisitor {
87- sess : & save_ctxt. tcx . sess ,
8885 tcx : save_ctxt. tcx ,
8986 save_ctxt : save_ctxt,
9087 dumper : dumper,
@@ -147,47 +144,23 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
147144 // For each prefix, we return the span for the last segment in the prefix and
148145 // a str representation of the entire prefix.
149146 fn process_path_prefixes ( & self , path : & ast:: Path ) -> Vec < ( Span , String ) > {
150- let spans = self . span . spans_for_path_segments ( path) ;
151147 let segments = & path. segments [ if path. is_global ( ) { 1 } else { 0 } ..] ;
152148
153- // Paths to enums seem to not match their spans - the span includes all the
154- // variants too. But they seem to always be at the end, so I hope we can cope with
155- // always using the first ones. So, only error out if we don't have enough spans.
156- // What could go wrong...?
157- if spans. len ( ) < segments. len ( ) {
158- if generated_code ( path. span ) {
159- return vec ! [ ] ;
160- }
161- error ! ( "Mis-calculated spans for path '{}'. Found {} spans, expected {}. Found spans:" ,
162- path_to_string( path) ,
163- spans. len( ) ,
164- segments. len( ) ) ;
165- for s in & spans {
166- let loc = self . sess . codemap ( ) . lookup_char_pos ( s. lo ) ;
167- error ! ( " '{}' in {}, line {}" ,
168- self . span. snippet( * s) ,
169- loc. file. name,
170- loc. line) ;
171- }
172- error ! ( " master span: {:?}: `{}`" , path. span, self . span. snippet( path. span) ) ;
173- return vec ! [ ] ;
174- }
175-
176- let mut result: Vec < ( Span , String ) > = vec ! [ ] ;
149+ let mut result = Vec :: with_capacity ( segments. len ( ) ) ;
177150
178151 let mut segs = vec ! [ ] ;
179- for ( i, ( seg, span ) ) in segments. iter ( ) . zip ( & spans ) . enumerate ( ) {
152+ for ( i, seg) in segments. iter ( ) . enumerate ( ) {
180153 segs. push ( seg. clone ( ) ) ;
181154 let sub_path = ast:: Path {
182- span : * span, // span for the last segment
155+ span : seg . span , // span for the last segment
183156 segments : segs,
184157 } ;
185158 let qualname = if i == 0 && path. is_global ( ) {
186159 format ! ( "::{}" , path_to_string( & sub_path) )
187160 } else {
188161 path_to_string ( & sub_path)
189162 } ;
190- result. push ( ( * span, qualname) ) ;
163+ result. push ( ( seg . span , qualname) ) ;
191164 segs = sub_path. segments ;
192165 }
193166
@@ -437,13 +410,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
437410 full_span : Span ,
438411 prefix : & str ,
439412 id : NodeId ) {
440- // We can't only use visit_generics since we don't have spans for param
441- // bindings, so we reparse the full_span to get those sub spans.
442- // However full span is the entire enum/fn/struct block, so we only want
443- // the first few to match the number of generics we're looking for.
444- let param_sub_spans = self . span . spans_for_ty_params ( full_span,
445- ( generics. ty_params . len ( ) as isize ) ) ;
446- for ( param, param_ss) in generics. ty_params . iter ( ) . zip ( param_sub_spans) {
413+ for param in & generics. ty_params {
414+ let param_ss = param. span ;
447415 let name = escape ( self . span . snippet ( param_ss) ) ;
448416 // Append $id to name to make sure each one is unique
449417 let qualname = format ! ( "{}::{}${}" ,
0 commit comments