@@ -13,7 +13,7 @@ use rustc_hir::def::{DefKind, Res};
1313use rustc_hir:: def_id:: LocalDefId ;
1414use rustc_span:: source_map:: { respan, DesugaringKind } ;
1515use rustc_span:: symbol:: { kw, sym, Ident } ;
16- use rustc_span:: Span ;
16+ use rustc_span:: { Span , DUMMY_SP } ;
1717use rustc_target:: spec:: abi;
1818
1919use smallvec:: { smallvec, SmallVec } ;
@@ -34,8 +34,8 @@ impl ItemLowerer<'_, '_, '_> {
3434}
3535
3636impl < ' 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 ) ;
3939
4040 self . lctx . modules . insert (
4141 hir_id,
@@ -230,7 +230,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
230230
231231 if let ItemKind :: MacroDef ( MacroDef { ref body, macro_rules } ) = i. kind {
232232 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 ) ;
234234 let body = P ( self . lower_mac_args ( body) ) ;
235235 self . exported_macros . push ( hir:: MacroDef {
236236 ident,
@@ -248,7 +248,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
248248
249249 let kind = self . lower_item_kind ( i. span , i. id , & mut ident, attrs, & mut vis, & i. kind ) ;
250250
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+ } )
252259 }
253260
254261 fn lower_item_kind (
@@ -357,14 +364,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
357364 self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
358365 ) ,
359366 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) ;
361368 hir:: ItemKind :: Struct (
362369 struct_def,
363370 self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
364371 )
365372 }
366373 ItemKind :: Union ( ref vdata, ref generics) => {
367- let vdata = self . lower_variant_data ( vdata) ;
374+ let vdata = self . lower_variant_data ( span , vdata) ;
368375 hir:: ItemKind :: Union (
369376 vdata,
370377 self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
@@ -395,7 +402,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
395402 // method, it will not be considered an in-band
396403 // lifetime to be added, but rather a reference to a
397404 // 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 ) ;
399406 let ( generics, ( trait_ref, lowered_ty) ) = self . add_in_band_defs (
400407 ast_generics,
401408 def_id,
@@ -537,7 +544,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
537544 let span = path. span ;
538545
539546 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 ) ;
541548 let res = this. lower_res ( res) ;
542549 let path = this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
543550 let kind = hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) ;
@@ -594,7 +601,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
594601
595602 // Add all the nested `PathListItem`s to the HIR.
596603 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 ) ;
598605
599606 let mut prefix = prefix. clone ( ) ;
600607
@@ -663,7 +670,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
663670 let segments =
664671 self . arena . alloc_from_iter ( path. segments . iter ( ) . map ( |seg| hir:: PathSegment {
665672 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 ) ) ,
667674 res : seg. res ,
668675 args : None ,
669676 infer_args : seg. infer_args ,
@@ -679,7 +686,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
679686 hir:: VisibilityKind :: Restricted { ref path, hir_id : _ } => {
680687 hir:: VisibilityKind :: Restricted {
681688 path : self . rebuild_use_path ( path) ,
682- hir_id : self . next_id ( ) ,
689+ hir_id : self . next_id ( vis . span ) ,
683690 }
684691 }
685692 } ;
@@ -689,7 +696,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
689696 fn lower_foreign_item ( & mut self , i : & ForeignItem ) -> hir:: ForeignItem < ' hir > {
690697 let def_id = self . resolver . local_def_id ( i. id ) ;
691698 hir:: ForeignItem {
692- hir_id : self . lower_node_id ( i. id ) ,
699+ hir_id : self . lower_node_id ( i. id , i . span ) ,
693700 ident : i. ident ,
694701 attrs : self . lower_attrs ( & i. attrs ) ,
695702 kind : match i. kind {
@@ -724,7 +731,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
724731
725732 fn lower_foreign_item_ref ( & mut self , i : & ForeignItem ) -> hir:: ForeignItemRef < ' hir > {
726733 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 ) } ,
728735 ident : i. ident ,
729736 span : i. span ,
730737 vis : self . lower_visibility ( & i. vis , Some ( i. id ) ) ,
@@ -738,15 +745,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
738745 fn lower_variant ( & mut self , v : & Variant ) -> hir:: Variant < ' hir > {
739746 hir:: Variant {
740747 attrs : self . lower_attrs ( & v. attrs ) ,
741- data : self . lower_variant_data ( & v. data ) ,
748+ data : self . lower_variant_data ( v . span , & v. data ) ,
742749 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 ) ,
744751 ident : v. ident ,
745752 span : v. span ,
746753 }
747754 }
748755
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 > {
750757 match * vdata {
751758 VariantData :: Struct ( ref fields, recovered) => hir:: VariantData :: Struct (
752759 self . arena
@@ -756,9 +763,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
756763 VariantData :: Tuple ( ref fields, id) => hir:: VariantData :: Tuple (
757764 self . arena
758765 . 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 ) ,
760767 ) ,
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 ) ) ,
762769 }
763770 }
764771
@@ -777,7 +784,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
777784 } ;
778785 hir:: StructField {
779786 span : f. span ,
780- hir_id : self . lower_node_id ( f. id ) ,
787+ hir_id : self . lower_node_id ( f. id , f . span ) ,
781788 ident : match f. ident {
782789 Some ( ident) => ident,
783790 // FIXME(jseyfried): positional field hygiene.
@@ -824,7 +831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
824831 } ;
825832
826833 hir:: TraitItem {
827- hir_id : self . lower_node_id ( i. id ) ,
834+ hir_id : self . lower_node_id ( i. id , i . span ) ,
828835 ident : i. ident ,
829836 attrs : self . lower_attrs ( & i. attrs ) ,
830837 generics,
@@ -844,7 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
844851 }
845852 AssocItemKind :: MacCall ( ..) => unimplemented ! ( ) ,
846853 } ;
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 ) } ;
848855 let defaultness = hir:: Defaultness :: Default { has_value : has_default } ;
849856 hir:: TraitItemRef { id, ident : i. ident , span : i. span , defaultness, kind }
850857 }
@@ -908,7 +915,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
908915 let has_value = true ;
909916 let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
910917 hir:: ImplItem {
911- hir_id : self . lower_node_id ( i. id ) ,
918+ hir_id : self . lower_node_id ( i. id , i . span ) ,
912919 ident : i. ident ,
913920 attrs : self . lower_attrs ( & i. attrs ) ,
914921 generics,
@@ -924,7 +931,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
924931 let has_value = true ;
925932 let ( defaultness, _) = self . lower_defaultness ( i. kind . defaultness ( ) , has_value) ;
926933 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 ) } ,
928935 ident : i. ident ,
929936 span : i. span ,
930937 vis : self . lower_visibility ( & i. vis , Some ( i. id ) ) ,
@@ -956,9 +963,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
956963 VisibilityKind :: Restricted { ref path, id } => {
957964 debug ! ( "lower_visibility: restricted path id = {:?}" , id) ;
958965 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 )
960967 } else {
961- self . lower_node_id ( id)
968+ self . lower_node_id ( id, v . span )
962969 } ;
963970 let res = self . expect_full_res ( id) ;
964971 let res = self . lower_res ( res) ;
@@ -1013,7 +1020,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10131020 fn lower_param ( & mut self , param : & Param ) -> hir:: Param < ' hir > {
10141021 hir:: Param {
10151022 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 ) ,
10171024 pat : self . lower_pat ( & param. pat ) ,
10181025 ty_span : param. ty . span ,
10191026 span : param. span ,
@@ -1463,7 +1470,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14631470 } ) ,
14641471 WherePredicate :: EqPredicate ( WhereEqPredicate { id, ref lhs_ty, ref rhs_ty, span } ) => {
14651472 hir:: WherePredicate :: EqPredicate ( hir:: WhereEqPredicate {
1466- hir_id : self . lower_node_id ( id) ,
1473+ hir_id : self . lower_node_id ( id, span ) ,
14671474 lhs_ty : self . lower_ty ( lhs_ty, ImplTraitContext :: disallowed ( ) ) ,
14681475 rhs_ty : self . lower_ty ( rhs_ty, ImplTraitContext :: disallowed ( ) ) ,
14691476 span,
0 commit comments