@@ -26,7 +26,7 @@ use crate::attributes::stability::{
2626use  crate :: attributes:: transparency:: TransparencyParser ; 
2727use  crate :: attributes:: { AttributeParser  as  _,  Combine ,  Single } ; 
2828use  crate :: parser:: { ArgParser ,  MetaItemParser } ; 
29- use  crate :: session_diagnostics:: { AttributeParseError ,  AttributeParseErrorReason } ; 
29+ use  crate :: session_diagnostics:: { AttributeParseError ,  AttributeParseErrorReason ,   UnknownMetaItem } ; 
3030
3131macro_rules!  group_type { 
3232    ( $stage:  ty)  => { 
@@ -189,8 +189,16 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
189189        ( self . emit_lint ) ( AttributeLint  {  id,  span,  kind :  lint } ) ; 
190190    } 
191191
192+     pub ( crate )  fn  unknown_key ( 
193+         & self , 
194+         span :  Span , 
195+         found :  String , 
196+         options :  & ' static  [ & ' static  str ] , 
197+     )  -> ErrorGuaranteed  { 
198+         self . emit_err ( UnknownMetaItem  {  span,  item :  found,  expected :  options } ) 
199+     } 
200+ 
192201    pub ( crate )  fn  expected_string_literal ( & self ,  span :  Span )  -> ErrorGuaranteed  { 
193-         // 539? 
194202        self . emit_err ( AttributeParseError  { 
195203            span, 
196204            attr_span :  self . attr_span , 
@@ -200,12 +208,40 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
200208        } ) 
201209    } 
202210
203-     // pub(crate) fn expected_any_arguments(&self, span: Span) -> ErrorGuaranteed { 
204-     // 
205-     // } 
211+     pub ( crate )  fn  expected_list ( & self ,  span :  Span )  -> ErrorGuaranteed  { 
212+         self . emit_err ( AttributeParseError  { 
213+             span, 
214+             attr_span :  self . attr_span , 
215+             template :  self . template . clone ( ) , 
216+             attribute :  self . attr_path . clone ( ) , 
217+             reason :  AttributeParseErrorReason :: ExpectedList , 
218+         } ) 
219+     } 
220+ 
221+     /// emit an error that a `name = value` pair was expected at this span. The symbol can be given for 
222+      /// a nicer error message talking about the specific name that was found lacking a value. 
223+      pub ( crate )  fn  expected_name_value ( & self ,  span :  Span ,  name :  Option < Symbol > )  -> ErrorGuaranteed  { 
224+         self . emit_err ( AttributeParseError  { 
225+             span, 
226+             attr_span :  self . attr_span , 
227+             template :  self . template . clone ( ) , 
228+             attribute :  self . attr_path . clone ( ) , 
229+             reason :  AttributeParseErrorReason :: ExpectedNameValue ( name) , 
230+         } ) 
231+     } 
232+ 
233+     /// emit an error that a `name = value` pair was found where that name was already seen. 
234+      pub ( crate )  fn  duplicate_key ( & self ,  span :  Span ,  key :  Symbol )  -> ErrorGuaranteed  { 
235+         self . emit_err ( AttributeParseError  { 
236+             span, 
237+             attr_span :  self . attr_span , 
238+             template :  self . template . clone ( ) , 
239+             attribute :  self . attr_path . clone ( ) , 
240+             reason :  AttributeParseErrorReason :: DuplicateKey ( key) , 
241+         } ) 
242+     } 
206243
207244    pub ( crate )  fn  expected_single_argument ( & self ,  span :  Span )  -> ErrorGuaranteed  { 
208-         // E534? 
209245        self . emit_err ( AttributeParseError  { 
210246            span, 
211247            attr_span :  self . attr_span , 
@@ -218,15 +254,34 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
218254    pub ( crate )  fn  expected_specific_argument ( 
219255        & self , 
220256        span :  Span , 
221-         options :  Vec < & ' static  str > , 
257+         possibilities :  Vec < & ' static  str > , 
258+     )  -> ErrorGuaranteed  { 
259+         self . emit_err ( AttributeParseError  { 
260+             span, 
261+             attr_span :  self . attr_span , 
262+             template :  self . template . clone ( ) , 
263+             attribute :  self . attr_path . clone ( ) , 
264+             reason :  AttributeParseErrorReason :: ExpectedSpecificArgument  { 
265+                 possibilities, 
266+                 strings :  false , 
267+             } , 
268+         } ) 
269+     } 
270+ 
271+     pub ( crate )  fn  expected_specific_argument_strings ( 
272+         & self , 
273+         span :  Span , 
274+         possibilities :  Vec < & ' static  str > , 
222275    )  -> ErrorGuaranteed  { 
223-         // E535? 
224276        self . emit_err ( AttributeParseError  { 
225277            span, 
226278            attr_span :  self . attr_span , 
227279            template :  self . template . clone ( ) , 
228280            attribute :  self . attr_path . clone ( ) , 
229-             reason :  AttributeParseErrorReason :: ExpectedSpecificArgument ( options) , 
281+             reason :  AttributeParseErrorReason :: ExpectedSpecificArgument  { 
282+                 possibilities, 
283+                 strings :  true , 
284+             } , 
230285        } ) 
231286    } 
232287} 
0 commit comments