You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* handle feature gated simple enum variants
* test case for feature gated enum variants
* add towncrier newsfragment to pull request
* rename `attrs` to `cfg_attrs`
* generate a compiler error if cfg attributes disable all variants of enum
* test compiler error when all variants of enum disabled
* spanned compiler error when cfg features disable enum variants
// There's at least one variant of the enum without cfg attributes,
2448
+
// so the check is not necessary
2449
+
returnquote!{};
2450
+
}
2451
+
2452
+
for attr in cfg_attrs {
2453
+
iflet syn::Meta::List(meta) = &attr.meta{
2454
+
let cfg_tokens = &meta.tokens;
2455
+
conditions.push(quote!{ not(#cfg_tokens)});
2456
+
}
2457
+
}
2458
+
}
2459
+
2460
+
quote_spanned!{
2461
+
cls.span() =>
2462
+
#[cfg(all(#(#conditions),*))]
2463
+
::core::compile_error!(concat!("#[pyclass] can't be used on enums without any variants - all variants of enum `", stringify!(#cls),"` have been configured out by cfg attributes"));
2464
+
}
2465
+
}
2466
+
2398
2467
constUNIQUE_GET:&str = "`get` may only be specified once";
2399
2468
constUNIQUE_SET:&str = "`set` may only be specified once";
2400
2469
constUNIQUE_NAME:&str = "`name` may only be specified once";
Copy file name to clipboardExpand all lines: tests/ui/invalid_pyclass_enum.stderr
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,12 @@ error: The `ord` option requires the `eq` option.
66
66
83 | #[pyclass(ord)]
67
67
| ^^^
68
68
69
+
error: #[pyclass] can't be used on enums without any variants - all variants of enum `AllEnumVariantsDisabled` have been configured out by cfg attributes
70
+
--> tests/ui/invalid_pyclass_enum.rs:98:6
71
+
|
72
+
98 | enum AllEnumVariantsDisabled {
73
+
| ^^^^^^^^^^^^^^^^^^^^^^^
74
+
69
75
error[E0369]: binary operation `==` cannot be applied to type `&SimpleEqOptRequiresPartialEq`
0 commit comments