@@ -50,6 +50,21 @@ type iterator = Ast_iterator.iterator
5050
5151let super = Ast_iterator. default_iterator
5252
53+ let warning_attribute_iterator =
54+ let structure_item self str_item =
55+ (match str_item.pstr_desc with
56+ | Pstr_attribute attr -> Builtin_attributes. warning_attribute attr
57+ | _ -> () );
58+ super.structure_item self str_item
59+ in
60+ let signature_item self sig_item =
61+ (match sig_item.psig_desc with
62+ | Psig_attribute attr -> Builtin_attributes. warning_attribute attr
63+ | _ -> () );
64+ super.signature_item self sig_item
65+ in
66+ {super with structure_item; signature_item}
67+
5368let check_constant loc (const : Parsetree.constant ) =
5469 match const with
5570 | Pconst_string (_ , Some s ) ->
@@ -148,28 +163,14 @@ let emit_external_warnings : iterator =
148163 | _ -> super.pat self pat);
149164 }
150165
151- let rec iter_warnings_on_stru (stru : Parsetree.structure ) =
152- match stru with
153- | [] -> ()
154- | head :: rest -> (
155- match head.pstr_desc with
156- | Pstr_attribute attr ->
157- Builtin_attributes. warning_attribute attr;
158- iter_warnings_on_stru rest
159- | _ -> () )
166+ let iter_warnings_on_structure (structure : Parsetree.structure ) =
167+ warning_attribute_iterator.structure warning_attribute_iterator structure
160168
161- let rec iter_warnings_on_sigi (stru : Parsetree.signature ) =
162- match stru with
163- | [] -> ()
164- | head :: rest -> (
165- match head.psig_desc with
166- | Psig_attribute attr ->
167- Builtin_attributes. warning_attribute attr;
168- iter_warnings_on_sigi rest
169- | _ -> () )
169+ let iter_warnings_on_signature (signature : Parsetree.signature ) =
170+ warning_attribute_iterator.signature warning_attribute_iterator signature
170171
171- let emit_external_warnings_on_structure (stru : Parsetree.structure ) =
172- emit_external_warnings.structure emit_external_warnings stru
172+ let emit_external_warnings_on_structure (structure : Parsetree.structure ) =
173+ emit_external_warnings.structure emit_external_warnings structure
173174
174- let emit_external_warnings_on_signature (sigi : Parsetree.signature ) =
175- emit_external_warnings.signature emit_external_warnings sigi
175+ let emit_external_warnings_on_signature (signature : Parsetree.signature ) =
176+ emit_external_warnings.signature emit_external_warnings signature
0 commit comments