File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -162,18 +162,30 @@ impl Clean<ExternalCrate> for CrateNum {
162
162
. collect ( )
163
163
} ;
164
164
165
+ let get_span =
166
+ |attr : & ast:: NestedMetaItem | Some ( attr. meta_item ( ) ?. name_value_literal ( ) ?. span ) ;
167
+
165
168
let as_keyword = |res : Res | {
166
169
if let Res :: Def ( DefKind :: Mod , def_id) = res {
167
170
let attrs = cx. tcx . get_attrs ( def_id) . clean ( cx) ;
168
171
let mut keyword = None ;
169
172
for attr in attrs. lists ( sym:: doc) {
170
- if let Some ( v) = attr. value_str ( ) {
171
- if attr. has_name ( sym:: keyword) {
172
- if v. is_doc_keyword ( ) {
173
- keyword = Some ( v. to_string ( ) ) ;
174
- break ;
173
+ if attr. has_name ( sym:: keyword) {
174
+ if let Some ( v) = attr. value_str ( ) {
175
+ let k = v. to_string ( ) ;
176
+ if !rustc_lexer:: is_ident ( & k) {
177
+ let sp = get_span ( & attr) . unwrap_or_else ( || attr. span ( ) ) ;
178
+ cx. tcx
179
+ . sess
180
+ . struct_span_err (
181
+ sp,
182
+ & format ! ( "`{}` is not a valid identifier" , v) ,
183
+ )
184
+ . emit ( ) ;
185
+ } else {
186
+ keyword = Some ( k) ;
175
187
}
176
- // FIXME: should warn on unknown keywords?
188
+ break ;
177
189
}
178
190
}
179
191
}
You can’t perform that action at this time.
0 commit comments