This repository was archived by the owner on May 28, 2025. It is now read-only.
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 {
162162 . collect ( )
163163 } ;
164164
165+ let get_span =
166+ |attr : & ast:: NestedMetaItem | Some ( attr. meta_item ( ) ?. name_value_literal ( ) ?. span ) ;
167+
165168 let as_keyword = |res : Res | {
166169 if let Res :: Def ( DefKind :: Mod , def_id) = res {
167170 let attrs = cx. tcx . get_attrs ( def_id) . clean ( cx) ;
168171 let mut keyword = None ;
169172 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) ;
175187 }
176- // FIXME: should warn on unknown keywords?
188+ break ;
177189 }
178190 }
179191 }
You can’t perform that action at this time.
0 commit comments