@@ -44,11 +44,12 @@ pub fn parse_cfg<S: Stage>(
4444 args : & ArgParser ,
4545) -> Option < CfgEntry > {
4646 let ArgParser :: List ( list) = args else {
47- cx. expected_list ( cx. attr_span , args) ;
47+ let attr_span = cx. attr_span ;
48+ cx. adcx ( ) . expected_list ( attr_span, args) ;
4849 return None ;
4950 } ;
5051 let Some ( single) = list. single ( ) else {
51- cx. expected_single_argument ( list. span ) ;
52+ cx. adcx ( ) . expected_single_argument ( list. span ) ;
5253 return None ;
5354 } ;
5455 parse_cfg_entry ( cx, single) . ok ( )
@@ -63,7 +64,7 @@ pub fn parse_cfg_entry<S: Stage>(
6364 ArgParser :: List ( list) => match meta. path ( ) . word_sym ( ) {
6465 Some ( sym:: not) => {
6566 let Some ( single) = list. single ( ) else {
66- return Err ( cx. expected_single_argument ( list. span ) ) ;
67+ return Err ( cx. adcx ( ) . expected_single_argument ( list. span ) ) ;
6768 } ;
6869 CfgEntry :: Not ( Box :: new ( parse_cfg_entry ( cx, single) ?) , list. span )
6970 }
@@ -87,14 +88,14 @@ pub fn parse_cfg_entry<S: Stage>(
8788 a @ ( ArgParser :: NoArgs | ArgParser :: NameValue ( _) ) => {
8889 let Some ( name) = meta. path ( ) . word_sym ( ) . filter ( |s| !s. is_path_segment_keyword ( ) )
8990 else {
90- return Err ( cx. expected_identifier ( meta. path ( ) . span ( ) ) ) ;
91+ return Err ( cx. adcx ( ) . expected_identifier ( meta. path ( ) . span ( ) ) ) ;
9192 } ;
9293 parse_name_value ( name, meta. path ( ) . span ( ) , a. name_value ( ) , meta. span ( ) , cx) ?
9394 }
9495 } ,
9596 MetaItemOrLitParser :: Lit ( lit) => match lit. kind {
9697 LitKind :: Bool ( b) => CfgEntry :: Bool ( b, lit. span ) ,
97- _ => return Err ( cx. expected_identifier ( lit. span ) ) ,
98+ _ => return Err ( cx. adcx ( ) . expected_identifier ( lit. span ) ) ,
9899 } ,
99100 } )
100101}
@@ -152,17 +153,17 @@ fn parse_cfg_entry_target<S: Stage>(
152153 for sub_item in list. mixed ( ) {
153154 // First, validate that this is a NameValue item
154155 let Some ( sub_item) = sub_item. meta_item ( ) else {
155- cx. expected_name_value ( sub_item. span ( ) , None ) ;
156+ cx. adcx ( ) . expected_name_value ( sub_item. span ( ) , None ) ;
156157 continue ;
157158 } ;
158159 let Some ( nv) = sub_item. args ( ) . name_value ( ) else {
159- cx. expected_name_value ( sub_item. span ( ) , None ) ;
160+ cx. adcx ( ) . expected_name_value ( sub_item. span ( ) , None ) ;
160161 continue ;
161162 } ;
162163
163164 // Then, parse it as a name-value item
164165 let Some ( name) = sub_item. path ( ) . word_sym ( ) . filter ( |s| !s. is_path_segment_keyword ( ) ) else {
165- return Err ( cx. expected_identifier ( sub_item. path ( ) . span ( ) ) ) ;
166+ return Err ( cx. adcx ( ) . expected_identifier ( sub_item. path ( ) . span ( ) ) ) ;
166167 } ;
167168 let name = Symbol :: intern ( & format ! ( "target_{name}" ) ) ;
168169 if let Ok ( cfg) =
@@ -187,9 +188,9 @@ pub(crate) fn parse_name_value<S: Stage>(
187188 None => None ,
188189 Some ( value) => {
189190 let Some ( value_str) = value. value_as_str ( ) else {
190- return Err (
191- cx . expected_string_literal ( value . value_span , Some ( value . value_as_lit ( ) ) )
192- ) ;
191+ return Err ( cx
192+ . adcx ( )
193+ . expected_string_literal ( value . value_span , Some ( value . value_as_lit ( ) ) ) ) ;
193194 } ;
194195 Some ( ( value_str, value. value_span ) )
195196 }
@@ -335,8 +336,10 @@ pub fn parse_cfg_attr(
335336 path : AttrPath :: from_ast ( & cfg_attr. get_normal_item ( ) . path , identity) ,
336337 description : ParsedDescription :: Attribute ,
337338 reason,
338- suggestions : CFG_ATTR_TEMPLATE
339- . suggestions ( AttrSuggestionStyle :: Attribute ( cfg_attr. style ) , sym:: cfg_attr) ,
339+ suggestions : session_diagnostics:: AttributeParseErrorSuggestions :: CreatedByTemplate (
340+ CFG_ATTR_TEMPLATE
341+ . suggestions ( AttrSuggestionStyle :: Attribute ( cfg_attr. style ) , sym:: cfg_attr) ,
342+ ) ,
340343 } ) ;
341344 }
342345 }
0 commit comments