Skip to content

Commit f3eb624

Browse files
authored
silence non_upper_case_globals lint on __match_args__ (#4705)
1 parent a42e53e commit f3eb624

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

newsfragments/4705.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix `non_upper_case_globals` lint firing for generated `__match_args__` on complex enums.

pyo3-macros-backend/src/pyclass.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,19 +1186,21 @@ fn impl_complex_enum_variant_match_args(
11861186
variant_cls_type: &syn::Type,
11871187
field_names: &mut Vec<Ident>,
11881188
) -> (MethodAndMethodDef, syn::ImplItemConst) {
1189+
let ident = format_ident!("__match_args__");
11891190
let match_args_const_impl: syn::ImplItemConst = {
11901191
let args_tp = field_names.iter().map(|_| {
11911192
quote! { &'static str }
11921193
});
11931194
parse_quote! {
1194-
const __match_args__: ( #(#args_tp,)* ) = (
1195+
#[allow(non_upper_case_globals)]
1196+
const #ident: ( #(#args_tp,)* ) = (
11951197
#(stringify!(#field_names),)*
11961198
);
11971199
}
11981200
};
11991201

12001202
let spec = ConstSpec {
1201-
rust_ident: format_ident!("__match_args__"),
1203+
rust_ident: ident,
12021204
attributes: ConstAttributes {
12031205
is_class_attr: true,
12041206
name: None,

0 commit comments

Comments
 (0)