mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 15:19:44 +00:00
Implement variants_from_header checking
This commit is contained in:
parent
15bf509509
commit
dd8320320c
@ -349,7 +349,7 @@ fn check_api_enum(cx: &mut Check, enm: &Enum) {
|
||||
check_reserved_name(cx, &enm.name.rust);
|
||||
check_lifetimes(cx, &enm.generics);
|
||||
|
||||
if enm.variants.is_empty() && !enm.explicit_repr {
|
||||
if enm.variants.is_empty() && !enm.explicit_repr && !enm.variants_from_header {
|
||||
let span = span_for_enum_error(enm);
|
||||
cx.error(
|
||||
span,
|
||||
@ -357,6 +357,14 @@ fn check_api_enum(cx: &mut Check, enm: &Enum) {
|
||||
);
|
||||
}
|
||||
|
||||
if enm.variants_from_header && !enm.variants.is_empty() {
|
||||
let span = span_for_enum_error(enm);
|
||||
cx.error(
|
||||
span,
|
||||
"enum with #![variants_from_header] must be written with no explicit variants",
|
||||
);
|
||||
}
|
||||
|
||||
for derive in &enm.derives {
|
||||
if derive.what == Trait::Default || derive.what == Trait::ExternType {
|
||||
let msg = format!("derive({}) on shared enum is not supported", derive);
|
||||
|
Loading…
Reference in New Issue
Block a user