@@ -14,7 +14,7 @@ use rustc_hir::def::{DefKind, Res};
14
14
use rustc_hir:: def_id:: LocalDefId ;
15
15
use rustc_span:: source_map:: { respan, DesugaringKind } ;
16
16
use rustc_span:: symbol:: { kw, sym, Ident } ;
17
- use rustc_span:: Span ;
17
+ use rustc_span:: { Span , DUMMY_SP } ;
18
18
use rustc_target:: spec:: abi;
19
19
20
20
use log:: debug;
@@ -35,8 +35,8 @@ impl ItemLowerer<'_, '_, '_> {
35
35
}
36
36
37
37
impl < ' a > Visitor < ' a > for ItemLowerer < ' a , ' _ , ' _ > {
38
- fn visit_mod ( & mut self , m : & ' a Mod , _s : Span , _attrs : & [ Attribute ] , n : NodeId ) {
39
- let hir_id = self . lctx . lower_node_id ( n) ;
38
+ fn visit_mod ( & mut self , m : & ' a Mod , span : Span , _attrs : & [ Attribute ] , n : NodeId ) {
39
+ let hir_id = self . lctx . lower_node_id ( n, span ) ;
40
40
41
41
self . lctx . modules . insert (
42
42
hir_id,
@@ -206,7 +206,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
206
206
207
207
if let ItemKind :: MacroDef ( MacroDef { ref body, macro_rules } ) = i. kind {
208
208
if !macro_rules || attr:: contains_name ( & i. attrs , sym:: macro_export) {
209
- let hir_id = self . lower_node_id ( i. id ) ;
209
+ let hir_id = self . lower_node_id ( i. id , i . span ) ;
210
210
let body = P ( self . lower_mac_args ( body) ) ;
211
211
self . exported_macros . push ( hir:: MacroDef {
212
212
ident,
@@ -224,7 +224,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
224
224
225
225
let kind = self . lower_item_kind ( i. span , i. id , & mut ident, attrs, & mut vis, & i. kind ) ;
226
226
227
- Some ( hir:: Item { hir_id : self . lower_node_id ( i. id ) , ident, attrs, kind, vis, span : i. span } )
227
+ Some ( hir:: Item {
228
+ hir_id : self . lower_node_id ( i. id , i. span ) ,
229
+ ident,
230
+ attrs,
231
+ kind,
232
+ vis,
233
+ span : i. span ,
234
+ } )
228
235
}
229
236
230
237
fn lower_item_kind (
@@ -319,14 +326,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
319
326
self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
320
327
) ,
321
328
ItemKind :: Struct ( ref struct_def, ref generics) => {
322
- let struct_def = self . lower_variant_data ( struct_def) ;
329
+ let struct_def = self . lower_variant_data ( span , struct_def) ;
323
330
hir:: ItemKind :: Struct (
324
331
struct_def,
325
332
self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
326
333
)
327
334
}
328
335
ItemKind :: Union ( ref vdata, ref generics) => {
329
- let vdata = self . lower_variant_data ( vdata) ;
336
+ let vdata = self . lower_variant_data ( span , vdata) ;
330
337
hir:: ItemKind :: Union (
331
338
vdata,
332
339
self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
@@ -357,7 +364,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
357
364
// method, it will not be considered an in-band
358
365
// lifetime to be added, but rather a reference to a
359
366
// parent lifetime.
360
- let lowered_trait_impl_id = self . lower_node_id ( id) ;
367
+ let lowered_trait_impl_id = self . lower_node_id ( id, DUMMY_SP ) ;
361
368
let ( generics, ( trait_ref, lowered_ty) ) = self . add_in_band_defs (
362
369
ast_generics,
363
370
def_id,
@@ -499,7 +506,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
499
506
let span = path. span ;
500
507
501
508
self . with_hir_id_owner ( new_node_id, |this| {
502
- let new_id = this. lower_node_id ( new_node_id) ;
509
+ let new_id = this. lower_node_id ( new_node_id, span ) ;
503
510
let res = this. lower_res ( res) ;
504
511
let path = this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
505
512
let kind = hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) ;
@@ -553,7 +560,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
553
560
554
561
// Add all the nested `PathListItem`s to the HIR.
555
562
for & ( ref use_tree, id) in trees {
556
- let new_hir_id = self . lower_node_id ( id) ;
563
+ let new_hir_id = self . lower_node_id ( id, use_tree . span ) ;
557
564
558
565
let mut prefix = prefix. clone ( ) ;
559
566
@@ -622,7 +629,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
622
629
let segments =
623
630
self . arena . alloc_from_iter ( path. segments . iter ( ) . map ( |seg| hir:: PathSegment {
624
631
ident : seg. ident ,
625
- hir_id : seg. hir_id . map ( |_| self . next_id ( ) ) ,
632
+ hir_id : seg. hir_id . map ( |_| self . next_id ( seg . ident . span ) ) ,
626
633
res : seg. res ,
627
634
args : None ,
628
635
infer_args : seg. infer_args ,
@@ -638,7 +645,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
638
645
hir:: VisibilityKind :: Restricted { ref path, hir_id : _ } => {
639
646
hir:: VisibilityKind :: Restricted {
640
647
path : self . rebuild_use_path ( path) ,
641
- hir_id : self . next_id ( ) ,
648
+ hir_id : self . next_id ( vis . span ) ,
642
649
}
643
650
}
644
651
} ;
@@ -648,7 +655,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
648
655
fn lower_foreign_item ( & mut self , i : & ForeignItem ) -> hir:: ForeignItem < ' hir > {
649
656
let def_id = self . resolver . definitions ( ) . local_def_id ( i. id ) ;
650
657
hir:: ForeignItem {
651
- hir_id : self . lower_node_id ( i. id ) ,
658
+ hir_id : self . lower_node_id ( i. id , i . span ) ,
652
659
ident : i. ident ,
653
660
attrs : self . lower_attrs ( & i. attrs ) ,
654
661
kind : match i. kind {
@@ -695,15 +702,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
695
702
fn lower_variant ( & mut self , v : & Variant ) -> hir:: Variant < ' hir > {
696
703
hir:: Variant {
697
704
attrs : self . lower_attrs ( & v. attrs ) ,
698
- data : self . lower_variant_data ( & v. data ) ,
705
+ data : self . lower_variant_data ( v . span , & v. data ) ,
699
706
disr_expr : v. disr_expr . as_ref ( ) . map ( |e| self . lower_anon_const ( e) ) ,
700
- id : self . lower_node_id ( v. id ) ,
707
+ id : self . lower_node_id ( v. id , v . span ) ,
701
708
ident : v. ident ,
702
709
span : v. span ,
703
710
}
704
711
}
705
712
706
- fn lower_variant_data ( & mut self , vdata : & VariantData ) -> hir:: VariantData < ' hir > {
713
+ fn lower_variant_data ( & mut self , span : Span , vdata : & VariantData ) -> hir:: VariantData < ' hir > {
707
714
match * vdata {
708
715
VariantData :: Struct ( ref fields, recovered) => hir:: VariantData :: Struct (
709
716
self . arena
@@ -713,9 +720,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
713
720
VariantData :: Tuple ( ref fields, id) => hir:: VariantData :: Tuple (
714
721
self . arena
715
722
. alloc_from_iter ( fields. iter ( ) . enumerate ( ) . map ( |f| self . lower_struct_field ( f) ) ) ,
716
- self . lower_node_id ( id) ,
723
+ self . lower_node_id ( id, span ) ,
717
724
) ,
718
- VariantData :: Unit ( id) => hir:: VariantData :: Unit ( self . lower_node_id ( id) ) ,
725
+ VariantData :: Unit ( id) => hir:: VariantData :: Unit ( self . lower_node_id ( id, span ) ) ,
719
726
}
720
727
}
721
728
@@ -734,7 +741,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
734
741
} ;
735
742
hir:: StructField {
736
743
span : f. span ,
737
- hir_id : self . lower_node_id ( f. id ) ,
744
+ hir_id : self . lower_node_id ( f. id , f . span ) ,
738
745
ident : match f. ident {
739
746
Some ( ident) => ident,
740
747
// FIXME(jseyfried): positional field hygiene.
@@ -781,7 +788,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
781
788
} ;
782
789
783
790
hir:: TraitItem {
784
- hir_id : self . lower_node_id ( i. id ) ,
791
+ hir_id : self . lower_node_id ( i. id , i . span ) ,
785
792
ident : i. ident ,
786
793
attrs : self . lower_attrs ( & i. attrs ) ,
787
794
generics,
@@ -801,7 +808,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
801
808
}
802
809
AssocItemKind :: MacCall ( ..) => unimplemented ! ( ) ,
803
810
} ;
804
- let id = hir:: TraitItemId { hir_id : self . lower_node_id ( i. id ) } ;
811
+ let id = hir:: TraitItemId { hir_id : self . lower_node_id ( i. id , i . span ) } ;
805
812
let defaultness = hir:: Defaultness :: Default { has_value : has_default } ;
806
813
hir:: TraitItemRef { id, ident : i. ident , span : i. span , defaultness, kind }
807
814
}
@@ -865,7 +872,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
865
872
let has_value = true ;
866
873
let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
867
874
hir:: ImplItem {
868
- hir_id : self . lower_node_id ( i. id ) ,
875
+ hir_id : self . lower_node_id ( i. id , i . span ) ,
869
876
ident : i. ident ,
870
877
attrs : self . lower_attrs ( & i. attrs ) ,
871
878
generics,
@@ -881,7 +888,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
881
888
let has_value = true ;
882
889
let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
883
890
hir:: ImplItemRef {
884
- id : hir:: ImplItemId { hir_id : self . lower_node_id ( i. id ) } ,
891
+ id : hir:: ImplItemId { hir_id : self . lower_node_id ( i. id , i . span ) } ,
885
892
ident : i. ident ,
886
893
span : i. span ,
887
894
vis : self . lower_visibility ( & i. vis , Some ( i. id ) ) ,
@@ -913,9 +920,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
913
920
VisibilityKind :: Restricted { ref path, id } => {
914
921
debug ! ( "lower_visibility: restricted path id = {:?}" , id) ;
915
922
let lowered_id = if let Some ( owner) = explicit_owner {
916
- self . lower_node_id_with_owner ( id, owner)
923
+ self . lower_node_id_with_owner ( id, owner, v . span )
917
924
} else {
918
- self . lower_node_id ( id)
925
+ self . lower_node_id ( id, v . span )
919
926
} ;
920
927
let res = self . expect_full_res ( id) ;
921
928
let res = self . lower_res ( res) ;
@@ -970,7 +977,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
970
977
fn lower_param ( & mut self , param : & Param ) -> hir:: Param < ' hir > {
971
978
hir:: Param {
972
979
attrs : self . lower_attrs ( & param. attrs ) ,
973
- hir_id : self . lower_node_id ( param. id ) ,
980
+ hir_id : self . lower_node_id ( param. id , param . span ) ,
974
981
pat : self . lower_pat ( & param. pat ) ,
975
982
span : param. span ,
976
983
}
@@ -1413,7 +1420,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1413
1420
} ) ,
1414
1421
WherePredicate :: EqPredicate ( WhereEqPredicate { id, ref lhs_ty, ref rhs_ty, span } ) => {
1415
1422
hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1416
- hir_id : self . lower_node_id ( id) ,
1423
+ hir_id : self . lower_node_id ( id, span ) ,
1417
1424
lhs_ty : self . lower_ty ( lhs_ty, ImplTraitContext :: disallowed ( ) ) ,
1418
1425
rhs_ty : self . lower_ty ( rhs_ty, ImplTraitContext :: disallowed ( ) ) ,
1419
1426
span,
0 commit comments