@@ -50,6 +50,27 @@ impl<'sess> AttributeParser<'sess, Early> {
5050 target_span : Span ,
5151 target_node_id : NodeId ,
5252 features : Option < & ' sess Features > ,
53+ ) -> Option < Attribute > {
54+ Self :: parse_limited_should_emit (
55+ sess,
56+ attrs,
57+ sym,
58+ target_span,
59+ target_node_id,
60+ features,
61+ ShouldEmit :: Nothing ,
62+ )
63+ }
64+
65+ /// Usually you want `parse_limited`, which defaults to no errors.
66+ pub fn parse_limited_should_emit (
67+ sess : & ' sess Session ,
68+ attrs : & [ ast:: Attribute ] ,
69+ sym : Symbol ,
70+ target_span : Span ,
71+ target_node_id : NodeId ,
72+ features : Option < & ' sess Features > ,
73+ should_emit : ShouldEmit ,
5374 ) -> Option < Attribute > {
5475 let mut parsed = Self :: parse_limited_all (
5576 sess,
@@ -59,7 +80,7 @@ impl<'sess> AttributeParser<'sess, Early> {
5980 target_span,
6081 target_node_id,
6182 features,
62- ShouldEmit :: Nothing ,
83+ should_emit ,
6384 ) ;
6485 assert ! ( parsed. len( ) <= 1 ) ;
6586 parsed. pop ( )
@@ -84,9 +105,8 @@ impl<'sess> AttributeParser<'sess, Early> {
84105 target,
85106 OmitDoc :: Skip ,
86107 std:: convert:: identity,
87- |_lint| {
88- // FIXME: Can't emit lints here for now
89- // This branch can be hit when an attribute produces a warning during early parsing (such as attributes on macro calls)
108+ |lint| {
109+ crate :: lints:: emit_attribute_lint ( & lint, sess) ;
90110 } ,
91111 )
92112 }
@@ -121,8 +141,8 @@ impl<'sess> AttributeParser<'sess, Early> {
121141 cx : & mut parser,
122142 target_span,
123143 target_id : target_node_id,
124- emit_lint : & mut |_lint | {
125- panic ! ( "can't emit lints here for now (nothing uses this atm)" ) ;
144+ emit_lint : & mut |lint | {
145+ crate :: lints:: emit_attribute_lint ( & lint , sess ) ;
126146 } ,
127147 } ,
128148 attr_span : attr. span ,
0 commit comments