11use std:: borrow:: Cow ;
2+ use std:: convert:: identity;
23
34use rustc_ast as ast;
45use rustc_ast:: token:: DocFragmentKind ;
@@ -13,7 +14,7 @@ use rustc_session::lint::BuiltinLintDiag;
1314use rustc_span:: { DUMMY_SP , Span , Symbol , sym} ;
1415
1516use crate :: context:: { AcceptContext , FinalizeContext , SharedContext , Stage } ;
16- use crate :: parser:: { ArgParser , MetaItemParser , PathParser } ;
17+ use crate :: parser:: { ArgParser , PathParser } ;
1718use crate :: session_diagnostics:: ParsedDescription ;
1819use crate :: { Early , Late , OmitDoc , ShouldEmit } ;
1920
@@ -144,22 +145,23 @@ impl<'sess> AttributeParser<'sess, Early> {
144145 } ;
145146 let parts =
146147 normal_attr. item . path . segments . iter ( ) . map ( |seg| seg. ident . name ) . collect :: < Vec < _ > > ( ) ;
147- let meta_parser = MetaItemParser :: from_attr ( normal_attr, & parts, & sess. psess , emit_errors) ?;
148- let path = meta_parser. path ( ) ;
149- let args = meta_parser. args ( ) ;
148+
149+ let path = AttrPath :: from_ast ( & normal_attr. item . path , identity) ;
150+ let args =
151+ ArgParser :: from_attr_args ( & normal_attr. item . args , & parts, & sess. psess , emit_errors) ?;
150152 Self :: parse_single_args (
151153 sess,
152154 attr. span ,
153155 normal_attr. item . span ( ) ,
154156 attr. style ,
155- path. get_attribute_path ( ) ,
157+ path,
156158 Some ( normal_attr. item . unsafety ) ,
157159 ParsedDescription :: Attribute ,
158160 target_span,
159161 target_node_id,
160162 features,
161163 emit_errors,
162- args,
164+ & args,
163165 parse_fn,
164166 template,
165167 )
@@ -316,15 +318,14 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
316318 n. item . path . segments . iter ( ) . map ( |seg| seg. ident . name ) . collect :: < Vec < _ > > ( ) ;
317319
318320 if let Some ( accepts) = S :: parsers ( ) . accepters . get ( parts. as_slice ( ) ) {
319- let Some ( parser ) = MetaItemParser :: from_attr (
320- n ,
321+ let Some ( args ) = ArgParser :: from_attr_args (
322+ & n . item . args ,
321323 & parts,
322324 & self . sess . psess ,
323325 self . stage . should_emit ( ) ,
324326 ) else {
325327 continue ;
326328 } ;
327- let args = parser. args ( ) ;
328329
329330 // Special-case handling for `#[doc = "..."]`: if we go through with
330331 // `DocParser`, the order of doc comments will be messed up because `///`
@@ -373,7 +374,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
373374 attr_path : attr_path. clone ( ) ,
374375 } ;
375376
376- ( accept. accept_fn ) ( & mut cx, args) ;
377+ ( accept. accept_fn ) ( & mut cx, & args) ;
377378 if !matches ! ( cx. stage. should_emit( ) , ShouldEmit :: Nothing ) {
378379 Self :: check_target ( & accept. allowed_targets , target, & mut cx) ;
379380 }
0 commit comments