@@ -50,6 +50,27 @@ impl<'sess> AttributeParser<'sess, Early> {
50
50
target_span : Span ,
51
51
target_node_id : NodeId ,
52
52
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 ,
53
74
) -> Option < Attribute > {
54
75
let mut parsed = Self :: parse_limited_all (
55
76
sess,
@@ -59,7 +80,7 @@ impl<'sess> AttributeParser<'sess, Early> {
59
80
target_span,
60
81
target_node_id,
61
82
features,
62
- ShouldEmit :: Nothing ,
83
+ should_emit ,
63
84
) ;
64
85
assert ! ( parsed. len( ) <= 1 ) ;
65
86
parsed. pop ( )
@@ -84,9 +105,8 @@ impl<'sess> AttributeParser<'sess, Early> {
84
105
target,
85
106
OmitDoc :: Skip ,
86
107
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) ;
90
110
} ,
91
111
)
92
112
}
@@ -121,8 +141,8 @@ impl<'sess> AttributeParser<'sess, Early> {
121
141
cx : & mut parser,
122
142
target_span,
123
143
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 ) ;
126
146
} ,
127
147
} ,
128
148
attr_span : attr. span ,
0 commit comments