1- use core:: panic;
21use std:: fmt:: { Debug , Display } ;
32use std:: iter:: Peekable ;
43
@@ -231,7 +230,7 @@ impl<'a> Debug for MetaItemParser<'a> {
231230
232231impl < ' a > MetaItemParser < ' a > {
233232 /// Create a new parser from a [`NormalAttr`], which is stored inside of any
234- /// [`ast::Attribute`](Attribute)
233+ /// [`ast::Attribute`](rustc_ast:: Attribute)
235234 pub fn from_attr ( attr : & ' a NormalAttr , dcx : DiagCtxtHandle < ' a > ) -> Self {
236235 Self {
237236 path : PathParser :: Ast ( & attr. item . path ) ,
@@ -268,8 +267,6 @@ impl<'a> MetaItemParser<'a> {
268267 /// - `#[rustfmt::skip]`: `rustfmt::skip` is a path
269268 /// - `#[allow(clippy::complexity)]`: `clippy::complexity` is a path
270269 /// - `#[inline]`: `inline` is a single segment path
271- /// - `#[inline(always)]`: `always` is a single segment path, but `inline` is *not and
272- /// should be parsed using [`list`](Self::list)
273270 pub fn path ( & self ) -> ( PathParser < ' a > , & ArgParser < ' a > ) {
274271 self . deconstruct ( )
275272 }
@@ -291,11 +288,8 @@ impl<'a> MetaItemParser<'a> {
291288 ///
292289 /// Some examples:
293290 /// - `#[inline]`: `inline` is a word
294- /// - `#[rustfmt::skip]`: `rustfmt::skip` is a path, and not a word
295- /// - `#[inline(always)]`: `always` is a word, but `inline` is *not and should be parsed
296- /// using [`path_list`](Self::path_list)
297- /// - `#[allow(clippy::complexity)]`: `clippy::complexity` is *not* a word, and should instead be parsed
298- /// using [`path`](Self::path)
291+ /// - `#[rustfmt::skip]`: `rustfmt::skip` is a path,
292+ /// and not a word and should instead be parsed using [`path`](Self::path)
299293 pub fn word ( & self ) -> Option < ( Ident , & ArgParser < ' a > ) > {
300294 let ( path, args) = self . deconstruct ( ) ;
301295 Some ( ( path. word ( ) ?, args) )
@@ -406,7 +400,7 @@ impl<'a> MetaItemListParserContext<'a> {
406400 {
407401 segments. push ( Ident :: new ( name, span) ) ;
408402 } else {
409- unreachable ! ( )
403+ return None ;
410404 }
411405 if let Some ( TokenTree :: Token ( Token { kind : token:: PathSep , .. } , _) ) =
412406 self . inside_delimiters . peek ( )
@@ -422,16 +416,14 @@ impl<'a> MetaItemListParserContext<'a> {
422416 Some ( TokenTree :: Token (
423417 Token { kind : token:: OpenDelim ( _) | token:: CloseDelim ( _) , .. } ,
424418 _,
425- ) ) => {
426- panic ! ( "Should be `AttrTokenTree::Delimited`, not delim tokens: {:?}" , tt) ;
427- }
428- Some ( x) => {
419+ ) ) => None ,
420+ Some ( _) => {
429421 // malformed attributes can get here. We can't crash, but somewhere else should've
430422 // already warned for this.
431- self . dcx . span_delayed_bug (
432- x. span ( ) ,
433- format ! ( "unexpected token {x:?} in built-in attribute path" ) ,
434- ) ;
423+ // self.dcx.span_delayed_bug(
424+ // x.span(),
425+ // format!("unexpected token {x:?} in built-in attribute path"),
426+ // );
435427 None
436428 }
437429 None => None ,
@@ -450,7 +442,7 @@ impl<'a> MetaItemListParserContext<'a> {
450442 Some ( TokenTree :: Token ( ref token, _) ) => {
451443 if let Some ( s) = MetaItemLit :: from_token ( token) { Some ( s) } else { None }
452444 }
453- x => unreachable ! ( "{x:?}" ) ,
445+ x => None ,
454446 }
455447 }
456448
@@ -532,9 +524,9 @@ impl<'a> MetaItemListParserContext<'a> {
532524 ) ) ,
533525 }
534526 }
535- Some ( TokenTree :: Delimited ( span , ..) ) => {
527+ Some ( TokenTree :: Delimited ( _ , ..) ) => {
536528 self . inside_delimiters . next ( ) ;
537- self . dcx . span_delayed_bug ( span. entire ( ) , "wrong delimiters" ) ;
529+ // self.dcx.span_delayed_bug(span.entire(), "wrong delimiters");
538530 return None ;
539531 }
540532 Some ( TokenTree :: Token ( Token { kind : token:: Eq , span } , _) ) => {
0 commit comments