|
28 | 28 | *) |
29 | 29 | let is_bs_attribute txt = |
30 | 30 | match txt with |
31 | | - (* TODO #6636: | "as "| "int" *) |
32 | | - | "bs" | "config" | "ignore" | "optional" | "string" | "uncurry" | "unwrap" -> |
| 31 | + (* TODO #6636: "int" *) |
| 32 | + | "as" | "bs" | "config" | "ignore" | "optional" | "string" | "uncurry" |
| 33 | + | "unwrap" -> |
33 | 34 | true |
34 | 35 | | _ -> false |
35 | 36 |
|
36 | | -let used_attributes : string Asttypes.loc Hash_set_poly.t = |
37 | | - Hash_set_poly.create 16 |
38 | | - |
39 | | -(* |
40 | | - let dump_attribute fmt = (fun ( (sloc : string Asttypes.loc),payload) -> |
41 | | - Format.fprintf fmt "@[%s %a@]" sloc.txt (Printast.payload 0 ) payload |
42 | | - ) |
43 | | -
|
44 | | -let dump_used_attributes fmt = |
45 | | - Format.fprintf fmt "Used attributes Listing Start:@."; |
46 | | - Hash_set_poly.iter used_attributes (fun attr -> dump_attribute fmt attr) ; |
47 | | - Format.fprintf fmt "Used attributes Listing End:@." |
48 | | - *) |
49 | | - |
50 | | -(* only mark non-ghost used bs attribute *) |
51 | | -let mark_used_bs_attribute ((x, _) : Parsetree.attribute) = |
52 | | - if not x.loc.loc_ghost then Hash_set_poly.add used_attributes x |
53 | | - |
54 | 37 | let warn_unused_attribute ((({txt; loc} as sloc), _) : Parsetree.attribute) = |
55 | 38 | if |
56 | 39 | is_bs_attribute txt && (not loc.loc_ghost) |
57 | | - && not (Hash_set_poly.mem used_attributes sloc) |
| 40 | + && not (Used_attributes.is_used_attribute sloc) |
58 | 41 | then |
59 | 42 | (* |
60 | 43 | dump_used_attributes Format.err_formatter; |
@@ -126,11 +109,15 @@ let emit_external_warnings : iterator = |
126 | 109 | (fun self lbl -> |
127 | 110 | Ext_list.iter lbl.pld_attributes (fun attr -> |
128 | 111 | match attr with |
129 | | - | {txt = "as"}, _ -> mark_used_bs_attribute attr |
| 112 | + | {txt = "as"}, _ -> Used_attributes.mark_used_attribute attr |
130 | 113 | | _ -> ()); |
131 | 114 | super.label_declaration self lbl); |
132 | 115 | constructor_declaration = |
133 | 116 | (fun self ({pcd_name = {txt; loc}} as ctr) -> |
| 117 | + let _ = |
| 118 | + Ast_untagged_variants.process_tag_type |
| 119 | + ctr.pcd_attributes (* mark @as used in variant cases *) |
| 120 | + in |
134 | 121 | (match txt with |
135 | 122 | | "false" | "true" | "()" -> |
136 | 123 | Location.raise_errorf ~loc "%s can not be redefined " txt |
|
0 commit comments