11use std:: borrow:: Cow ;
2+ use std:: convert:: identity;
23
34use rustc_ast as ast;
45use rustc_ast:: { AttrStyle , NodeId , Safety } ;
@@ -12,7 +13,7 @@ use rustc_session::lint::BuiltinLintDiag;
1213use rustc_span:: { DUMMY_SP , Span , Symbol , sym} ;
1314
1415use crate :: context:: { AcceptContext , FinalizeContext , SharedContext , Stage } ;
15- use crate :: parser:: { ArgParser , MetaItemParser , PathParser } ;
16+ use crate :: parser:: { ArgParser , PathParser } ;
1617use crate :: session_diagnostics:: ParsedDescription ;
1718use crate :: { Early , Late , OmitDoc , ShouldEmit } ;
1819
@@ -143,22 +144,23 @@ impl<'sess> AttributeParser<'sess, Early> {
143144 } ;
144145 let parts =
145146 normal_attr. item . path . segments . iter ( ) . map ( |seg| seg. ident . name ) . collect :: < Vec < _ > > ( ) ;
146- let meta_parser = MetaItemParser :: from_attr ( normal_attr, & parts, & sess. psess , emit_errors) ?;
147- let path = meta_parser. path ( ) ;
148- let args = meta_parser. args ( ) ;
147+
148+ let path = AttrPath :: from_ast ( & normal_attr. item . path , identity) ;
149+ let args =
150+ ArgParser :: from_attr_args ( & normal_attr. item . args , & parts, & sess. psess , emit_errors) ?;
149151 Self :: parse_single_args (
150152 sess,
151153 attr. span ,
152154 normal_attr. item . span ( ) ,
153155 attr. style ,
154- path. get_attribute_path ( ) ,
156+ path,
155157 Some ( normal_attr. item . unsafety ) ,
156158 ParsedDescription :: Attribute ,
157159 target_span,
158160 target_node_id,
159161 features,
160162 emit_errors,
161- args,
163+ & args,
162164 parse_fn,
163165 template,
164166 )
@@ -325,15 +327,14 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
325327 n. item . path . segments . iter ( ) . map ( |seg| seg. ident . name ) . collect :: < Vec < _ > > ( ) ;
326328
327329 if let Some ( accepts) = S :: parsers ( ) . accepters . get ( parts. as_slice ( ) ) {
328- let Some ( parser ) = MetaItemParser :: from_attr (
329- n ,
330+ let Some ( args ) = ArgParser :: from_attr_args (
331+ & n . item . args ,
330332 & parts,
331333 & self . sess . psess ,
332334 self . stage . should_emit ( ) ,
333335 ) else {
334336 continue ;
335337 } ;
336- let args = parser. args ( ) ;
337338 for accept in accepts {
338339 let mut cx: AcceptContext < ' _ , ' sess , S > = AcceptContext {
339340 shared : SharedContext {
@@ -350,7 +351,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
350351 attr_path : attr_path. clone ( ) ,
351352 } ;
352353
353- ( accept. accept_fn ) ( & mut cx, args) ;
354+ ( accept. accept_fn ) ( & mut cx, & args) ;
354355 if !matches ! ( cx. stage. should_emit( ) , ShouldEmit :: Nothing ) {
355356 Self :: check_target ( & accept. allowed_targets , target, & mut cx) ;
356357 }
0 commit comments