Rename variants_from_header optin to "experimental-enum-variants-from-header"

In preparation for "experimental-async-fn" as a completely orthogonal
experimental feature.
This commit is contained in:
David Tolnay 2022-01-18 17:19:36 -08:00
parent cf5bbe629e
commit d58307a1f0
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
9 changed files with 14 additions and 12 deletions

View File

@ -318,7 +318,7 @@ fn write_struct_decl(out: &mut OutFile, ident: &Pair) {
fn write_enum_decl(out: &mut OutFile, enm: &Enum) {
let repr = match &enm.repr {
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
EnumRepr::Foreign { .. } => return,
EnumRepr::Native { atom, .. } => *atom,
};
@ -382,7 +382,7 @@ fn write_opaque_type<'a>(out: &mut OutFile<'a>, ety: &'a ExternType, methods: &[
fn write_enum<'a>(out: &mut OutFile<'a>, enm: &'a Enum) {
let repr = match &enm.repr {
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
EnumRepr::Foreign { .. } => return,
EnumRepr::Native { atom, .. } => *atom,
};
@ -408,7 +408,7 @@ fn write_enum<'a>(out: &mut OutFile<'a>, enm: &'a Enum) {
fn check_enum<'a>(out: &mut OutFile<'a>, enm: &'a Enum) {
let repr = match &enm.repr {
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
EnumRepr::Foreign { .. } => return,
EnumRepr::Native { atom, .. } => *atom,
};

View File

@ -16,7 +16,7 @@ categories = ["development-tools::ffi"]
proc-macro = true
[features]
experimental = ["clang-ast", "flate2", "memmap", "serde", "serde_json"]
experimental-enum-variants-from-header = ["clang-ast", "flate2", "memmap", "serde", "serde_json"]
[dependencies]
proc-macro2 = "1.0"

View File

@ -36,7 +36,7 @@ pub fn bridge(mut ffi: Module) -> Result<TokenStream> {
let trusted = ffi.unsafety.is_some();
let namespace = &ffi.namespace;
let ref mut apis = syntax::parse_items(errors, content, trusted, namespace);
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
crate::load::load(errors, apis);
let ref types = Types::collect(errors, apis);
errors.propagate()?;

View File

@ -37,9 +37,9 @@ mod syntax;
mod tokens;
mod type_id;
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
mod clang;
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
mod load;
use crate::syntax::file::Module;

View File

@ -142,7 +142,9 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe
break;
}
}
} else if attr.path.is_ident("variants_from_header") && cfg!(feature = "experimental") {
} else if attr.path.is_ident("variants_from_header")
&& cfg!(feature = "experimental-enum-variants-from-header")
{
if let Err(err) = Nothing::parse.parse2(attr.tokens.clone()) {
cx.push(err);
}

View File

@ -180,7 +180,7 @@ impl Discriminant {
}
}
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
pub const fn checked_succ(self) -> Option<Self> {
match self.sign {
Sign::Negative => {

View File

@ -128,7 +128,7 @@ pub enum EnumRepr {
atom: Atom,
repr_type: Type,
},
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
Foreign {
rust_type: syn::Path,
},

View File

@ -286,7 +286,7 @@ impl ToTokens for EnumRepr {
fn to_tokens(&self, tokens: &mut TokenStream) {
match self {
EnumRepr::Native { atom, repr_type: _ } => atom.to_tokens(tokens),
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
EnumRepr::Foreign { rust_type } => rust_type.to_tokens(tokens),
}
}

View File

@ -92,7 +92,7 @@ impl<'a> Types<'a> {
EnumRepr::Native { atom: _, repr_type } => {
all.insert(repr_type);
}
#[cfg(feature = "experimental")]
#[cfg(feature = "experimental-enum-variants-from-header")]
EnumRepr::Foreign { rust_type: _ } => {}
}
let ident = &enm.name.rust;