@@ -12,6 +12,7 @@ use rustc_ast::{AttrArgs, DelimArgs, Expr, ExprKind, LitKind, MetaItemLit, Norma
1212use rustc_ast_pretty:: pprust;
1313use rustc_errors:: DiagCtxtHandle ;
1414use rustc_hir:: { self as hir, AttrPath } ;
15+ use rustc_session:: parse:: ParseSess ;
1516use rustc_span:: { ErrorGuaranteed , Ident , Span , Symbol , kw, sym} ;
1617
1718pub struct SegmentIterator < ' a > {
@@ -123,18 +124,18 @@ impl<'a> ArgParser<'a> {
123124 }
124125 }
125126
126- pub fn from_attr_args < ' sess > ( value : & ' a AttrArgs , dcx : DiagCtxtHandle < ' sess > ) -> Self {
127+ pub fn from_attr_args < ' sess > ( value : & ' a AttrArgs , psess : & ' sess ParseSess ) -> Self {
127128 match value {
128129 AttrArgs :: Empty => Self :: NoArgs ,
129130 AttrArgs :: Delimited ( args) if args. delim == Delimiter :: Parenthesis => {
130- Self :: List ( MetaItemListParser :: new ( args, dcx ) )
131+ Self :: List ( MetaItemListParser :: new ( args, psess ) )
131132 }
132133 AttrArgs :: Delimited ( args) => {
133134 Self :: List ( MetaItemListParser { sub_parsers : vec ! [ ] , span : args. dspan . entire ( ) } )
134135 }
135136 AttrArgs :: Eq { eq_span, expr } => Self :: NameValue ( NameValueParser {
136137 eq_span : * eq_span,
137- value : expr_to_lit ( dcx, & expr, * eq_span) ,
138+ value : expr_to_lit ( psess . dcx ( ) , & expr, * eq_span) ,
138139 value_span : expr. span ,
139140 } ) ,
140141 }
@@ -249,10 +250,10 @@ impl<'a> Debug for MetaItemParser<'a> {
249250impl < ' a > MetaItemParser < ' a > {
250251 /// Create a new parser from a [`NormalAttr`], which is stored inside of any
251252 /// [`ast::Attribute`](rustc_ast::Attribute)
252- pub fn from_attr < ' sess > ( attr : & ' a NormalAttr , dcx : DiagCtxtHandle < ' sess > ) -> Self {
253+ pub fn from_attr < ' sess > ( attr : & ' a NormalAttr , psess : & ' sess ParseSess ) -> Self {
253254 Self {
254255 path : PathParser :: Ast ( & attr. item . path ) ,
255- args : ArgParser :: from_attr_args ( & attr. item . args , dcx ) ,
256+ args : ArgParser :: from_attr_args ( & attr. item . args , psess ) ,
256257 }
257258 }
258259}
@@ -337,7 +338,7 @@ fn expr_to_lit(dcx: DiagCtxtHandle<'_>, expr: &Expr, span: Span) -> MetaItemLit
337338struct MetaItemListParserContext < ' a , ' sess > {
338339 // the tokens inside the delimiters, so `#[some::attr(a b c)]` would have `a b c` inside
339340 inside_delimiters : Peekable < TokenStreamIter < ' a > > ,
340- dcx : DiagCtxtHandle < ' sess > ,
341+ psess : & ' sess ParseSess ,
341342}
342343
343344impl < ' a , ' sess > MetaItemListParserContext < ' a , ' sess > {
@@ -414,7 +415,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
414415 Some ( TokenTree :: Delimited ( .., Delimiter :: Invisible ( _) , inner_tokens) ) => {
415416 MetaItemListParserContext {
416417 inside_delimiters : inner_tokens. iter ( ) . peekable ( ) ,
417- dcx : self . dcx ,
418+ psess : self . psess ,
418419 }
419420 . value ( )
420421 }
@@ -447,7 +448,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
447448 self . inside_delimiters . next ( ) ;
448449 return MetaItemListParserContext {
449450 inside_delimiters : inner_tokens. iter ( ) . peekable ( ) ,
450- dcx : self . dcx ,
451+ psess : self . psess ,
451452 }
452453 . next ( ) ;
453454 }
@@ -468,7 +469,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
468469 args : ArgParser :: List ( MetaItemListParser :: new_tts (
469470 inner_tokens. iter ( ) ,
470471 dspan. entire ( ) ,
471- self . dcx ,
472+ self . psess ,
472473 ) ) ,
473474 }
474475 }
@@ -521,12 +522,12 @@ pub struct MetaItemListParser<'a> {
521522}
522523
523524impl < ' a > MetaItemListParser < ' a > {
524- fn new < ' sess > ( delim : & ' a DelimArgs , dcx : DiagCtxtHandle < ' sess > ) -> Self {
525- MetaItemListParser :: new_tts ( delim. tokens . iter ( ) , delim. dspan . entire ( ) , dcx )
525+ fn new < ' sess > ( delim : & ' a DelimArgs , psess : & ' sess ParseSess ) -> Self {
526+ MetaItemListParser :: new_tts ( delim. tokens . iter ( ) , delim. dspan . entire ( ) , psess )
526527 }
527528
528- fn new_tts < ' sess > ( tts : TokenStreamIter < ' a > , span : Span , dcx : DiagCtxtHandle < ' sess > ) -> Self {
529- MetaItemListParserContext { inside_delimiters : tts. peekable ( ) , dcx } . parse ( span)
529+ fn new_tts < ' sess > ( tts : TokenStreamIter < ' a > , span : Span , psess : & ' sess ParseSess ) -> Self {
530+ MetaItemListParserContext { inside_delimiters : tts. peekable ( ) , psess } . parse ( span)
530531 }
531532
532533 /// Lets you pick and choose as what you want to parse each element in the list
0 commit comments