@@ -13,7 +13,7 @@ use rustc_hir::def::{DefKind, Res};
13
13
use rustc_hir:: def_id:: LocalDefId ;
14
14
use rustc_span:: source_map:: { respan, DesugaringKind } ;
15
15
use rustc_span:: symbol:: { kw, sym, Ident } ;
16
- use rustc_span:: Span ;
16
+ use rustc_span:: { Span , DUMMY_SP } ;
17
17
use rustc_target:: spec:: abi;
18
18
19
19
use smallvec:: { smallvec, SmallVec } ;
@@ -34,8 +34,8 @@ impl ItemLowerer<'_, '_, '_> {
34
34
}
35
35
36
36
impl < ' a > Visitor < ' a > for ItemLowerer < ' a , ' _ , ' _ > {
37
- fn visit_mod ( & mut self , m : & ' a Mod , _s : Span , _attrs : & [ Attribute ] , n : NodeId ) {
38
- let hir_id = self . lctx . lower_node_id ( n) ;
37
+ fn visit_mod ( & mut self , m : & ' a Mod , span : Span , _attrs : & [ Attribute ] , n : NodeId ) {
38
+ let hir_id = self . lctx . lower_node_id ( n, span ) ;
39
39
40
40
self . lctx . modules . insert (
41
41
hir_id,
@@ -230,7 +230,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
230
230
231
231
if let ItemKind :: MacroDef ( MacroDef { ref body, macro_rules } ) = i. kind {
232
232
if !macro_rules || self . sess . contains_name ( & i. attrs , sym:: macro_export) {
233
- let hir_id = self . lower_node_id ( i. id ) ;
233
+ let hir_id = self . lower_node_id ( i. id , i . span ) ;
234
234
let body = P ( self . lower_mac_args ( body) ) ;
235
235
self . exported_macros . push ( hir:: MacroDef {
236
236
ident,
@@ -248,7 +248,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
248
248
249
249
let kind = self . lower_item_kind ( i. span , i. id , & mut ident, attrs, & mut vis, & i. kind ) ;
250
250
251
- Some ( hir:: Item { hir_id : self . lower_node_id ( i. id ) , ident, attrs, kind, vis, span : i. span } )
251
+ Some ( hir:: Item {
252
+ hir_id : self . lower_node_id ( i. id , i. span ) ,
253
+ ident,
254
+ attrs,
255
+ kind,
256
+ vis,
257
+ span : i. span ,
258
+ } )
252
259
}
253
260
254
261
fn lower_item_kind (
@@ -357,14 +364,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
357
364
self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
358
365
) ,
359
366
ItemKind :: Struct ( ref struct_def, ref generics) => {
360
- let struct_def = self . lower_variant_data ( struct_def) ;
367
+ let struct_def = self . lower_variant_data ( span , struct_def) ;
361
368
hir:: ItemKind :: Struct (
362
369
struct_def,
363
370
self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
364
371
)
365
372
}
366
373
ItemKind :: Union ( ref vdata, ref generics) => {
367
- let vdata = self . lower_variant_data ( vdata) ;
374
+ let vdata = self . lower_variant_data ( span , vdata) ;
368
375
hir:: ItemKind :: Union (
369
376
vdata,
370
377
self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
@@ -395,7 +402,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
395
402
// method, it will not be considered an in-band
396
403
// lifetime to be added, but rather a reference to a
397
404
// parent lifetime.
398
- let lowered_trait_impl_id = self . lower_node_id ( id) ;
405
+ let lowered_trait_impl_id = self . lower_node_id ( id, DUMMY_SP ) ;
399
406
let ( generics, ( trait_ref, lowered_ty) ) = self . add_in_band_defs (
400
407
ast_generics,
401
408
def_id,
@@ -537,7 +544,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
537
544
let span = path. span ;
538
545
539
546
self . with_hir_id_owner ( new_node_id, |this| {
540
- let new_id = this. lower_node_id ( new_node_id) ;
547
+ let new_id = this. lower_node_id ( new_node_id, span ) ;
541
548
let res = this. lower_res ( res) ;
542
549
let path = this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
543
550
let kind = hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) ;
@@ -594,7 +601,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
594
601
595
602
// Add all the nested `PathListItem`s to the HIR.
596
603
for & ( ref use_tree, id) in trees {
597
- let new_hir_id = self . lower_node_id ( id) ;
604
+ let new_hir_id = self . lower_node_id ( id, use_tree . span ) ;
598
605
599
606
let mut prefix = prefix. clone ( ) ;
600
607
@@ -663,7 +670,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
663
670
let segments =
664
671
self . arena . alloc_from_iter ( path. segments . iter ( ) . map ( |seg| hir:: PathSegment {
665
672
ident : seg. ident ,
666
- hir_id : seg. hir_id . map ( |_| self . next_id ( ) ) ,
673
+ hir_id : seg. hir_id . map ( |_| self . next_id ( seg . ident . span ) ) ,
667
674
res : seg. res ,
668
675
args : None ,
669
676
infer_args : seg. infer_args ,
@@ -679,7 +686,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
679
686
hir:: VisibilityKind :: Restricted { ref path, hir_id : _ } => {
680
687
hir:: VisibilityKind :: Restricted {
681
688
path : self . rebuild_use_path ( path) ,
682
- hir_id : self . next_id ( ) ,
689
+ hir_id : self . next_id ( vis . span ) ,
683
690
}
684
691
}
685
692
} ;
@@ -689,7 +696,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
689
696
fn lower_foreign_item ( & mut self , i : & ForeignItem ) -> hir:: ForeignItem < ' hir > {
690
697
let def_id = self . resolver . local_def_id ( i. id ) ;
691
698
hir:: ForeignItem {
692
- hir_id : self . lower_node_id ( i. id ) ,
699
+ hir_id : self . lower_node_id ( i. id , i . span ) ,
693
700
ident : i. ident ,
694
701
attrs : self . lower_attrs ( & i. attrs ) ,
695
702
kind : match i. kind {
@@ -724,7 +731,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
724
731
725
732
fn lower_foreign_item_ref ( & mut self , i : & ForeignItem ) -> hir:: ForeignItemRef < ' hir > {
726
733
hir:: ForeignItemRef {
727
- id : hir:: ForeignItemId { hir_id : self . lower_node_id ( i. id ) } ,
734
+ id : hir:: ForeignItemId { hir_id : self . lower_node_id ( i. id , i . span ) } ,
728
735
ident : i. ident ,
729
736
span : i. span ,
730
737
vis : self . lower_visibility ( & i. vis , Some ( i. id ) ) ,
@@ -738,15 +745,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
738
745
fn lower_variant ( & mut self , v : & Variant ) -> hir:: Variant < ' hir > {
739
746
hir:: Variant {
740
747
attrs : self . lower_attrs ( & v. attrs ) ,
741
- data : self . lower_variant_data ( & v. data ) ,
748
+ data : self . lower_variant_data ( v . span , & v. data ) ,
742
749
disr_expr : v. disr_expr . as_ref ( ) . map ( |e| self . lower_anon_const ( e) ) ,
743
- id : self . lower_node_id ( v. id ) ,
750
+ id : self . lower_node_id ( v. id , v . span ) ,
744
751
ident : v. ident ,
745
752
span : v. span ,
746
753
}
747
754
}
748
755
749
- fn lower_variant_data ( & mut self , vdata : & VariantData ) -> hir:: VariantData < ' hir > {
756
+ fn lower_variant_data ( & mut self , span : Span , vdata : & VariantData ) -> hir:: VariantData < ' hir > {
750
757
match * vdata {
751
758
VariantData :: Struct ( ref fields, recovered) => hir:: VariantData :: Struct (
752
759
self . arena
@@ -756,9 +763,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
756
763
VariantData :: Tuple ( ref fields, id) => hir:: VariantData :: Tuple (
757
764
self . arena
758
765
. alloc_from_iter ( fields. iter ( ) . enumerate ( ) . map ( |f| self . lower_struct_field ( f) ) ) ,
759
- self . lower_node_id ( id) ,
766
+ self . lower_node_id ( id, span ) ,
760
767
) ,
761
- VariantData :: Unit ( id) => hir:: VariantData :: Unit ( self . lower_node_id ( id) ) ,
768
+ VariantData :: Unit ( id) => hir:: VariantData :: Unit ( self . lower_node_id ( id, span ) ) ,
762
769
}
763
770
}
764
771
@@ -777,7 +784,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
777
784
} ;
778
785
hir:: StructField {
779
786
span : f. span ,
780
- hir_id : self . lower_node_id ( f. id ) ,
787
+ hir_id : self . lower_node_id ( f. id , f . span ) ,
781
788
ident : match f. ident {
782
789
Some ( ident) => ident,
783
790
// FIXME(jseyfried): positional field hygiene.
@@ -824,7 +831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
824
831
} ;
825
832
826
833
hir:: TraitItem {
827
- hir_id : self . lower_node_id ( i. id ) ,
834
+ hir_id : self . lower_node_id ( i. id , i . span ) ,
828
835
ident : i. ident ,
829
836
attrs : self . lower_attrs ( & i. attrs ) ,
830
837
generics,
@@ -844,7 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
844
851
}
845
852
AssocItemKind :: MacCall ( ..) => unimplemented ! ( ) ,
846
853
} ;
847
- let id = hir:: TraitItemId { hir_id : self . lower_node_id ( i. id ) } ;
854
+ let id = hir:: TraitItemId { hir_id : self . lower_node_id ( i. id , i . span ) } ;
848
855
let defaultness = hir:: Defaultness :: Default { has_value : has_default } ;
849
856
hir:: TraitItemRef { id, ident : i. ident , span : i. span , defaultness, kind }
850
857
}
@@ -908,7 +915,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
908
915
let has_value = true ;
909
916
let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
910
917
hir:: ImplItem {
911
- hir_id : self . lower_node_id ( i. id ) ,
918
+ hir_id : self . lower_node_id ( i. id , i . span ) ,
912
919
ident : i. ident ,
913
920
attrs : self . lower_attrs ( & i. attrs ) ,
914
921
generics,
@@ -924,7 +931,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
924
931
let has_value = true ;
925
932
let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
926
933
hir:: ImplItemRef {
927
- id : hir:: ImplItemId { hir_id : self . lower_node_id ( i. id ) } ,
934
+ id : hir:: ImplItemId { hir_id : self . lower_node_id ( i. id , i . span ) } ,
928
935
ident : i. ident ,
929
936
span : i. span ,
930
937
vis : self . lower_visibility ( & i. vis , Some ( i. id ) ) ,
@@ -956,9 +963,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
956
963
VisibilityKind :: Restricted { ref path, id } => {
957
964
debug ! ( "lower_visibility: restricted path id = {:?}" , id) ;
958
965
let lowered_id = if let Some ( owner) = explicit_owner {
959
- self . lower_node_id_with_owner ( id, owner)
966
+ self . lower_node_id_with_owner ( id, owner, v . span )
960
967
} else {
961
- self . lower_node_id ( id)
968
+ self . lower_node_id ( id, v . span )
962
969
} ;
963
970
let res = self . expect_full_res ( id) ;
964
971
let res = self . lower_res ( res) ;
@@ -1013,7 +1020,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1013
1020
fn lower_param ( & mut self , param : & Param ) -> hir:: Param < ' hir > {
1014
1021
hir:: Param {
1015
1022
attrs : self . lower_attrs ( & param. attrs ) ,
1016
- hir_id : self . lower_node_id ( param. id ) ,
1023
+ hir_id : self . lower_node_id ( param. id , param . span ) ,
1017
1024
pat : self . lower_pat ( & param. pat ) ,
1018
1025
ty_span : param. ty . span ,
1019
1026
span : param. span ,
@@ -1463,7 +1470,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1463
1470
} ) ,
1464
1471
WherePredicate :: EqPredicate ( WhereEqPredicate { id, ref lhs_ty, ref rhs_ty, span } ) => {
1465
1472
hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1466
- hir_id : self . lower_node_id ( id) ,
1473
+ hir_id : self . lower_node_id ( id, span ) ,
1467
1474
lhs_ty : self . lower_ty ( lhs_ty, ImplTraitContext :: disallowed ( ) ) ,
1468
1475
rhs_ty : self . lower_ty ( rhs_ty, ImplTraitContext :: disallowed ( ) ) ,
1469
1476
span,
0 commit comments