@@ -28,6 +28,7 @@ use util::nodemap::FxHashMap;
28
28
29
29
use syntax:: ast;
30
30
use syntax:: symbol:: Symbol ;
31
+ use syntax_pos:: Span ;
31
32
use hir:: itemlikevisit:: ItemLikeVisitor ;
32
33
use hir;
33
34
@@ -104,17 +105,18 @@ struct LanguageItemCollector<'a, 'tcx: 'a> {
104
105
105
106
impl <' a, ' v, ' tcx> ItemLikeVisitor <' v> for LanguageItemCollector <' a, ' tcx> {
106
107
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) {
108
109
let item_index = self . item_refs. get( & * value. as_str( ) ) . cloned( ) ;
109
110
110
111
if let Some ( item_index) = item_index {
111
112
let def_id = self . tcx. hir. local_def_id( item. id) ;
112
113
self . collect_item( item_index, def_id) ;
113
114
} 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( ) ;
118
120
}
119
121
}
120
122
}
@@ -177,11 +179,11 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
177
179
}
178
180
}
179
181
180
- pub fn extract( attrs: & [ ast:: Attribute ] ) -> Option <Symbol > {
182
+ pub fn extract( attrs: & [ ast:: Attribute ] ) -> Option <( Symbol , Span ) > {
181
183
for attribute in attrs {
182
184
if attribute. check_name( "lang" ) {
183
185
if let Some ( value) = attribute. value_str( ) {
184
- return Some ( value)
186
+ return Some ( ( value, attribute . span ) ) ;
185
187
}
186
188
}
187
189
}
0 commit comments