@@ -12,6 +12,7 @@ use rustc_ast::{AttrArgs, DelimArgs, Expr, ExprKind, LitKind, MetaItemLit, Norma
12
12
use rustc_ast_pretty:: pprust;
13
13
use rustc_errors:: DiagCtxtHandle ;
14
14
use rustc_hir:: { self as hir, AttrPath } ;
15
+ use rustc_session:: parse:: ParseSess ;
15
16
use rustc_span:: { ErrorGuaranteed , Ident , Span , Symbol , kw, sym} ;
16
17
17
18
pub struct SegmentIterator < ' a > {
@@ -123,18 +124,18 @@ impl<'a> ArgParser<'a> {
123
124
}
124
125
}
125
126
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 {
127
128
match value {
128
129
AttrArgs :: Empty => Self :: NoArgs ,
129
130
AttrArgs :: Delimited ( args) if args. delim == Delimiter :: Parenthesis => {
130
- Self :: List ( MetaItemListParser :: new ( args, dcx ) )
131
+ Self :: List ( MetaItemListParser :: new ( args, psess ) )
131
132
}
132
133
AttrArgs :: Delimited ( args) => {
133
134
Self :: List ( MetaItemListParser { sub_parsers : vec ! [ ] , span : args. dspan . entire ( ) } )
134
135
}
135
136
AttrArgs :: Eq { eq_span, expr } => Self :: NameValue ( NameValueParser {
136
137
eq_span : * eq_span,
137
- value : expr_to_lit ( dcx, & expr, * eq_span) ,
138
+ value : expr_to_lit ( psess . dcx ( ) , & expr, * eq_span) ,
138
139
value_span : expr. span ,
139
140
} ) ,
140
141
}
@@ -249,10 +250,10 @@ impl<'a> Debug for MetaItemParser<'a> {
249
250
impl < ' a > MetaItemParser < ' a > {
250
251
/// Create a new parser from a [`NormalAttr`], which is stored inside of any
251
252
/// [`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 {
253
254
Self {
254
255
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 ) ,
256
257
}
257
258
}
258
259
}
@@ -337,7 +338,7 @@ fn expr_to_lit(dcx: DiagCtxtHandle<'_>, expr: &Expr, span: Span) -> MetaItemLit
337
338
struct MetaItemListParserContext < ' a , ' sess > {
338
339
// the tokens inside the delimiters, so `#[some::attr(a b c)]` would have `a b c` inside
339
340
inside_delimiters : Peekable < TokenStreamIter < ' a > > ,
340
- dcx : DiagCtxtHandle < ' sess > ,
341
+ psess : & ' sess ParseSess ,
341
342
}
342
343
343
344
impl < ' a , ' sess > MetaItemListParserContext < ' a , ' sess > {
@@ -414,7 +415,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
414
415
Some ( TokenTree :: Delimited ( .., Delimiter :: Invisible ( _) , inner_tokens) ) => {
415
416
MetaItemListParserContext {
416
417
inside_delimiters : inner_tokens. iter ( ) . peekable ( ) ,
417
- dcx : self . dcx ,
418
+ psess : self . psess ,
418
419
}
419
420
. value ( )
420
421
}
@@ -447,7 +448,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
447
448
self . inside_delimiters . next ( ) ;
448
449
return MetaItemListParserContext {
449
450
inside_delimiters : inner_tokens. iter ( ) . peekable ( ) ,
450
- dcx : self . dcx ,
451
+ psess : self . psess ,
451
452
}
452
453
. next ( ) ;
453
454
}
@@ -468,7 +469,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
468
469
args : ArgParser :: List ( MetaItemListParser :: new_tts (
469
470
inner_tokens. iter ( ) ,
470
471
dspan. entire ( ) ,
471
- self . dcx ,
472
+ self . psess ,
472
473
) ) ,
473
474
}
474
475
}
@@ -521,12 +522,12 @@ pub struct MetaItemListParser<'a> {
521
522
}
522
523
523
524
impl < ' 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 )
526
527
}
527
528
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)
530
531
}
531
532
532
533
/// Lets you pick and choose as what you want to parse each element in the list
0 commit comments