@@ -28,6 +28,7 @@ use util::nodemap::FxHashMap;
2828
2929use  syntax:: ast; 
3030use  syntax:: symbol:: Symbol ; 
31+ use  syntax_pos:: Span ; 
3132use  hir:: itemlikevisit:: ItemLikeVisitor ; 
3233use  hir; 
3334
@@ -104,17 +105,18 @@ struct LanguageItemCollector<'a, 'tcx: 'a> {
104105
105106impl <' a,  ' v,  ' tcx> ItemLikeVisitor <' v> for  LanguageItemCollector <' a,  ' tcx> { 
106107    fn  visit_item( & mut  self ,  item:  & hir:: Item )  { 
107-         if  let  Some ( value)  = extract( & item. attrs)  { 
108+         if  let  Some ( ( value,  span ) )  = extract( & item. attrs)  { 
108109            let  item_index = self . item_refs. get( & * value. as_str( ) ) . cloned( ) ; 
109110
110111            if  let  Some ( item_index)  = item_index { 
111112                let  def_id = self . tcx. hir. local_def_id( item. id) ; 
112113                self . collect_item( item_index,  def_id) ; 
113114            }  else { 
114-                 let  span = self . tcx. hir. span( item. id) ; 
115-                 span_err!( self . tcx. sess,  span,  E0522 , 
116-                           "definition of an unknown language item: `{}`." , 
117-                           value) ; 
115+                 let  mut  err = struct_span_err!( self . tcx. sess,  span,  E0522 , 
116+                                                "definition of an unknown language item: `{}`" , 
117+                                                value) ; 
118+                 err. span_label( span,  format!( "definition of unknown language item `{}`" ,  value) ) ; 
119+                 err. emit( ) ; 
118120            } 
119121        } 
120122    } 
@@ -177,11 +179,11 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
177179    } 
178180} 
179181
180- pub  fn  extract( attrs:  & [ ast:: Attribute ] )  -> Option <Symbol > { 
182+ pub  fn  extract( attrs:  & [ ast:: Attribute ] )  -> Option <( Symbol ,   Span ) > { 
181183    for  attribute in attrs { 
182184        if  attribute. check_name( "lang" )  { 
183185            if  let  Some ( value)  = attribute. value_str( )  { 
184-                 return  Some ( value) 
186+                 return  Some ( ( value,  attribute . span ) ) ; 
185187            } 
186188        } 
187189    } 
0 commit comments