From 631871c553e16e020ea4161530b76d03b0c9bc3f Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Tue, 29 May 2018 12:33:02 +0200 Subject: Update quote and proc-macro. I give up on the doc comments. This is a rebase of #1334 keeping the formatting of the comments and using TokenStream::from_str instead because one can hope. Fixes #1407. --- Cargo.lock | 14 +- Cargo.toml | 4 +- src/codegen/helpers.rs | 67 ++-- src/codegen/impl_debug.rs | 16 +- src/codegen/impl_partialeq.rs | 9 +- src/codegen/mod.rs | 202 ++++++------ src/codegen/struct_layout.rs | 11 +- src/ir/context.rs | 10 +- src/ir/function.rs | 4 +- src/ir/objc.rs | 9 +- src/lib.rs | 2 +- tests/expectations/tests/accessors.rs | 31 +- tests/expectations/tests/annotation_hide.rs | 12 +- .../tests/array-of-zero-sized-types.rs | 16 +- .../expectations/tests/bitfield-32bit-overflow.rs | 23 +- tests/expectations/tests/bitfield-large.rs | 23 +- .../tests/bitfield-method-same-name.rs | 23 +- tests/expectations/tests/bitfield_align.rs | 23 +- tests/expectations/tests/bitfield_align_2.rs | 23 +- .../expectations/tests/bitfield_method_mangling.rs | 23 +- .../expectations/tests/blacklist-and-impl-debug.rs | 11 +- tests/expectations/tests/class_use_as.rs | 12 +- tests/expectations/tests/comment-indent.rs | 44 +-- tests/expectations/tests/constify-enum.rs | 2 +- .../tests/contains-vs-inherits-zero-sized.rs | 20 +- .../tests/convert-cpp-comment-to-rust.rs | 8 +- .../tests/derive-bitfield-method-same-name.rs | 30 +- tests/expectations/tests/derive-clone.rs | 12 +- tests/expectations/tests/derive-clone_1_0.rs | 14 +- .../tests/derive-debug-bitfield-core.rs | 16 - tests/expectations/tests/derive-debug-bitfield.rs | 23 +- .../tests/derive-default-and-blacklist.rs | 13 +- .../tests/derive-hash-and-blacklist.rs | 11 +- .../expectations/tests/derive-hash-blacklisting.rs | 15 +- .../derive-hash-struct-with-anon-struct-float.rs | 12 +- .../tests/derive-hash-struct-with-float-array.rs | 12 +- .../tests/derive-hash-struct-with-pointer.rs | 9 +- .../tests/derive-hash-template-def-float.rs | 12 +- .../tests/derive-hash-template-inst-float.rs | 16 +- .../tests/derive-partialeq-and-blacklist.rs | 13 +- .../tests/derive-partialeq-bitfield.rs | 26 +- tests/expectations/tests/derive-partialeq-union.rs | 12 +- .../tests/derive-partialeq-union_1_0.rs | 11 +- .../tests/divide-by-zero-in-struct-layout.rs | 23 +- tests/expectations/tests/doggo-or-null.rs | 21 +- tests/expectations/tests/enum-doc-bitfield.rs | 20 +- tests/expectations/tests/enum-doc-mod.rs | 20 +- tests/expectations/tests/enum-doc-rusty.rs | 20 +- tests/expectations/tests/enum-doc.rs | 20 +- tests/expectations/tests/enum-variant-replaces.rs | 21 +- ...erit-from-template-instantiation-with-vtable.rs | 21 +- tests/expectations/tests/issue-1034.rs | 23 +- .../tests/issue-1076-unnamed-bitfield-alignment.rs | 23 +- tests/expectations/tests/issue-537.rs | 30 +- .../tests/issue-648-derive-debug-with-padding.rs | 26 +- .../tests/issue-739-pointer-wide-bitfield.rs | 23 +- tests/expectations/tests/issue-816.rs | 23 +- .../tests/issue-848-replacement-system-include.rs | 22 +- .../issue-944-derive-copy-and-blacklisting.rs | 4 +- tests/expectations/tests/issue_315.rs | 14 +- tests/expectations/tests/jsval_layout_opaque.rs | 61 ++-- .../expectations/tests/jsval_layout_opaque_1_0.rs | 61 ++-- tests/expectations/tests/layout_align.rs | 28 +- tests/expectations/tests/layout_arp.rs | 32 +- tests/expectations/tests/layout_array.rs | 64 ++-- tests/expectations/tests/layout_array_too_long.rs | 42 +-- tests/expectations/tests/layout_cmdline_token.rs | 53 ++-- tests/expectations/tests/layout_eth_conf.rs | 348 ++++++++++----------- tests/expectations/tests/layout_eth_conf_1_0.rs | 348 ++++++++++----------- tests/expectations/tests/layout_kni_mbuf.rs | 10 +- .../expectations/tests/layout_large_align_field.rs | 80 ++--- tests/expectations/tests/layout_mbuf.rs | 90 +++--- tests/expectations/tests/layout_mbuf_1_0.rs | 90 +++--- .../type_alias_template_specialized.rs | 2 +- .../type_alias_template_specialized.rs | 2 +- .../libclang-4/type_alias_template_specialized.rs | 2 +- .../libclang-5/type_alias_template_specialized.rs | 4 +- tests/expectations/tests/no-derive-debug.rs | 15 +- tests/expectations/tests/no-derive-default.rs | 15 +- tests/expectations/tests/no_copy.rs | 5 +- tests/expectations/tests/only_bitfields.rs | 23 +- .../tests/opaque-template-inst-member-2.rs | 18 +- .../tests/opaque-template-inst-member.rs | 17 +- tests/expectations/tests/opaque_in_struct.rs | 5 +- tests/expectations/tests/opaque_pointer.rs | 7 +- tests/expectations/tests/opaque_typedef.rs | 4 +- tests/expectations/tests/private.rs | 10 +- tests/expectations/tests/reparented_replacement.rs | 4 +- tests/expectations/tests/replace_template_alias.rs | 16 +- tests/expectations/tests/replace_use.rs | 5 +- tests/expectations/tests/replaces_double.rs | 4 +- tests/expectations/tests/struct_with_bitfields.rs | 23 +- tests/expectations/tests/template.rs | 27 +- tests/expectations/tests/templatized-bitfield.rs | 16 +- tests/expectations/tests/union_bitfield.rs | 23 +- tests/expectations/tests/union_bitfield_1_0.rs | 16 - .../tests/union_with_anon_struct_bitfield.rs | 23 +- .../tests/union_with_anon_struct_bitfield_1_0.rs | 23 +- tests/expectations/tests/weird_bitfields.rs | 23 +- tests/expectations/tests/zero-sized-array.rs | 21 +- 100 files changed, 1311 insertions(+), 1602 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49515751..c520fcbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,8 +38,8 @@ dependencies = [ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -177,7 +177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.3.5" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -190,10 +190,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.5.2" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -368,9 +368,9 @@ dependencies = [ "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "898696750eb5c3ce5eb5afbfbe46e7f7c4e1936e19d3e97be4b7937da7b6d114" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -"checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4" +"checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" +"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" diff --git a/Cargo.toml b/Cargo.toml index 8e8945ca..4e4f81cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,12 +51,12 @@ clap = "2" clang-sys = { version = "0.26", features = ["runtime", "clang_6_0"] } lazy_static = "1" peeking_take_while = "0.1.2" -quote = { version = "0.5", default-features = false } +quote = { version = "0.6", default-features = false } regex = "1.0" which = "1.0.2" # New validation in 0.3.6 breaks bindgen-integration: # https://github.com/alexcrichton/proc-macro2/commit/489c642. -proc-macro2 = { version = "0.3.2, < 0.3.6", default-features = false } +proc-macro2 = { version = "0.4", default-features = false } [dependencies.env_logger] optional = true diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index 02909d57..aea4b1fb 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -2,58 +2,54 @@ use ir::context::BindgenContext; use ir::layout::Layout; -use quote; -use proc_macro2::{Term, Span}; +use proc_macro2::{self, Ident, Span}; +use quote::TokenStreamExt; pub mod attributes { - use quote; - use proc_macro2::{Term, Span}; + use proc_macro2::{self, Ident, Span}; - pub fn repr(which: &str) -> quote::Tokens { - let which = Term::new(which, Span::call_site()); + pub fn repr(which: &str) -> proc_macro2::TokenStream { + let which = Ident::new(which, Span::call_site()); quote! { #[repr( #which )] } } - pub fn repr_list(which_ones: &[&str]) -> quote::Tokens { - let which_ones = which_ones.iter().cloned().map(|one| Term::new(one, Span::call_site())); + pub fn repr_list(which_ones: &[&str]) -> proc_macro2::TokenStream { + let which_ones = which_ones.iter().cloned().map(|one| Ident::new(one, Span::call_site())); quote! { #[repr( #( #which_ones ),* )] } } - pub fn derives(which_ones: &[&str]) -> quote::Tokens { - let which_ones = which_ones.iter().cloned().map(|one| Term::new(one, Span::call_site())); + pub fn derives(which_ones: &[&str]) -> proc_macro2::TokenStream { + let which_ones = which_ones.iter().cloned().map(|one| Ident::new(one, Span::call_site())); quote! { #[derive( #( #which_ones ),* )] } } - pub fn inline() -> quote::Tokens { + pub fn inline() -> proc_macro2::TokenStream { quote! { #[inline] } } - pub fn must_use() -> quote::Tokens { + pub fn must_use() -> proc_macro2::TokenStream { quote! { #[must_use] } } - pub fn doc(comment: String) -> quote::Tokens { - // Doc comments are already preprocessed into nice `///` formats by the - // time they get here. Just make sure that we have newlines around it so - // that nothing else gets wrapped into the comment. - let mut tokens = quote! {}; - tokens.append(Term::new("\n", Span::call_site())); - tokens.append(Term::new(&comment, Span::call_site())); - tokens.append(Term::new("\n", Span::call_site())); - tokens + pub fn doc(comment: String) -> proc_macro2::TokenStream { + use std::str::FromStr; + + // NOTE(emilio): By this point comments are already preprocessed and in + // `///` form. Quote turns them into `#[doc]` comments, but oh well. + proc_macro2::TokenStream::from_str(&comment).unwrap() } - pub fn link_name(name: &str) -> quote::Tokens { + pub fn link_name(name: &str) -> proc_macro2::TokenStream { // LLVM mangles the name by default but it's already mangled. // Prefixing the name with \u{1} should tell LLVM to not mangle it. let name = format!("\u{1}{}", name); @@ -65,7 +61,7 @@ pub mod attributes { /// Generates a proper type for a field or type with a given `Layout`, that is, /// a type with the correct size and alignment restrictions. -pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens { +pub fn blob(ctx: &BindgenContext, layout: Layout) -> proc_macro2::TokenStream { let opaque = layout.opaque(); // FIXME(emilio, #412): We fall back to byte alignment, but there are @@ -80,7 +76,7 @@ pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens { } }; - let ty_name = Term::new(ty_name, Span::call_site()); + let ty_name = Ident::new(ty_name, Span::call_site()); let data_len = opaque.array_size(ctx).unwrap_or(layout.size); @@ -96,14 +92,14 @@ pub fn blob(ctx: &BindgenContext, layout: Layout) -> quote::Tokens { } /// Integer type of the same size as the given `Layout`. -pub fn integer_type(ctx: &BindgenContext, layout: Layout) -> Option { +pub fn integer_type(ctx: &BindgenContext, layout: Layout) -> Option { let name = Layout::known_type_for_size(ctx, layout.size)?; - let name = Term::new(name, Span::call_site()); + let name = Ident::new(name, Span::call_site()); Some(quote! { #name }) } /// Generates a bitfield allocation unit type for a type with the given `Layout`. -pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> quote::Tokens { +pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> proc_macro2::TokenStream { let mut tokens = quote! {}; if ctx.options().enable_cxx_namespaces { @@ -130,10 +126,9 @@ pub mod ast_ty { use ir::function::FunctionSig; use ir::layout::Layout; use ir::ty::FloatKind; - use quote; use proc_macro2; - pub fn raw_type(ctx: &BindgenContext, name: &str) -> quote::Tokens { + pub fn raw_type(ctx: &BindgenContext, name: &str) -> proc_macro2::TokenStream { let ident = ctx.rust_ident_raw(name); match ctx.options().ctypes_prefix { Some(ref prefix) => { @@ -152,7 +147,7 @@ pub mod ast_ty { ctx: &BindgenContext, fk: FloatKind, layout: Option, - ) -> quote::Tokens { + ) -> proc_macro2::TokenStream { // TODO: we probably should take the type layout into account more // often? // @@ -192,25 +187,25 @@ pub mod ast_ty { } } - pub fn int_expr(val: i64) -> quote::Tokens { + pub fn int_expr(val: i64) -> proc_macro2::TokenStream { // Don't use quote! { #val } because that adds the type suffix. let val = proc_macro2::Literal::i64_unsuffixed(val); quote!(#val) } - pub fn uint_expr(val: u64) -> quote::Tokens { + pub fn uint_expr(val: u64) -> proc_macro2::TokenStream { // Don't use quote! { #val } because that adds the type suffix. let val = proc_macro2::Literal::u64_unsuffixed(val); quote!(#val) } - pub fn byte_array_expr(bytes: &[u8]) -> quote::Tokens { + pub fn byte_array_expr(bytes: &[u8]) -> proc_macro2::TokenStream { let mut bytes: Vec<_> = bytes.iter().cloned().collect(); bytes.push(0); quote! { [ #(#bytes),* ] } } - pub fn cstr_expr(mut string: String) -> quote::Tokens { + pub fn cstr_expr(mut string: String) -> proc_macro2::TokenStream { string.push('\0'); let b = proc_macro2::Literal::byte_string(&string.as_bytes()); quote! { @@ -221,7 +216,7 @@ pub mod ast_ty { pub fn float_expr( ctx: &BindgenContext, f: f64, - ) -> Result { + ) -> Result { if f.is_finite() { let val = proc_macro2::Literal::f64_unsuffixed(f); @@ -255,7 +250,7 @@ pub mod ast_ty { pub fn arguments_from_signature( signature: &FunctionSig, ctx: &BindgenContext, - ) -> Vec { + ) -> Vec { let mut unnamed_arguments = 0; signature .argument_types() diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs index 8759bf27..d429e328 100644 --- a/src/codegen/impl_debug.rs +++ b/src/codegen/impl_debug.rs @@ -3,14 +3,14 @@ use ir::context::BindgenContext; use ir::derive::CanTriviallyDeriveDebug; use ir::item::{HasTypeParamInArray, IsOpaque, Item, ItemCanonicalName}; use ir::ty::{RUST_DERIVE_IN_ARRAY_LIMIT, TypeKind}; -use quote; +use proc_macro2; pub fn gen_debug_impl( ctx: &BindgenContext, fields: &[Field], item: &Item, kind: CompKind, -) -> quote::Tokens { +) -> proc_macro2::TokenStream { let struct_name = item.canonical_name(ctx); let mut format_string = format!("{} {{{{ ", struct_name); let mut tokens = vec![]; @@ -63,7 +63,7 @@ pub trait ImplDebug<'a> { &self, ctx: &BindgenContext, extra: Self::Extra, - ) -> Option<(String, Vec)>; + ) -> Option<(String, Vec)>; } impl<'a> ImplDebug<'a> for FieldData { @@ -73,7 +73,7 @@ impl<'a> ImplDebug<'a> for FieldData { &self, ctx: &BindgenContext, _: Self::Extra, - ) -> Option<(String, Vec)> { + ) -> Option<(String, Vec)> { if let Some(name) = self.name() { ctx.resolve_item(self.ty()).impl_debug(ctx, name) } else { @@ -89,7 +89,7 @@ impl<'a> ImplDebug<'a> for BitfieldUnit { &self, ctx: &BindgenContext, _: Self::Extra, - ) -> Option<(String, Vec)> { + ) -> Option<(String, Vec)> { let mut format_string = String::new(); let mut tokens = vec![]; for (i, bitfield) in self.bitfields().iter().enumerate() { @@ -118,7 +118,7 @@ impl<'a> ImplDebug<'a> for Item { &self, ctx: &BindgenContext, name: &str, - ) -> Option<(String, Vec)> { + ) -> Option<(String, Vec)> { let name_ident = ctx.rust_ident(name); // We don't know if blacklisted items `impl Debug` or not, so we can't @@ -136,8 +136,8 @@ impl<'a> ImplDebug<'a> for Item { fn debug_print( name: &str, - name_ident: quote::Tokens, - ) -> Option<(String, Vec)> { + name_ident: proc_macro2::TokenStream, + ) -> Option<(String, Vec)> { Some(( format!("{}: {{:?}}", name), vec![quote! { diff --git a/src/codegen/impl_partialeq.rs b/src/codegen/impl_partialeq.rs index c8ff6313..ca61b4bf 100644 --- a/src/codegen/impl_partialeq.rs +++ b/src/codegen/impl_partialeq.rs @@ -3,7 +3,6 @@ use ir::comp::{CompInfo, CompKind, Field, FieldMethods}; use ir::context::BindgenContext; use ir::item::{IsOpaque, Item}; use ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT}; -use quote; use proc_macro2; /// Generate a manual implementation of `PartialEq` trait for the @@ -12,8 +11,8 @@ pub fn gen_partialeq_impl( ctx: &BindgenContext, comp_info: &CompInfo, item: &Item, - ty_for_impl: "e::Tokens, -) -> Option { + ty_for_impl: &proc_macro2::TokenStream, +) -> Option { let mut tokens = vec![]; if item.is_opaque(ctx, &()) { @@ -71,8 +70,8 @@ pub fn gen_partialeq_impl( }) } -fn gen_field(ctx: &BindgenContext, ty_item: &Item, name: &str) -> quote::Tokens { - fn quote_equals(name_ident: proc_macro2::Term) -> quote::Tokens { +fn gen_field(ctx: &BindgenContext, ty_item: &Item, name: &str) -> proc_macro2::TokenStream { + fn quote_equals(name_ident: proc_macro2::Ident) -> proc_macro2::TokenStream { quote! { self.#name_ident == other.#name_ident } } diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 9405f11b..d2b77d6a 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -37,8 +37,8 @@ use ir::template::{AsTemplateParam, TemplateInstantiation, TemplateParameters}; use ir::ty::{Type, TypeKind}; use ir::var::Var; -use quote; -use proc_macro2::{self, Term, Span}; +use quote::TokenStreamExt; +use proc_macro2::{self, Ident, Span}; use std; use std::borrow::Cow; @@ -48,11 +48,12 @@ use std::collections::hash_map::{Entry, HashMap}; use std::fmt::Write; use std::iter; use std::ops; +use std::str::FromStr; // Name of type defined in constified enum module pub static CONSTIFIED_ENUM_MODULE_REPR_NAME: &'static str = "Type"; -fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec { +fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec { let mut path = vec![quote! { self }]; if ctx.options().enable_cxx_namespaces { @@ -64,7 +65,7 @@ fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec { path } -fn root_import(ctx: &BindgenContext, module: &Item) -> quote::Tokens { +fn root_import(ctx: &BindgenContext, module: &Item) -> proc_macro2::TokenStream { assert!(ctx.options().enable_cxx_namespaces, "Somebody messed it up"); assert!(module.is_module()); @@ -76,7 +77,7 @@ fn root_import(ctx: &BindgenContext, module: &Item) -> quote::Tokens { let mut tokens = quote! {}; - tokens.append_separated(path, Term::new("::", Span::call_site())); + tokens.append_separated(path, quote!(::)); quote! { #[allow(unused_imports)] @@ -85,7 +86,7 @@ fn root_import(ctx: &BindgenContext, module: &Item) -> quote::Tokens { } struct CodegenResult<'a> { - items: Vec, + items: Vec, /// A monotonic counter used to add stable unique id's to stuff that doesn't /// need to be referenced by anything. @@ -212,7 +213,7 @@ impl<'a> CodegenResult<'a> { self.vars_seen.insert(name.into()); } - fn inner(&mut self, cb: F) -> Vec + fn inner(&mut self, cb: F) -> Vec where F: FnOnce(&mut Self), { @@ -231,7 +232,7 @@ impl<'a> CodegenResult<'a> { } impl<'a> ops::Deref for CodegenResult<'a> { - type Target = Vec; + type Target = Vec; fn deref(&self) -> &Self::Target { &self.items @@ -247,11 +248,11 @@ impl<'a> ops::DerefMut for CodegenResult<'a> { /// A trait to convert a rust type into a pointer, optionally const, to the same /// type. trait ToPtr { - fn to_ptr(self, is_const: bool) -> quote::Tokens; + fn to_ptr(self, is_const: bool) -> proc_macro2::TokenStream; } -impl ToPtr for quote::Tokens { - fn to_ptr(self, is_const: bool) -> quote::Tokens { +impl ToPtr for proc_macro2::TokenStream { + fn to_ptr(self, is_const: bool) -> proc_macro2::TokenStream { if is_const { quote! { *const #self } } else { @@ -260,7 +261,7 @@ impl ToPtr for quote::Tokens { } } -/// An extension trait for `quote::Tokens` that lets us append any implicit +/// An extension trait for `proc_macro2::TokenStream` that lets us append any implicit /// template parameters that exist for some type, if necessary. trait AppendImplicitTemplateParams { fn append_implicit_template_params( @@ -270,7 +271,7 @@ trait AppendImplicitTemplateParams { ); } -impl AppendImplicitTemplateParams for quote::Tokens { +impl AppendImplicitTemplateParams for proc_macro2::TokenStream { fn append_implicit_template_params( &mut self, ctx: &BindgenContext, @@ -439,10 +440,7 @@ impl CodeGenerator for Module { if let Some(raw_lines) = ctx.options().module_lines.get(&path) { for raw_line in raw_lines { found_any = true; - // FIXME(emilio): The use of `Term` is an abuse, but we abuse it - // in a bunch more places. - let line = Term::new(raw_line, Span::call_site()); - result.push(quote! { #line }); + result.push(proc_macro2::TokenStream::from_str(raw_line).unwrap()); } } @@ -756,7 +754,7 @@ impl CodeGenerator for Type { pub use }); let path = top_level_path(ctx, item); - tokens.append_separated(path, Term::new("::", Span::call_site())); + tokens.append_separated(path, quote!(::)); tokens.append_all(quote! { :: #inner_rust_type as #rust_name ; }); @@ -868,7 +866,7 @@ impl<'a> TryToRustTy for Vtable<'a> { &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { let name = ctx.rust_ident(self.canonical_name(ctx)); Ok(quote! { #name @@ -963,8 +961,8 @@ trait FieldCodegen<'a> { methods: &mut M, extra: Self::Extra, ) where - F: Extend, - M: Extend; + F: Extend, + M: Extend; } impl<'a> FieldCodegen<'a> for Field { @@ -983,8 +981,8 @@ impl<'a> FieldCodegen<'a> for Field { methods: &mut M, _: (), ) where - F: Extend, - M: Extend, + F: Extend, + M: Extend, { match *self { Field::DataMember(ref data) => { @@ -1035,8 +1033,8 @@ impl<'a> FieldCodegen<'a> for FieldData { methods: &mut M, _: (), ) where - F: Extend, - M: Extend, + F: Extend, + M: Extend, { // Bitfields are handled by `FieldCodegen` implementations for // `BitfieldUnit` and `Bitfield`. @@ -1170,8 +1168,8 @@ impl<'a> FieldCodegen<'a> for FieldData { impl BitfieldUnit { /// Get the constructor name for this bitfield unit. - fn ctor_name(&self) -> quote::Tokens { - let ctor_name = Term::new(&format!("new_bitfield_{}", self.nth()), Span::call_site()); + fn ctor_name(&self) -> proc_macro2::TokenStream { + let ctor_name = Ident::new(&format!("new_bitfield_{}", self.nth()), Span::call_site()); quote! { #ctor_name } @@ -1189,9 +1187,9 @@ impl Bitfield { fn extend_ctor_impl( &self, ctx: &BindgenContext, - param_name: quote::Tokens, - mut ctor_impl: quote::Tokens, - ) -> quote::Tokens { + param_name: proc_macro2::TokenStream, + mut ctor_impl: proc_macro2::TokenStream, + ) -> proc_macro2::TokenStream { let bitfield_ty = ctx.resolve_type(self.ty()); let bitfield_ty_layout = bitfield_ty.layout(ctx).expect( "Bitfield without layout? Gah!", @@ -1235,8 +1233,8 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit { methods: &mut M, _: (), ) where - F: Extend, - M: Extend, + F: Extend, + M: Extend, { result.saw_bitfield_unit(); @@ -1333,7 +1331,7 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit { fn bitfield_getter_name( ctx: &BindgenContext, bitfield: &Bitfield, -) -> quote::Tokens { +) -> proc_macro2::TokenStream { let name = bitfield.getter_name(); let name = ctx.rust_ident_raw(name); quote! { #name } @@ -1342,7 +1340,7 @@ fn bitfield_getter_name( fn bitfield_setter_name( ctx: &BindgenContext, bitfield: &Bitfield, -) -> quote::Tokens { +) -> proc_macro2::TokenStream { let setter = bitfield.setter_name(); let setter = ctx.rust_ident_raw(setter); quote! { #setter } @@ -1364,13 +1362,13 @@ impl<'a> FieldCodegen<'a> for Bitfield { methods: &mut M, (unit_field_name, bitfield_representable_as_int): (&'a str, &mut bool), ) where - F: Extend, - M: Extend, + F: Extend, + M: Extend, { let prefix = ctx.trait_prefix(); let getter_name = bitfield_getter_name(ctx, self); let setter_name = bitfield_setter_name(ctx, self); - let unit_field_ident = Term::new(unit_field_name, Span::call_site()); + let unit_field_ident = Ident::new(unit_field_name, Span::call_site()); let bitfield_ty_item = ctx.resolve_item(self.ty()); let bitfield_ty = bitfield_ty_item.expect_type(); @@ -1805,7 +1803,7 @@ impl CodeGenerator for CompInfo { if self.found_unknown_attr() { warn!( "Type {} has an unknown attribute that may affect layout", - canonical_ident.as_str() + canonical_ident ); } @@ -1819,7 +1817,7 @@ impl CodeGenerator for CompInfo { if ctx.options().layout_tests && !self.is_forward_declaration() { if let Some(layout) = layout { let fn_name = - format!("bindgen_test_layout_{}", canonical_ident.as_str()); + format!("bindgen_test_layout_{}", canonical_ident); let fn_name = ctx.rust_ident_raw(fn_name); let prefix = ctx.trait_prefix(); let size_of_expr = quote! { @@ -1881,7 +1879,7 @@ impl CodeGenerator for CompInfo { }) }) }) - .collect::>(); + .collect::>(); asserts }; @@ -2021,7 +2019,7 @@ trait MethodCodegen { fn codegen_method<'a>( &self, ctx: &BindgenContext, - methods: &mut Vec, + methods: &mut Vec, method_names: &mut HashMap, result: &mut CodegenResult<'a>, parent: &CompInfo, @@ -2032,7 +2030,7 @@ impl MethodCodegen for Method { fn codegen_method<'a>( &self, ctx: &BindgenContext, - methods: &mut Vec, + methods: &mut Vec, method_names: &mut HashMap, result: &mut CodegenResult<'a>, _parent: &CompInfo, @@ -2237,24 +2235,24 @@ impl std::str::FromStr for EnumVariation { enum EnumBuilder<'a> { Rust { codegen_depth: usize, - attrs: Vec, - ident: Term, - tokens: quote::Tokens, + attrs: Vec, + ident: Ident, + tokens: proc_macro2::TokenStream, emitted_any_variants: bool, }, Bitfield { codegen_depth: usize, canonical_name: &'a str, - tokens: quote::Tokens, + tokens: proc_macro2::TokenStream, }, Consts { - variants: Vec, + variants: Vec, codegen_depth: usize, }, ModuleConsts { codegen_depth: usize, module_name: &'a str, - module_items: Vec, + module_items: Vec, }, } @@ -2273,12 +2271,12 @@ impl<'a> EnumBuilder<'a> { /// the representation, and which variation it should be generated as. fn new( name: &'a str, - attrs: Vec, - repr: quote::Tokens, + attrs: Vec, + repr: proc_macro2::TokenStream, enum_variation: EnumVariation, enum_codegen_depth: usize, ) -> Self { - let ident = Term::new(name, Span::call_site()); + let ident = Ident::new(name, Span::call_site()); match enum_variation { EnumVariation::Bitfield => { @@ -2316,7 +2314,7 @@ impl<'a> EnumBuilder<'a> { } EnumVariation::ModuleConsts => { - let ident = Term::new(CONSTIFIED_ENUM_MODULE_REPR_NAME, Span::call_site()); + let ident = Ident::new(CONSTIFIED_ENUM_MODULE_REPR_NAME, Span::call_site()); let type_definition = quote! { #( #attrs )* pub type #ident = #repr; @@ -2337,7 +2335,7 @@ impl<'a> EnumBuilder<'a> { ctx: &BindgenContext, variant: &EnumVariant, mangling_prefix: Option<&str>, - rust_ty: quote::Tokens, + rust_ty: proc_macro2::TokenStream, result: &mut CodegenResult<'b>, is_ty_named: bool, ) -> Self { @@ -2439,9 +2437,9 @@ impl<'a> EnumBuilder<'a> { fn build<'b>( self, ctx: &BindgenContext, - rust_ty: quote::Tokens, + rust_ty: proc_macro2::TokenStream, result: &mut CodegenResult<'b>, - ) -> quote::Tokens { + ) -> proc_macro2::TokenStream { match self { EnumBuilder::Rust { attrs, ident, tokens, emitted_any_variants, .. } => { let variants = if !emitted_any_variants { @@ -2612,23 +2610,23 @@ impl CodeGenerator for Enum { ctx: &BindgenContext, enum_: &Type, // Only to avoid recomputing every time. - enum_canonical_name: &Term, + enum_canonical_name: &Ident, // May be the same as "variant" if it's because the // enum is unnamed and we still haven't seen the // value. - variant_name: &str, - referenced_name: &Term, - enum_rust_ty: quote::Tokens, + variant_name: &Ident, + referenced_name: &Ident, + enum_rust_ty: proc_macro2::TokenStream, result: &mut CodegenResult<'a>, ) { let constant_name = if enum_.name().is_some() { if ctx.options().prepend_enum_name { - format!("{}_{}", enum_canonical_name.as_str(), variant_name) + format!("{}_{}", enum_canonical_name, variant_name) } else { - variant_name.into() + format!("{}", variant_name) } } else { - variant_name.into() + format!("{}", variant_name) }; let constant_name = ctx.rust_ident(constant_name); @@ -2652,7 +2650,7 @@ impl CodeGenerator for Enum { ); // A map where we keep a value -> variant relation. - let mut seen_values = HashMap::<_, Term>::new(); + let mut seen_values = HashMap::<_, Ident>::new(); let enum_rust_ty = item.to_rust_ty_or_opaque(ctx, &()); let is_toplevel = item.is_toplevel(ctx); @@ -2724,7 +2722,7 @@ impl CodeGenerator for Enum { ctx, enum_ty, &ident, - &*mangled_name, + &Ident::new(&*mangled_name, Span::call_site()), existing_variant_name, enum_rust_ty.clone(), result, @@ -2765,11 +2763,11 @@ impl CodeGenerator for Enum { let parent_name = parent_canonical_name.as_ref().unwrap(); - Term::new( + Ident::new( &format!( "{}_{}", parent_name, - variant_name.as_str() + variant_name ), Span::call_site() ) @@ -2779,7 +2777,7 @@ impl CodeGenerator for Enum { ctx, enum_ty, &ident, - mangled_name.as_str(), + &mangled_name, &variant_name, enum_rust_ty.clone(), result, @@ -2816,7 +2814,7 @@ trait TryToOpaque { &self, ctx: &BindgenContext, extra: &Self::Extra, - ) -> error::Result { + ) -> error::Result { self.try_get_layout(ctx, extra).map(|layout| { helpers::blob(ctx, layout) }) @@ -2843,7 +2841,7 @@ trait ToOpaque: TryToOpaque { &self, ctx: &BindgenContext, extra: &Self::Extra, - ) -> quote::Tokens { + ) -> proc_macro2::TokenStream { let layout = self.get_layout(ctx, extra); helpers::blob(ctx, layout) } @@ -2869,7 +2867,7 @@ trait TryToRustTy { &self, ctx: &BindgenContext, extra: &Self::Extra, - ) -> error::Result; + ) -> error::Result; } /// Fallible conversion to a Rust type or an opaque blob with the correct size @@ -2884,7 +2882,7 @@ trait TryToRustTyOrOpaque: TryToRustTy + TryToOpaque { &self, ctx: &BindgenContext, extra: &::Extra, - ) -> error::Result; + ) -> error::Result; } impl TryToRustTyOrOpaque for T @@ -2898,7 +2896,7 @@ where &self, ctx: &BindgenContext, extra: &E, - ) -> error::Result { + ) -> error::Result { self.try_to_rust_ty(ctx, extra).or_else( |_| if let Ok(layout) = self.try_get_layout(ctx, extra) @@ -2935,7 +2933,7 @@ trait ToRustTyOrOpaque: TryToRustTy + ToOpaque { &self, ctx: &BindgenContext, extra: &::Extra, - ) -> quote::Tokens; + ) -> proc_macro2::TokenStream; } impl ToRustTyOrOpaque for T @@ -2948,7 +2946,7 @@ where &self, ctx: &BindgenContext, extra: &E, - ) -> quote::Tokens { + ) -> proc_macro2::TokenStream { self.try_to_rust_ty(ctx, extra).unwrap_or_else(|_| { self.to_opaque(ctx, extra) }) @@ -2980,7 +2978,7 @@ where &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { ctx.resolve_item((*self).into()).try_to_rust_ty(ctx, &()) } } @@ -3004,7 +3002,7 @@ impl TryToRustTy for Item { &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { self.kind().expect_type().try_to_rust_ty(ctx, self) } } @@ -3028,7 +3026,7 @@ impl TryToRustTy for Type { &self, ctx: &BindgenContext, item: &Item, - ) -> error::Result { + ) -> error::Result { use self::helpers::ast_ty::*; match *self.kind() { @@ -3130,7 +3128,7 @@ impl TryToRustTy for Type { } TypeKind::Enum(..) => { let path = item.namespace_aware_canonical_path(ctx); - let path = Term::new(&path.join("::"), Span::call_site()); + let path = proc_macro2::TokenStream::from_str(&path.join("::")).unwrap(); Ok(quote!(#path)) } TypeKind::TemplateInstantiation(ref inst) => { @@ -3233,7 +3231,7 @@ impl TryToRustTy for TemplateInstantiation { &self, ctx: &BindgenContext, item: &Item, - ) -> error::Result { + ) -> error::Result { if self.is_opaque(ctx, item) { return Err(error::Error::InstantiationOfOpaqueType); } @@ -3245,7 +3243,7 @@ impl TryToRustTy for TemplateInstantiation { let mut ty = quote! {}; let def_path = def.namespace_aware_canonical_path(ctx); - ty.append_separated(def_path.into_iter().map(|p| ctx.rust_ident(p)), Term::new("::", Span::call_site())); + ty.append_separated(def_path.into_iter().map(|p| ctx.rust_ident(p)), quote!(::)); let def_params = def.self_template_params(ctx); if def_params.is_empty() { @@ -3297,7 +3295,7 @@ impl TryToRustTy for FunctionSig { &self, ctx: &BindgenContext, _: &(), - ) -> error::Result { + ) -> error::Result { // TODO: we might want to consider ignoring the reference return value. let ret = utils::fnsig_return_ty(ctx, &self); let arguments = utils::fnsig_arguments(ctx, &self); @@ -3306,7 +3304,7 @@ impl TryToRustTy for FunctionSig { match abi { Abi::ThisCall if !ctx.options().rust_features().thiscall_abi => { warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target"); - Ok(quote::Tokens::new()) + Ok(proc_macro2::TokenStream::new()) } _ => { Ok(quote! { @@ -3438,7 +3436,7 @@ fn objc_method_codegen( method: &ObjCMethod, class_name: Option<&str>, prefix: &str, -) -> (quote::Tokens, quote::Tokens) { +) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) { let signature = method.signature(); let fn_args = utils::fnsig_arguments(ctx, signature); let fn_ret = utils::fnsig_return_ty(ctx, signature); @@ -3552,7 +3550,7 @@ impl CodeGenerator for ObjCInterface { } } -pub(crate) fn codegen(context: BindgenContext) -> (Vec, BindgenOptions) { +pub(crate) fn codegen(context: BindgenContext) -> (Vec, BindgenOptions) { context.gen(|context| { let _t = context.timer("codegen"); let counter = Cell::new(0); @@ -3588,12 +3586,12 @@ mod utils { use ir::function::FunctionSig; use ir::item::{Item, ItemCanonicalPath}; use ir::ty::TypeKind; - use quote; - use proc_macro2::{Term, Span}; + use proc_macro2; use std::mem; + use std::str::FromStr; - pub fn prepend_bitfield_unit_type(result: &mut Vec) { - let bitfield_unit_type = Term::new(include_str!("./bitfield_unit.rs"), Span::call_site()); + pub fn prepend_bitfield_unit_type(result: &mut Vec) { + let bitfield_unit_type = proc_macro2::TokenStream::from_str(include_str!("./bitfield_unit.rs")).unwrap(); let bitfield_unit_type = quote!(#bitfield_unit_type); let items = vec![bitfield_unit_type]; @@ -3603,7 +3601,7 @@ mod utils { pub fn prepend_objc_header( ctx: &BindgenContext, - result: &mut Vec, + result: &mut Vec, ) { let use_objc = if ctx.options().objc_extern_crate { quote! { @@ -3628,7 +3626,7 @@ mod utils { pub fn prepend_block_header( ctx: &BindgenContext, - result: &mut Vec, + result: &mut Vec, ) { let use_block = if ctx.options().block_extern_crate { quote! { @@ -3647,7 +3645,7 @@ mod utils { pub fn prepend_union_types( ctx: &BindgenContext, - result: &mut Vec, + result: &mut Vec, ) { let prefix = ctx.trait_prefix(); @@ -3746,7 +3744,7 @@ mod utils { pub fn prepend_incomplete_array_types( ctx: &BindgenContext, - result: &mut Vec, + result: &mut Vec, ) { let prefix = ctx.trait_prefix(); @@ -3819,7 +3817,7 @@ mod utils { } pub fn prepend_complex_type( - result: &mut Vec, + result: &mut Vec, ) { let complex_type = quote! { #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] @@ -3838,18 +3836,14 @@ mod utils { pub fn build_path( item: &Item, ctx: &BindgenContext, - ) -> error::Result { - use proc_macro2::{Term, Span}; - + ) -> error::Result { let path = item.namespace_aware_canonical_path(ctx); - let path = Term::new(&path.join("::"), Span::call_site()); - let tokens = quote! {#path}; - //tokens.append_separated(path, "::"); + let tokens = proc_macro2::TokenStream::from_str(&path.join("::")).unwrap(); Ok(tokens) } - fn primitive_ty(ctx: &BindgenContext, name: &str) -> quote::Tokens { + fn primitive_ty(ctx: &BindgenContext, name: &str) -> proc_macro2::TokenStream { let ident = ctx.rust_ident_raw(name); quote! { #ident @@ -3859,7 +3853,7 @@ mod utils { pub fn type_from_named( ctx: &BindgenContext, name: &str, - ) -> Option { + ) -> Option { // FIXME: We could use the inner item to check this is really a // primitive type but, who the heck overrides these anyway? Some(match name { @@ -3882,7 +3876,7 @@ mod utils { pub fn fnsig_return_ty( ctx: &BindgenContext, sig: &FunctionSig, - ) -> quote::Tokens { + ) -> proc_macro2::TokenStream { let return_item = ctx.resolve_item(sig.return_type()); if let TypeKind::Void = *return_item.kind().expect_type().kind() { quote! { } @@ -3897,7 +3891,7 @@ mod utils { pub fn fnsig_arguments( ctx: &BindgenContext, sig: &FunctionSig, - ) -> Vec { + ) -> Vec { use super::ToPtr; let mut unnamed_arguments = 0; @@ -3960,7 +3954,7 @@ mod utils { pub fn fnsig_block( ctx: &BindgenContext, sig: &FunctionSig, - ) -> quote::Tokens { + ) -> proc_macro2::TokenStream { let args = sig.argument_types().iter().map(|&(_, ty)| { let arg_item = ctx.resolve_item(ty); diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs index 0ea23ddf..921ab215 100644 --- a/src/codegen/struct_layout.rs +++ b/src/codegen/struct_layout.rs @@ -6,8 +6,7 @@ use ir::comp::CompInfo; use ir::context::BindgenContext; use ir::layout::Layout; use ir::ty::{Type, TypeKind}; -use quote; -use proc_macro2::{Term, Span}; +use proc_macro2::{self, Ident, Span}; use std::cmp; /// Trace the layout of struct. @@ -154,7 +153,7 @@ impl<'a> StructLayoutTracker<'a> { field_name: &str, field_ty: &Type, field_offset: Option, - ) -> Option { + ) -> Option { let mut field_layout = field_ty.layout(self.ctx)?; if let TypeKind::Array(inner, len) = @@ -236,7 +235,7 @@ impl<'a> StructLayoutTracker<'a> { padding_layout.map(|layout| self.padding_field(layout)) } - pub fn pad_struct(&mut self, layout: Layout) -> Option { + pub fn pad_struct(&mut self, layout: Layout) -> Option { debug!( "pad_struct:\n\tself = {:#?}\n\tlayout = {:#?}", self, @@ -310,13 +309,13 @@ impl<'a> StructLayoutTracker<'a> { align_to(self.latest_offset, layout.align) - self.latest_offset } - fn padding_field(&mut self, layout: Layout) -> quote::Tokens { + fn padding_field(&mut self, layout: Layout) -> proc_macro2::TokenStream { let ty = helpers::blob(self.ctx, layout); let padding_count = self.padding_count; self.padding_count += 1; - let padding_field_name = Term::new(&format!("__bindgen_padding_{}", padding_count), Span::call_site()); + let padding_field_name = Ident::new(&format!("__bindgen_padding_{}", padding_count), Span::call_site()); self.max_field_align = cmp::max(self.max_field_align, layout.align); diff --git a/src/ir/context.rs b/src/ir/context.rs index 3f49f8a0..063c79f0 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -24,7 +24,7 @@ use cexpr; use clang::{self, Cursor}; use clang_sys; use parse::ClangItemParser; -use proc_macro2::{Term, Span}; +use proc_macro2::{Ident, Span}; use std::borrow::Cow; use std::cell::Cell; use std::collections::{HashMap, HashSet, hash_map}; @@ -922,7 +922,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" } /// Returns a mangled name as a rust identifier. - pub fn rust_ident(&self, name: S) -> Term + pub fn rust_ident(&self, name: S) -> Ident where S: AsRef { @@ -930,11 +930,11 @@ If you encounter an error missing from this list, please file an issue or a PR!" } /// Returns a mangled name as a rust identifier. - pub fn rust_ident_raw(&self, name: T) -> Term + pub fn rust_ident_raw(&self, name: T) -> Ident where T: AsRef { - Term::new(name.as_ref(), Span::call_site()) + Ident::new(name.as_ref(), Span::call_site()) } /// Iterate over all items that have been defined. @@ -2393,7 +2393,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" /// Convenient method for getting the prefix to use for most traits in /// codegen depending on the `use_core` option. - pub fn trait_prefix(&self) -> Term { + pub fn trait_prefix(&self) -> Ident { if self.options().use_core { self.rust_ident_raw("core") } else { diff --git a/src/ir/function.rs b/src/ir/function.rs index 0b83a74d..f851ad72 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -12,6 +12,8 @@ use ir::derive::{CanTriviallyDeriveDebug, CanTriviallyDeriveHash, CanTriviallyDerivePartialEqOrPartialOrd, CanDerive}; use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use quote; +use quote::TokenStreamExt; +use proc_macro2; use std::io; const RUST_DERIVE_FUNPTR_LIMIT: usize = 12; @@ -192,7 +194,7 @@ impl Abi { } impl quote::ToTokens for Abi { - fn to_tokens(&self, tokens: &mut quote::Tokens) { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { tokens.append_all(match *self { Abi::C => quote! { "C" }, Abi::Stdcall => quote! { "stdcall" }, diff --git a/src/ir/objc.rs b/src/ir/objc.rs index 46c0802e..61c22356 100644 --- a/src/ir/objc.rs +++ b/src/ir/objc.rs @@ -12,8 +12,7 @@ use clang_sys::CXCursor_ObjCClassRef; use clang_sys::CXCursor_ObjCInstanceMethodDecl; use clang_sys::CXCursor_ObjCProtocolDecl; use clang_sys::CXCursor_ObjCProtocolRef; -use quote; -use proc_macro2::{Term, Span}; +use proc_macro2::{TokenStream, Ident, Span}; /// Objective C interface as used in TypeKind /// @@ -213,11 +212,11 @@ impl ObjCMethod { } /// Formats the method call - pub fn format_method_call(&self, args: &[quote::Tokens]) -> quote::Tokens { + pub fn format_method_call(&self, args: &[TokenStream]) -> TokenStream { let split_name: Vec<_> = self.name .split(':') .filter(|p| !p.is_empty()) - .map(|name| Term::new(name, Span::call_site())) + .map(|name| Ident::new(name, Span::call_site())) .collect(); // No arguments @@ -243,7 +242,7 @@ impl ObjCMethod { let arg = arg.to_string(); let name_and_sig: Vec<&str> = arg.split(' ').collect(); let name = name_and_sig[0]; - args_without_types.push(Term::new(name, Span::call_site())) + args_without_types.push(Ident::new(name, Span::call_site())) }; let args = split_name diff --git a/src/lib.rs b/src/lib.rs index ffe4e80d..66ba2e82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1675,7 +1675,7 @@ fn ensure_libclang_is_loaded() { #[derive(Debug)] pub struct Bindings { options: BindgenOptions, - module: quote::Tokens, + module: proc_macro2::TokenStream, } impl Bindings { diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index 43422ac5..b7c41bda 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -1,18 +1,21 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct SomeAccessors { pub mNoAccessor: ::std::os::raw::c_int, - ///
+ #[doc = "
"] pub mBothAccessors: ::std::os::raw::c_int, - ///
+ #[doc = "
"] pub mUnsafeAccessors: ::std::os::raw::c_int, - ///
+ #[doc = "
"] pub mImmutableAccessor: ::std::os::raw::c_int, } #[test] @@ -92,7 +95,7 @@ impl SomeAccessors { &self.mImmutableAccessor } } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AllAccessors { @@ -150,7 +153,7 @@ impl AllAccessors { &mut self.mAlsoBothAccessors } } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AllUnsafeAccessors { @@ -212,16 +215,16 @@ impl AllUnsafeAccessors { &mut self.mAlsoBothAccessors } } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ContradictAccessors { pub mBothAccessors: ::std::os::raw::c_int, - ///
+ #[doc = "
"] pub mNoAccessors: ::std::os::raw::c_int, - ///
+ #[doc = "
"] pub mUnsafeAccessors: ::std::os::raw::c_int, - ///
+ #[doc = "
"] pub mImmutableAccessor: ::std::os::raw::c_int, } #[test] @@ -307,7 +310,7 @@ impl ContradictAccessors { &self.mImmutableAccessor } } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Replaced { @@ -346,7 +349,7 @@ impl Replaced { &mut self.mAccessor } } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Wrapper { diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs index 6657a950..d6e854de 100644 --- a/tests/expectations/tests/annotation_hide.rs +++ b/tests/expectations/tests/annotation_hide.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct D { diff --git a/tests/expectations/tests/array-of-zero-sized-types.rs b/tests/expectations/tests/array-of-zero-sized-types.rs index 6e6193c9..be8446a6 100644 --- a/tests/expectations/tests/array-of-zero-sized-types.rs +++ b/tests/expectations/tests/array-of-zero-sized-types.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// This should get an `_address` byte. +#[doc = " This should get an `_address` byte."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Empty { @@ -24,8 +26,8 @@ fn bindgen_test_layout_Empty() { concat!("Alignment of ", stringify!(Empty)) ); } -/// This should not get an `_address` byte, since each `Empty` gets one, meaning -/// that this object is addressable. +#[doc = " This should not get an `_address` byte, since each `Empty` gets one, meaning"] +#[doc = " that this object is addressable."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct HasArrayOfEmpty { diff --git a/tests/expectations/tests/bitfield-32bit-overflow.rs b/tests/expectations/tests/bitfield-32bit-overflow.rs index 905c7268..9cb1f152 100644 --- a/tests/expectations/tests/bitfield-32bit-overflow.rs +++ b/tests/expectations/tests/bitfield-32bit-overflow.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs index 1a0dbdb4..408c2a0e 100644 --- a/tests/expectations/tests/bitfield-large.rs +++ b/tests/expectations/tests/bitfield-large.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/bitfield-method-same-name.rs b/tests/expectations/tests/bitfield-method-same-name.rs index 8dda4538..46c4744e 100644 --- a/tests/expectations/tests/bitfield-method-same-name.rs +++ b/tests/expectations/tests/bitfield-method-same-name.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/bitfield_align.rs b/tests/expectations/tests/bitfield_align.rs index 0600052b..c7758c5a 100644 --- a/tests/expectations/tests/bitfield_align.rs +++ b/tests/expectations/tests/bitfield_align.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/bitfield_align_2.rs b/tests/expectations/tests/bitfield_align_2.rs index 7f5f689d..39ab0eef 100644 --- a/tests/expectations/tests/bitfield_align_2.rs +++ b/tests/expectations/tests/bitfield_align_2.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/bitfield_method_mangling.rs b/tests/expectations/tests/bitfield_method_mangling.rs index d778dd9b..0089d2c7 100644 --- a/tests/expectations/tests/bitfield_method_mangling.rs +++ b/tests/expectations/tests/bitfield_method_mangling.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/blacklist-and-impl-debug.rs b/tests/expectations/tests/blacklist-and-impl-debug.rs index 140342be..ec757d8f 100644 --- a/tests/expectations/tests/blacklist-and-impl-debug.rs +++ b/tests/expectations/tests/blacklist-and-impl-debug.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] pub struct BlacklistMe(u8); - -/// Because this type contains a blacklisted type, it should not derive Debug. +#[doc = " Because this type contains a blacklisted type, it should not derive Debug."] #[repr(C)] pub struct ShouldManuallyImplDebug { pub a: BlacklistMe, diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index 5882328d..b60e4780 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct whatever { diff --git a/tests/expectations/tests/comment-indent.rs b/tests/expectations/tests/comment-indent.rs index 97afeefa..78acaf14 100644 --- a/tests/expectations/tests/comment-indent.rs +++ b/tests/expectations/tests/comment-indent.rs @@ -1,22 +1,27 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] use self::super::root; - /// This is a multi-line doc comment. - /// - /// This class is really really interesting, look! + #[doc = " This is a multi-line doc comment."] + #[doc = ""] + #[doc = " This class is really really interesting, look!"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } - /// This nested class is also a multi-line doc comment. - /// - /// This class is not so interesting, but worth a bit of docs too! + #[doc = " This nested class is also a multi-line doc comment."] + #[doc = ""] + #[doc = " This class is not so interesting, but worth a bit of docs too!"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo_Bar { @@ -51,18 +56,18 @@ pub mod root { pub mod test { #[allow(unused_imports)] use self::super::super::root; - /// I'm in a namespace, and thus I may be on a rust module, most of the time. - /// My documentation is pretty extensive, I guess. + #[doc = " I\'m in a namespace, and thus I may be on a rust module, most of the time."] + #[doc = " My documentation is pretty extensive, I guess."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Baz { - /// This member is plain awesome, just amazing. - /// - /// It also has super-extensive docs, with even a nice ascii-art diagram. - /// - /// +------+ +-------+ - /// | foo | ----> | bar | - /// +------+ +-------+ + #[doc = " This member is plain awesome, just amazing."] + #[doc = ""] + #[doc = " It also has super-extensive docs, with even a nice ascii-art diagram."] + #[doc = ""] + #[doc = " +------+ +-------+"] + #[doc = " | foo | ----> | bar |"] + #[doc = " +------+ +-------+"] pub member: ::std::os::raw::c_int, } #[test] @@ -88,9 +93,9 @@ pub mod root { ) ); } - /// I'm in an inline namespace, and as such I shouldn't get generated inside - /// a rust module, except when the relevant option is specified. Also, this - /// comment shouldn't be misaligned. + #[doc = " I\'m in an inline namespace, and as such I shouldn\'t get generated inside"] + #[doc = " a rust module, except when the relevant option is specified. Also, this"] + #[doc = " comment shouldn\'t be misaligned."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct InInlineNS { @@ -109,7 +114,6 @@ pub mod root { concat!("Alignment of ", stringify!(InInlineNS)) ); } - #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bazz { diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs index f1dc139c..53ef0b44 100644 --- a/tests/expectations/tests/constify-enum.rs +++ b/tests/expectations/tests/constify-enum.rs @@ -19,6 +19,6 @@ pub enum nsCSSPropertyID { eCSSProperty_b = 1, eCSSPropertyAlias_aa = 2, eCSSPropertyAlias_bb = 3, - ///<
+ #[doc = "<
"] eCSSProperty_COUNT_unexistingVariantValue = 4, } diff --git a/tests/expectations/tests/contains-vs-inherits-zero-sized.rs b/tests/expectations/tests/contains-vs-inherits-zero-sized.rs index 16139a06..7f30a3b1 100644 --- a/tests/expectations/tests/contains-vs-inherits-zero-sized.rs +++ b/tests/expectations/tests/contains-vs-inherits-zero-sized.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// This should get an `_address` byte. +#[doc = " This should get an `_address` byte."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Empty { @@ -24,8 +26,8 @@ fn bindgen_test_layout_Empty() { concat!("Alignment of ", stringify!(Empty)) ); } -/// This should not get an `_address` byte, so `sizeof(Inherits)` should be -/// `1`. +#[doc = " This should not get an `_address` byte, so `sizeof(Inherits)` should be"] +#[doc = " `1`."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Inherits { @@ -54,8 +56,8 @@ fn bindgen_test_layout_Inherits() { ) ); } -/// This should not get an `_address` byte, but contains `Empty` which *does* get -/// one, so `sizeof(Contains)` should be `1 + 1`. +#[doc = " This should not get an `_address` byte, but contains `Empty` which *does* get"] +#[doc = " one, so `sizeof(Contains)` should be `1 + 1`."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Contains { diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs index 8058af10..6781cd1e 100644 --- a/tests/expectations/tests/convert-cpp-comment-to-rust.rs +++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs @@ -8,15 +8,15 @@ )] pub type mbedtls_mpi_uint = ::std::os::raw::c_uint; -/// \brief MPI structure +#[doc = " \\brief MPI structure"] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mbedtls_mpi { - ///< integer sign + #[doc = "< integer sign"] pub s: ::std::os::raw::c_int, - ///< total # of limbs + #[doc = "< total # of limbs"] pub n: ::std::os::raw::c_ulong, - ///< pointer to limbs + #[doc = "< pointer to limbs"] pub p: *mut mbedtls_mpi_uint, } #[test] diff --git a/tests/expectations/tests/derive-bitfield-method-same-name.rs b/tests/expectations/tests/derive-bitfield-method-same-name.rs index c23b0264..e8b33a81 100644 --- a/tests/expectations/tests/derive-bitfield-method-same-name.rs +++ b/tests/expectations/tests/derive-bitfield-method-same-name.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -100,10 +89,9 @@ where } } } - -/// Because this struct have array larger than 32 items -/// and --with-derive-partialeq --impl-partialeq --impl-debug is provided, -/// this struct should manually implement `Debug` and `PartialEq`. +#[doc = " Because this struct have array larger than 32 items"] +#[doc = " and --with-derive-partialeq --impl-partialeq --impl-debug is provided,"] +#[doc = " this struct should manually implement `Debug` and `PartialEq`."] #[repr(C)] #[derive(Copy, Clone)] pub struct Foo { diff --git a/tests/expectations/tests/derive-clone.rs b/tests/expectations/tests/derive-clone.rs index fda94f99..80dee43d 100644 --- a/tests/expectations/tests/derive-clone.rs +++ b/tests/expectations/tests/derive-clone.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// This struct should derive `Clone`. +#[doc = " This struct should derive `Clone`."] #[repr(C)] #[derive(Copy, Clone)] pub struct ShouldDeriveClone { diff --git a/tests/expectations/tests/derive-clone_1_0.rs b/tests/expectations/tests/derive-clone_1_0.rs index c71eb92f..b56ded1d 100644 --- a/tests/expectations/tests/derive-clone_1_0.rs +++ b/tests/expectations/tests/derive-clone_1_0.rs @@ -1,12 +1,14 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// Since builtin `Clone` impls were introduced in Rust 1.21 this struct -/// should impl `Clone` "manually". +#[doc = " Since builtin `Clone` impls were introduced in Rust 1.21 this struct"] +#[doc = " should impl `Clone` \"manually\"."] #[repr(C)] #[derive(Copy)] pub struct ShouldImplClone { diff --git a/tests/expectations/tests/derive-debug-bitfield-core.rs b/tests/expectations/tests/derive-debug-bitfield-core.rs index 59a01dbf..613e00f3 100644 --- a/tests/expectations/tests/derive-debug-bitfield-core.rs +++ b/tests/expectations/tests/derive-debug-bitfield-core.rs @@ -18,7 +18,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -27,38 +26,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -66,15 +56,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -85,16 +72,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/derive-debug-bitfield.rs b/tests/expectations/tests/derive-debug-bitfield.rs index ccd7155d..88a41d78 100644 --- a/tests/expectations/tests/derive-debug-bitfield.rs +++ b/tests/expectations/tests/derive-debug-bitfield.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/derive-default-and-blacklist.rs b/tests/expectations/tests/derive-default-and-blacklist.rs index 7b1b1afc..292e51b0 100644 --- a/tests/expectations/tests/derive-default-and-blacklist.rs +++ b/tests/expectations/tests/derive-default-and-blacklist.rs @@ -1,13 +1,16 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] pub struct BlacklistMe(u8); - -/// Because this type contains a blacklisted type, it should not derive -/// Default. Instead, we should emit a `mem::zeroed` implementation. +#[doc = " Because this type contains a blacklisted type, it should not derive"] +#[doc = " Default. Instead, we should emit a `mem::zeroed` implementation."] #[repr(C)] pub struct ShouldNotDeriveDefault { pub a: BlacklistMe, diff --git a/tests/expectations/tests/derive-hash-and-blacklist.rs b/tests/expectations/tests/derive-hash-and-blacklist.rs index ef12b9a8..8e58055b 100644 --- a/tests/expectations/tests/derive-hash-and-blacklist.rs +++ b/tests/expectations/tests/derive-hash-and-blacklist.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] pub struct BlacklistMe(u8); - -/// Because this type contains a blacklisted type, it should not derive Hash. +#[doc = " Because this type contains a blacklisted type, it should not derive Hash."] #[repr(C)] pub struct ShouldNotDeriveHash { pub a: BlacklistMe, diff --git a/tests/expectations/tests/derive-hash-blacklisting.rs b/tests/expectations/tests/derive-hash-blacklisting.rs index fa35d6ca..2bbc4a16 100644 --- a/tests/expectations/tests/derive-hash-blacklisting.rs +++ b/tests/expectations/tests/derive-hash-blacklisting.rs @@ -1,7 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] @@ -10,9 +14,8 @@ pub struct Blacklisted { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } - -/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type, -/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. +#[doc = " This would derive(Hash, Eq, PartialEq) if it didn\'t contain a blacklisted type,"] +#[doc = " causing us to conservatively avoid deriving hash/Eq/PartialEq for it."] #[repr(C)] pub struct WhitelistedOne { pub a: Blacklisted<::std::os::raw::c_int>, @@ -45,7 +48,7 @@ impl Default for WhitelistedOne { unsafe { ::std::mem::zeroed() } } } -/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type. +#[doc = " This can\'t derive(Hash/Eq) even if it didn\'t contain a blacklisted type."] #[repr(C)] pub struct WhitelistedTwo { pub b: Blacklisted, diff --git a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs index 11c86de4..bd0acb04 100644 --- a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs +++ b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// A struct containing a struct containing a float that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd +#[doc = " A struct containing a struct containing a float that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { diff --git a/tests/expectations/tests/derive-hash-struct-with-float-array.rs b/tests/expectations/tests/derive-hash-struct-with-float-array.rs index 12ac57aa..e2d05e0b 100644 --- a/tests/expectations/tests/derive-hash-struct-with-float-array.rs +++ b/tests/expectations/tests/derive-hash-struct-with-float-array.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd +#[doc = " A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { diff --git a/tests/expectations/tests/derive-hash-struct-with-pointer.rs b/tests/expectations/tests/derive-hash-struct-with-pointer.rs index c69bcd7c..60f8ff46 100644 --- a/tests/expectations/tests/derive-hash-struct-with-pointer.rs +++ b/tests/expectations/tests/derive-hash-struct-with-pointer.rs @@ -1,8 +1,13 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -/// Pointers can derive Hash/PartialOrd/Ord/PartialEq/Eq +#[doc = " Pointers can derive Hash/PartialOrd/Ord/PartialEq/Eq"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct ConstPtrMutObj { diff --git a/tests/expectations/tests/derive-hash-template-def-float.rs b/tests/expectations/tests/derive-hash-template-def-float.rs index 853d77af..f2b338db 100644 --- a/tests/expectations/tests/derive-hash-template-def-float.rs +++ b/tests/expectations/tests/derive-hash-template-def-float.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// Template definition containing a float, which cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd. +#[doc = " Template definition containing a float, which cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd."] #[repr(C)] #[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { diff --git a/tests/expectations/tests/derive-hash-template-inst-float.rs b/tests/expectations/tests/derive-hash-template-inst-float.rs index abb98f05..20f7c46c 100644 --- a/tests/expectations/tests/derive-hash-template-inst-float.rs +++ b/tests/expectations/tests/derive-hash-template-inst-float.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// Template definition that doesn't contain float can derive Hash/PartialOrd/Ord/PartialEq/Eq +#[doc = " Template definition that doesn\'t contain float can derive Hash/PartialOrd/Ord/PartialEq/Eq"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct foo { @@ -17,7 +19,7 @@ impl Default for foo { unsafe { ::std::mem::zeroed() } } } -/// Can derive Hash/PartialOrd/Ord/PartialEq/Eq when instantiated with int +#[doc = " Can derive Hash/PartialOrd/Ord/PartialEq/Eq when instantiated with int"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct IntStr { @@ -46,7 +48,7 @@ impl Default for IntStr { unsafe { ::std::mem::zeroed() } } } -/// Cannot derive Hash/Eq/Ord when instantiated with float but can derive PartialEq/PartialOrd +#[doc = " Cannot derive Hash/Eq/Ord when instantiated with float but can derive PartialEq/PartialOrd"] #[repr(C)] #[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] pub struct FloatStr { diff --git a/tests/expectations/tests/derive-partialeq-and-blacklist.rs b/tests/expectations/tests/derive-partialeq-and-blacklist.rs index 1c51c3a3..42ae1464 100644 --- a/tests/expectations/tests/derive-partialeq-and-blacklist.rs +++ b/tests/expectations/tests/derive-partialeq-and-blacklist.rs @@ -1,13 +1,16 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] pub struct BlacklistMe(u8); - -/// Because this type contains a blacklisted type, it should not derive -/// PartialEq. +#[doc = " Because this type contains a blacklisted type, it should not derive"] +#[doc = " PartialEq."] #[repr(C)] pub struct ShouldNotDerivePartialEq { pub a: BlacklistMe, diff --git a/tests/expectations/tests/derive-partialeq-bitfield.rs b/tests/expectations/tests/derive-partialeq-bitfield.rs index c1cb18f7..f4d91662 100644 --- a/tests/expectations/tests/derive-partialeq-bitfield.rs +++ b/tests/expectations/tests/derive-partialeq-bitfield.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -136,7 +125,8 @@ impl Default for C { } impl ::std::cmp::PartialEq for C { fn eq(&self, other: &C) -> bool { - self.a() == other.a() && self.b() == other.b() + self.a() == other.a() + && self.b() == other.b() && &self.large_array[..] == &other.large_array[..] } } diff --git a/tests/expectations/tests/derive-partialeq-union.rs b/tests/expectations/tests/derive-partialeq-union.rs index 68344591..e8fd542f 100644 --- a/tests/expectations/tests/derive-partialeq-union.rs +++ b/tests/expectations/tests/derive-partialeq-union.rs @@ -1,11 +1,13 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// Deriving PartialEq for rust unions is not supported. +#[doc = " Deriving PartialEq for rust unions is not supported."] #[repr(C)] #[derive(Copy, Clone)] pub union ShouldNotDerivePartialEq { diff --git a/tests/expectations/tests/derive-partialeq-union_1_0.rs b/tests/expectations/tests/derive-partialeq-union_1_0.rs index 57c415b4..83fd8333 100644 --- a/tests/expectations/tests/derive-partialeq-union_1_0.rs +++ b/tests/expectations/tests/derive-partialeq-union_1_0.rs @@ -1,8 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] pub struct __BindgenUnionField(::std::marker::PhantomData); @@ -47,7 +50,7 @@ impl ::std::cmp::PartialEq for __BindgenUnionField { } } impl ::std::cmp::Eq for __BindgenUnionField {} -/// This should manually derive PartialEq. +#[doc = " This should manually derive PartialEq."] #[repr(C)] #[derive(Copy)] pub struct ShouldDerivePartialEq { diff --git a/tests/expectations/tests/divide-by-zero-in-struct-layout.rs b/tests/expectations/tests/divide-by-zero-in-struct-layout.rs index 1b51a30f..1cdd1e09 100644 --- a/tests/expectations/tests/divide-by-zero-in-struct-layout.rs +++ b/tests/expectations/tests/divide-by-zero-in-struct-layout.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/doggo-or-null.rs b/tests/expectations/tests/doggo-or-null.rs index cf576634..0b84b456 100644 --- a/tests/expectations/tests/doggo-or-null.rs +++ b/tests/expectations/tests/doggo-or-null.rs @@ -1,8 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq)] @@ -45,12 +48,12 @@ fn bindgen_test_layout_Null() { concat!("Alignment of ", stringify!(Null)) ); } -/// This type is an opaque union. Unions can't derive anything interesting like -/// Debug or Default, even if their layout can, because it would require knowing -/// which variant is in use. Opaque unions still end up as a `union` in the Rust -/// bindings, but they just have one variant. Even so, can't derive. We should -/// probably emit an opaque struct for opaque unions... but until then, we have -/// this test to make sure that opaque unions don't derive and still compile. +#[doc = " This type is an opaque union. Unions can\'t derive anything interesting like"] +#[doc = " Debug or Default, even if their layout can, because it would require knowing"] +#[doc = " which variant is in use. Opaque unions still end up as a `union` in the Rust"] +#[doc = " bindings, but they just have one variant. Even so, can\'t derive. We should"] +#[doc = " probably emit an opaque struct for opaque unions... but until then, we have"] +#[doc = " this test to make sure that opaque unions don\'t derive and still compile."] #[repr(C)] #[derive(Copy, Clone)] pub union DoggoOrNull { diff --git a/tests/expectations/tests/enum-doc-bitfield.rs b/tests/expectations/tests/enum-doc-bitfield.rs index 9ebfc10e..7b11d0c6 100644 --- a/tests/expectations/tests/enum-doc-bitfield.rs +++ b/tests/expectations/tests/enum-doc-bitfield.rs @@ -8,30 +8,30 @@ )] impl B { - /// Document field with three slashes + #[doc = " Document field with three slashes"] pub const VAR_A: B = B(0); } impl B { - /// Document field with preceeding star + #[doc = " Document field with preceeding star"] pub const VAR_B: B = B(1); } impl B { - /// Document field with preceeding exclamation + #[doc = " Document field with preceeding exclamation"] pub const VAR_C: B = B(2); } impl B { - ///< Document field with following star + #[doc = "< Document field with following star"] pub const VAR_D: B = B(3); } impl B { - ///< Document field with following exclamation + #[doc = "< Document field with following exclamation"] pub const VAR_E: B = B(4); } impl B { - /// Document field with preceeding star, with a loong long multiline - /// comment. - /// - /// Very interesting documentation, definitely. + #[doc = " Document field with preceeding star, with a loong long multiline"] + #[doc = " comment."] + #[doc = ""] + #[doc = " Very interesting documentation, definitely."] pub const VAR_F: B = B(5); } impl ::std::ops::BitOr for B { @@ -61,6 +61,6 @@ impl ::std::ops::BitAndAssign for B { } } #[repr(C)] -/// Document enum +#[doc = " Document enum"] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct B(pub u32); diff --git a/tests/expectations/tests/enum-doc-mod.rs b/tests/expectations/tests/enum-doc-mod.rs index 1da02f41..35d671b0 100644 --- a/tests/expectations/tests/enum-doc-mod.rs +++ b/tests/expectations/tests/enum-doc-mod.rs @@ -8,21 +8,21 @@ )] pub mod B { - /// Document enum + #[doc = " Document enum"] pub type Type = u32; - /// Document field with three slashes + #[doc = " Document field with three slashes"] pub const VAR_A: Type = 0; - /// Document field with preceeding star + #[doc = " Document field with preceeding star"] pub const VAR_B: Type = 1; - /// Document field with preceeding exclamation + #[doc = " Document field with preceeding exclamation"] pub const VAR_C: Type = 2; - ///< Document field with following star + #[doc = "< Document field with following star"] pub const VAR_D: Type = 3; - ///< Document field with following exclamation + #[doc = "< Document field with following exclamation"] pub const VAR_E: Type = 4; - /// Document field with preceeding star, with a loong long multiline - /// comment. - /// - /// Very interesting documentation, definitely. + #[doc = " Document field with preceeding star, with a loong long multiline"] + #[doc = " comment."] + #[doc = ""] + #[doc = " Very interesting documentation, definitely."] pub const VAR_F: Type = 5; } diff --git a/tests/expectations/tests/enum-doc-rusty.rs b/tests/expectations/tests/enum-doc-rusty.rs index e4209e3e..8104a45a 100644 --- a/tests/expectations/tests/enum-doc-rusty.rs +++ b/tests/expectations/tests/enum-doc-rusty.rs @@ -8,22 +8,22 @@ )] #[repr(u32)] -/// Document enum +#[doc = " Document enum"] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum B { - /// Document field with three slashes + #[doc = " Document field with three slashes"] VAR_A = 0, - /// Document field with preceeding star + #[doc = " Document field with preceeding star"] VAR_B = 1, - /// Document field with preceeding exclamation + #[doc = " Document field with preceeding exclamation"] VAR_C = 2, - ///< Document field with following star + #[doc = "< Document field with following star"] VAR_D = 3, - ///< Document field with following exclamation + #[doc = "< Document field with following exclamation"] VAR_E = 4, - /// Document field with preceeding star, with a loong long multiline - /// comment. - /// - /// Very interesting documentation, definitely. + #[doc = " Document field with preceeding star, with a loong long multiline"] + #[doc = " comment."] + #[doc = ""] + #[doc = " Very interesting documentation, definitely."] VAR_F = 5, } diff --git a/tests/expectations/tests/enum-doc.rs b/tests/expectations/tests/enum-doc.rs index 0df3a5a5..4221ca80 100644 --- a/tests/expectations/tests/enum-doc.rs +++ b/tests/expectations/tests/enum-doc.rs @@ -7,20 +7,20 @@ non_upper_case_globals )] -/// Document field with three slashes +#[doc = " Document field with three slashes"] pub const B_VAR_A: B = 0; -/// Document field with preceeding star +#[doc = " Document field with preceeding star"] pub const B_VAR_B: B = 1; -/// Document field with preceeding exclamation +#[doc = " Document field with preceeding exclamation"] pub const B_VAR_C: B = 2; -///< Document field with following star +#[doc = "< Document field with following star"] pub const B_VAR_D: B = 3; -///< Document field with following exclamation +#[doc = "< Document field with following exclamation"] pub const B_VAR_E: B = 4; -/// Document field with preceeding star, with a loong long multiline -/// comment. -/// -/// Very interesting documentation, definitely. +#[doc = " Document field with preceeding star, with a loong long multiline"] +#[doc = " comment."] +#[doc = ""] +#[doc = " Very interesting documentation, definitely."] pub const B_VAR_F: B = 5; -/// Document enum +#[doc = " Document enum"] pub type B = u32; diff --git a/tests/expectations/tests/enum-variant-replaces.rs b/tests/expectations/tests/enum-variant-replaces.rs index aabcad75..9cb48f85 100644 --- a/tests/expectations/tests/enum-variant-replaces.rs +++ b/tests/expectations/tests/enum-variant-replaces.rs @@ -1,14 +1,19 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -///
-/// -/// Should see PASS below. +#[doc = "
"] +#[doc = ""] +#[doc = " Should see PASS below."] pub const OGRErr_PASS: OGRErr = 0; -///
-/// -/// Should see OGRERR_NONE instead of CUSTOM_OGRERR_NONE below. +#[doc = "
"] +#[doc = ""] +#[doc = " Should see OGRERR_NONE instead of CUSTOM_OGRERR_NONE below."] pub const OGRErr_OGRERR_NONE: OGRErr = 1; -///
+#[doc = "
"] pub type OGRErr = u32; diff --git a/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs index cf8b283c..9be33800 100644 --- a/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs +++ b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs @@ -1,12 +1,15 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] pub struct BaseWithVtable__bindgen_vtable(::std::os::raw::c_void); -/// This should have an explicit vtable. +#[doc = " This should have an explicit vtable."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct BaseWithVtable { @@ -19,7 +22,7 @@ impl Default for BaseWithVtable { unsafe { ::std::mem::zeroed() } } } -/// This should not have an explicit vtable. +#[doc = " This should not have an explicit vtable."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithNoVirtualMethods { @@ -43,7 +46,7 @@ impl Default for DerivedWithNoVirtualMethods { unsafe { ::std::mem::zeroed() } } } -/// This should not have an explicit vtable. +#[doc = " This should not have an explicit vtable."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithVirtualMethods { @@ -67,7 +70,7 @@ impl Default for DerivedWithVirtualMethods { unsafe { ::std::mem::zeroed() } } } -/// This should not have any vtable. +#[doc = " This should not have any vtable."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct BaseWithoutVtable { @@ -81,7 +84,7 @@ impl Default for BaseWithoutVtable { } #[repr(C)] pub struct DerivedWithVtable__bindgen_vtable(::std::os::raw::c_void); -/// This should have an explicit vtable. +#[doc = " This should have an explicit vtable."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithVtable { @@ -106,7 +109,7 @@ impl Default for DerivedWithVtable { unsafe { ::std::mem::zeroed() } } } -/// This should not have any vtable. +#[doc = " This should not have any vtable."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithoutVtable { diff --git a/tests/expectations/tests/issue-1034.rs b/tests/expectations/tests/issue-1034.rs index 957360b7..cd0c7217 100644 --- a/tests/expectations/tests/issue-1034.rs +++ b/tests/expectations/tests/issue-1034.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs b/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs index 14eb4d5f..7a4b77fb 100644 --- a/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs +++ b/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/issue-537.rs b/tests/expectations/tests/issue-537.rs index 136f9e0c..98bc0a96 100644 --- a/tests/expectations/tests/issue-537.rs +++ b/tests/expectations/tests/issue-537.rs @@ -1,12 +1,14 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// This should not be opaque; we can see the attributes and can pack the -/// struct. +#[doc = " This should not be opaque; we can see the attributes and can pack the"] +#[doc = " struct."] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct AlignedToOne { @@ -35,8 +37,8 @@ fn bindgen_test_layout_AlignedToOne() { ) ); } -/// This should be opaque because although we can see the attributes, Rust -/// doesn't have `#[repr(packed = "N")]` yet. +#[doc = " This should be opaque because although we can see the attributes, Rust"] +#[doc = " doesn\'t have `#[repr(packed = \"N\")]` yet."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AlignedToTwo { @@ -55,9 +57,9 @@ fn bindgen_test_layout_AlignedToTwo() { concat!("Alignment of ", stringify!(AlignedToTwo)) ); } -/// This should not be opaque because although `libclang` doesn't give us the -/// `#pragma pack(1)`, we can detect that alignment is 1 and add -/// `#[repr(packed)]` to the struct ourselves. +#[doc = " This should not be opaque because although `libclang` doesn\'t give us the"] +#[doc = " `#pragma pack(1)`, we can detect that alignment is 1 and add"] +#[doc = " `#[repr(packed)]` to the struct ourselves."] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct PackedToOne { @@ -97,9 +99,9 @@ fn bindgen_test_layout_PackedToOne() { ) ); } -/// In this case, even if we can detect the weird alignment triggered by -/// `#pragma pack(2)`, we can't do anything about it because Rust doesn't have -/// `#[repr(packed = "N")]`. Therefore, we must make it opaque. +#[doc = " In this case, even if we can detect the weird alignment triggered by"] +#[doc = " `#pragma pack(2)`, we can\'t do anything about it because Rust doesn\'t have"] +#[doc = " `#[repr(packed = \"N\")]`. Therefore, we must make it opaque."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct PackedToTwo { diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs index 0b0eb9a2..6df8e4b5 100644 --- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs +++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs @@ -1,14 +1,16 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// We emit a `[u8; 63usize]` padding field for this struct, which cannot derive -/// Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end -/// up with the reight alignment, we're waiting on `#[repr(align="N")]` to land -/// in rustc). +#[doc = " We emit a `[u8; 63usize]` padding field for this struct, which cannot derive"] +#[doc = " Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn\'t end"] +#[doc = " up with the reight alignment, we\'re waiting on `#[repr(align=\"N\")]` to land"] +#[doc = " in rustc)."] #[repr(C)] #[derive(Copy, Clone)] pub struct NoDebug { @@ -43,10 +45,10 @@ impl ::std::cmp::PartialEq for NoDebug { self.c == other.c } } -/// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive -/// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because -/// we determine Debug derive-ability before we compute padding, which happens at -/// codegen. (Again, we expect to get the alignment wrong for similar reasons.) +#[doc = " This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive"] +#[doc = " Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don\'t derive Debug/Hash because"] +#[doc = " we determine Debug derive-ability before we compute padding, which happens at"] +#[doc = " codegen. (Again, we expect to get the alignment wrong for similar reasons.)"] #[repr(C)] #[derive(Copy, Clone)] pub struct ShouldDeriveDebugButDoesNot { diff --git a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs index 7697660d..ce006656 100644 --- a/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs +++ b/tests/expectations/tests/issue-739-pointer-wide-bitfield.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/issue-816.rs b/tests/expectations/tests/issue-816.rs index b1a03081..d7be76ce 100644 --- a/tests/expectations/tests/issue-816.rs +++ b/tests/expectations/tests/issue-816.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/issue-848-replacement-system-include.rs b/tests/expectations/tests/issue-848-replacement-system-include.rs index 16fab93a..4e6efd6b 100644 --- a/tests/expectations/tests/issue-848-replacement-system-include.rs +++ b/tests/expectations/tests/issue-848-replacement-system-include.rs @@ -1,16 +1,18 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// This is intended to replace another type, but won't if we treat this include -/// as a system include, because clang doesn't parse comments there. -/// -/// See #848. -/// -///
+#[doc = " This is intended to replace another type, but won\'t if we treat this include"] +#[doc = " as a system include, because clang doesn\'t parse comments there."] +#[doc = ""] +#[doc = " See #848."] +#[doc = ""] +#[doc = "
"] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsTArray { diff --git a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs b/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs index 8143921d..2570316b 100644 --- a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs +++ b/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs @@ -1,12 +1,10 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] pub struct BlacklistMe(u8); - -/// Because this type contains a blacklisted type, it should not derive Copy. +#[doc = " Because this type contains a blacklisted type, it should not derive Copy."] #[repr(C)] pub struct ShouldNotBeCopy { pub a: BlacklistMe, diff --git a/tests/expectations/tests/issue_315.rs b/tests/expectations/tests/issue_315.rs index d6660523..983452de 100644 --- a/tests/expectations/tests/issue_315.rs +++ b/tests/expectations/tests/issue_315.rs @@ -1,9 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -///
+#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +#[doc = "
"] pub type c = a; diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index 6a03de65..3c2a0cbe 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -147,43 +136,43 @@ pub enum JSValueShiftedTag { #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSWhyMagic { - /// a hole in a native object's elements + #[doc = " a hole in a native object\'s elements"] JS_ELEMENTS_HOLE = 0, - /// there is not a pending iterator value + #[doc = " there is not a pending iterator value"] JS_NO_ITER_VALUE = 1, - /// exception value thrown when closing a generator + #[doc = " exception value thrown when closing a generator"] JS_GENERATOR_CLOSING = 2, - /// compiler sentinel value + #[doc = " compiler sentinel value"] JS_NO_CONSTANT = 3, - /// used in debug builds to catch tracing errors + #[doc = " used in debug builds to catch tracing errors"] JS_THIS_POISON = 4, - /// used in debug builds to catch tracing errors + #[doc = " used in debug builds to catch tracing errors"] JS_ARG_POISON = 5, - /// an empty subnode in the AST serializer + #[doc = " an empty subnode in the AST serializer"] JS_SERIALIZE_NO_NODE = 6, - /// lazy arguments value on the stack + #[doc = " lazy arguments value on the stack"] JS_LAZY_ARGUMENTS = 7, - /// optimized-away 'arguments' value + #[doc = " optimized-away \'arguments\' value"] JS_OPTIMIZED_ARGUMENTS = 8, - /// magic value passed to natives to indicate construction + #[doc = " magic value passed to natives to indicate construction"] JS_IS_CONSTRUCTING = 9, - /// arguments.callee has been overwritten + #[doc = " arguments.callee has been overwritten"] JS_OVERWRITTEN_CALLEE = 10, - /// value of static block object slot + #[doc = " value of static block object slot"] JS_BLOCK_NEEDS_CLONE = 11, - /// see class js::HashableValue + #[doc = " see class js::HashableValue"] JS_HASH_KEY_EMPTY = 12, - /// error while running Ion code + #[doc = " error while running Ion code"] JS_ION_ERROR = 13, - /// missing recover instruction result + #[doc = " missing recover instruction result"] JS_ION_BAILOUT = 14, - /// optimized out slot + #[doc = " optimized out slot"] JS_OPTIMIZED_OUT = 15, - /// uninitialized lexical bindings that produce ReferenceError on touch. + #[doc = " uninitialized lexical bindings that produce ReferenceError on touch."] JS_UNINITIALIZED_LEXICAL = 16, - /// for local use + #[doc = " for local use"] JS_GENERIC_MAGIC = 17, - /// for local use + #[doc = " for local use"] JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs index e006ee42..539465c3 100644 --- a/tests/expectations/tests/jsval_layout_opaque_1_0.rs +++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -190,43 +179,43 @@ pub enum JSValueShiftedTag { #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSWhyMagic { - /// a hole in a native object's elements + #[doc = " a hole in a native object\'s elements"] JS_ELEMENTS_HOLE = 0, - /// there is not a pending iterator value + #[doc = " there is not a pending iterator value"] JS_NO_ITER_VALUE = 1, - /// exception value thrown when closing a generator + #[doc = " exception value thrown when closing a generator"] JS_GENERATOR_CLOSING = 2, - /// compiler sentinel value + #[doc = " compiler sentinel value"] JS_NO_CONSTANT = 3, - /// used in debug builds to catch tracing errors + #[doc = " used in debug builds to catch tracing errors"] JS_THIS_POISON = 4, - /// used in debug builds to catch tracing errors + #[doc = " used in debug builds to catch tracing errors"] JS_ARG_POISON = 5, - /// an empty subnode in the AST serializer + #[doc = " an empty subnode in the AST serializer"] JS_SERIALIZE_NO_NODE = 6, - /// lazy arguments value on the stack + #[doc = " lazy arguments value on the stack"] JS_LAZY_ARGUMENTS = 7, - /// optimized-away 'arguments' value + #[doc = " optimized-away \'arguments\' value"] JS_OPTIMIZED_ARGUMENTS = 8, - /// magic value passed to natives to indicate construction + #[doc = " magic value passed to natives to indicate construction"] JS_IS_CONSTRUCTING = 9, - /// arguments.callee has been overwritten + #[doc = " arguments.callee has been overwritten"] JS_OVERWRITTEN_CALLEE = 10, - /// value of static block object slot + #[doc = " value of static block object slot"] JS_BLOCK_NEEDS_CLONE = 11, - /// see class js::HashableValue + #[doc = " see class js::HashableValue"] JS_HASH_KEY_EMPTY = 12, - /// error while running Ion code + #[doc = " error while running Ion code"] JS_ION_ERROR = 13, - /// missing recover instruction result + #[doc = " missing recover instruction result"] JS_ION_BAILOUT = 14, - /// optimized out slot + #[doc = " optimized out slot"] JS_OPTIMIZED_OUT = 15, - /// uninitialized lexical bindings that produce ReferenceError on touch. + #[doc = " uninitialized lexical bindings that produce ReferenceError on touch."] JS_UNINITIALIZED_LEXICAL = 16, - /// for local use + #[doc = " for local use"] JS_GENERIC_MAGIC = 17, - /// for local use + #[doc = " for local use"] JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs index a5fd1f69..0979da1e 100644 --- a/tests/expectations/tests/layout_align.rs +++ b/tests/expectations/tests/layout_align.rs @@ -16,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -25,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -64,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -83,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -145,15 +129,15 @@ impl ::std::marker::Copy for __IncompleteArrayField {} #[repr(C)] #[derive(Debug)] pub struct rte_kni_fifo { - ///< Next position to be written + #[doc = "< Next position to be written"] pub write: ::std::os::raw::c_uint, - ///< Next position to be read + #[doc = "< Next position to be read"] pub read: ::std::os::raw::c_uint, - ///< Circular buffer length + #[doc = "< Circular buffer length"] pub len: ::std::os::raw::c_uint, - ///< Pointer size - for 32/64 bit OS + #[doc = "< Pointer size - for 32/64 bit OS"] pub elem_size: ::std::os::raw::c_uint, - ///< The buffer contains mbuf pointers + #[doc = "< The buffer contains mbuf pointers"] pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, pub __bindgen_align: [u64; 0usize], } @@ -178,7 +162,7 @@ impl Default for rte_kni_fifo { #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct rte_eth_link { - ///< ETH_SPEED_NUM_ + #[doc = "< ETH_SPEED_NUM_"] pub link_speed: u32, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, pub __bindgen_padding_0: [u8; 3usize], diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index 28dfd53c..9738393b 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -15,19 +15,19 @@ pub const ARP_OP_REVREQUEST: u32 = 3; pub const ARP_OP_REVREPLY: u32 = 4; pub const ARP_OP_INVREQUEST: u32 = 8; pub const ARP_OP_INVREPLY: u32 = 9; -/// Ethernet address: -/// A universally administered address is uniquely assigned to a device by its -/// manufacturer. The first three octets (in transmission order) contain the -/// Organizationally Unique Identifier (OUI). The following three (MAC-48 and -/// EUI-48) octets are assigned by that organization with the only constraint -/// of uniqueness. -/// A locally administered address is assigned to a device by a network -/// administrator and does not contain OUIs. -/// See http://standards.ieee.org/regauth/groupmac/tutorial.html +#[doc = " Ethernet address:"] +#[doc = " A universally administered address is uniquely assigned to a device by its"] +#[doc = " manufacturer. The first three octets (in transmission order) contain the"] +#[doc = " Organizationally Unique Identifier (OUI). The following three (MAC-48 and"] +#[doc = " EUI-48) octets are assigned by that organization with the only constraint"] +#[doc = " of uniqueness."] +#[doc = " A locally administered address is assigned to a device by a network"] +#[doc = " administrator and does not contain OUIs."] +#[doc = " See http://standards.ieee.org/regauth/groupmac/tutorial.html"] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct ether_addr { - ///< Addr bytes in tx order + #[doc = "< Addr bytes in tx order"] pub addr_bytes: [u8; 6usize], } #[test] @@ -53,17 +53,17 @@ fn bindgen_test_layout_ether_addr() { ) ); } -/// ARP header IPv4 payload. +#[doc = " ARP header IPv4 payload."] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct arp_ipv4 { - ///< sender hardware address + #[doc = "< sender hardware address"] pub arp_sha: ether_addr, - ///< sender IP address + #[doc = "< sender IP address"] pub arp_sip: u32, - ///< target hardware address + #[doc = "< target hardware address"] pub arp_tha: ether_addr, - ///< target IP address + #[doc = "< target IP address"] pub arp_tip: u32, } #[test] @@ -119,7 +119,7 @@ fn bindgen_test_layout_arp_ipv4() { ) ); } -/// ARP header. +#[doc = " ARP header."] #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct arp_hdr { diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index 2fd93c4a..34e976f4 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -16,19 +16,19 @@ pub const RTE_HEAP_NUM_FREELISTS: u32 = 13; pub struct rte_mempool { _unused: [u8; 0], } -/// Prototype for implementation specific data provisioning function. -/// -/// The function should provide the implementation specific memory for -/// for use by the other mempool ops functions in a given mempool ops struct. -/// E.g. the default ops provides an instance of the rte_ring for this purpose. -/// it will most likely point to a different type of data structure, and -/// will be transparent to the application programmer. -/// This function should set mp->pool_data. +#[doc = " Prototype for implementation specific data provisioning function."] +#[doc = ""] +#[doc = " The function should provide the implementation specific memory for"] +#[doc = " for use by the other mempool ops functions in a given mempool ops struct."] +#[doc = " E.g. the default ops provides an instance of the rte_ring for this purpose."] +#[doc = " it will most likely point to a different type of data structure, and"] +#[doc = " will be transparent to the application programmer."] +#[doc = " This function should set mp->pool_data."] pub type rte_mempool_alloc_t = ::std::option::Option ::std::os::raw::c_int>; -/// Free the opaque private data pointed to by mp->pool_data pointer. +#[doc = " Free the opaque private data pointed to by mp->pool_data pointer."] pub type rte_mempool_free_t = ::std::option::Option; -/// Enqueue an object into the external pool. +#[doc = " Enqueue an object into the external pool."] pub type rte_mempool_enqueue_t = ::std::option::Option< unsafe extern "C" fn( mp: *mut rte_mempool, @@ -36,7 +36,7 @@ pub type rte_mempool_enqueue_t = ::std::option::Option< n: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >; -/// Dequeue an object from the external pool. +#[doc = " Dequeue an object from the external pool."] pub type rte_mempool_dequeue_t = ::std::option::Option< unsafe extern "C" fn( mp: *mut rte_mempool, @@ -44,24 +44,24 @@ pub type rte_mempool_dequeue_t = ::std::option::Option< n: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >; -/// Return the number of available objects in the external pool. +#[doc = " Return the number of available objects in the external pool."] pub type rte_mempool_get_count = ::std::option::Option ::std::os::raw::c_uint>; -/// Structure defining mempool operations structure +#[doc = " Structure defining mempool operations structure"] #[repr(C)] #[derive(Copy, Clone)] pub struct rte_mempool_ops { - ///< Name of mempool ops struct. + #[doc = "< Name of mempool ops struct."] pub name: [::std::os::raw::c_char; 32usize], - ///< Allocate private data. + #[doc = "< Allocate private data."] pub alloc: rte_mempool_alloc_t, - ///< Free the external pool. + #[doc = "< Free the external pool."] pub free: rte_mempool_free_t, - ///< Enqueue an object. + #[doc = "< Enqueue an object."] pub enqueue: rte_mempool_enqueue_t, - ///< Dequeue an object. + #[doc = "< Dequeue an object."] pub dequeue: rte_mempool_dequeue_t, - ///< Get qty of available objs. + #[doc = "< Get qty of available objs."] pub get_count: rte_mempool_get_count, pub __bindgen_padding_0: [u64; 7usize], } @@ -148,11 +148,11 @@ impl ::std::cmp::PartialEq for rte_mempool_ops { && self.get_count == other.get_count } } -/// The rte_spinlock_t type. +#[doc = " The rte_spinlock_t type."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_spinlock_t { - ///< lock status 0 = unlocked, 1 = locked + #[doc = "< lock status 0 = unlocked, 1 = locked"] pub locked: ::std::os::raw::c_int, } #[test] @@ -178,22 +178,22 @@ fn bindgen_test_layout_rte_spinlock_t() { ) ); } -/// Structure storing the table of registered ops structs, each of which contain -/// the function pointers for the mempool ops functions. -/// Each process has its own storage for this ops struct array so that -/// the mempools can be shared across primary and secondary processes. -/// The indices used to access the array are valid across processes, whereas -/// any function pointers stored directly in the mempool struct would not be. -/// This results in us simply having "ops_index" in the mempool struct. +#[doc = " Structure storing the table of registered ops structs, each of which contain"] +#[doc = " the function pointers for the mempool ops functions."] +#[doc = " Each process has its own storage for this ops struct array so that"] +#[doc = " the mempools can be shared across primary and secondary processes."] +#[doc = " The indices used to access the array are valid across processes, whereas"] +#[doc = " any function pointers stored directly in the mempool struct would not be."] +#[doc = " This results in us simply having \"ops_index\" in the mempool struct."] #[repr(C)] #[derive(Copy, Clone)] pub struct rte_mempool_ops_table { - ///< Spinlock for add/delete. + #[doc = "< Spinlock for add/delete."] pub sl: rte_spinlock_t, - ///< Number of used ops structs in the table. + #[doc = "< Number of used ops structs in the table."] pub num_ops: u32, pub __bindgen_padding_0: [u64; 7usize], - /// Storage for all possible ops structs. + #[doc = " Storage for all possible ops structs."] pub ops: [rte_mempool_ops; 16usize], } #[test] @@ -239,7 +239,7 @@ impl Default for rte_mempool_ops_table { unsafe { ::std::mem::zeroed() } } } -/// Structure to hold malloc heap +#[doc = " Structure to hold malloc heap"] #[repr(C)] #[derive(Copy, Clone)] pub struct malloc_heap { diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index 91c74d4b..c53b028e 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -16,23 +16,23 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_1 { - ///< index of last fragment + #[doc = "< index of last fragment"] IP_LAST_FRAG_IDX = 0, - ///< index of first fragment + #[doc = "< index of first fragment"] IP_FIRST_FRAG_IDX = 1, - ///< minimum number of fragments + #[doc = "< minimum number of fragments"] IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } -/// @internal fragmented mbuf +#[doc = " @internal fragmented mbuf"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag { - ///< offset into the packet + #[doc = "< offset into the packet"] pub ofs: u16, - ///< length of fragment + #[doc = "< length of fragment"] pub len: u16, - ///< fragment mbuf + #[doc = "< fragment mbuf"] pub mb: *mut rte_mbuf, } #[test] @@ -83,15 +83,15 @@ impl Default for ip_frag { unsafe { ::std::mem::zeroed() } } } -/// @internal to uniquely indetify fragmented datagram. +#[doc = " @internal to uniquely indetify fragmented datagram."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag_key { - ///< src address, first 8 bytes used for IPv4 + #[doc = "< src address, first 8 bytes used for IPv4"] pub src_dst: [u64; 4usize], - ///< dst address + #[doc = "< dst address"] pub id: u32, - ///< src/dst key length + #[doc = "< src/dst key length"] pub key_len: u32, } #[test] @@ -137,24 +137,24 @@ fn bindgen_test_layout_ip_frag_key() { ) ); } -/// @internal Fragmented packet to reassemble. -/// First two entries in the frags[] array are for the last and first fragments. +#[doc = " @internal Fragmented packet to reassemble."] +#[doc = " First two entries in the frags[] array are for the last and first fragments."] #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_pkt { - ///< LRU list + #[doc = "< LRU list"] pub lru: ip_frag_pkt__bindgen_ty_1, - ///< fragmentation key + #[doc = "< fragmentation key"] pub key: ip_frag_key, - ///< creation timestamp + #[doc = "< creation timestamp"] pub start: u64, - ///< expected reassembled size + #[doc = "< expected reassembled size"] pub total_size: u32, - ///< size of fragments received + #[doc = "< size of fragments received"] pub frag_size: u32, - ///< index of next entry to fill + #[doc = "< index of next entry to fill"] pub last_idx: u32, - ///< fragments + #[doc = "< fragments"] pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -300,7 +300,7 @@ impl ::std::cmp::PartialEq for ip_frag_pkt { && self.frags == other.frags } } -///< fragment mbuf +#[doc = "< fragment mbuf"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs index d583e641..f5b0d1d1 100644 --- a/tests/expectations/tests/layout_cmdline_token.rs +++ b/tests/expectations/tests/layout_cmdline_token.rs @@ -1,9 +1,14 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -/// Stores a pointer to the ops struct, and the offset: the place to -/// write the parsed result in the destination structure. +#[doc = " Stores a pointer to the ops struct, and the offset: the place to"] +#[doc = " write the parsed result in the destination structure."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct cmdline_token_hdr { @@ -49,27 +54,27 @@ impl Default for cmdline_token_hdr { } } pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; -/// A token is defined by this structure. -/// -/// parse() takes the token as first argument, then the source buffer -/// starting at the token we want to parse. The 3rd arg is a pointer -/// where we store the parsed data (as binary). It returns the number of -/// parsed chars on success and a negative value on error. -/// -/// complete_get_nb() returns the number of possible values for this -/// token if completion is possible. If it is NULL or if it returns 0, -/// no completion is possible. -/// -/// complete_get_elt() copy in dstbuf (the size is specified in the -/// parameter) the i-th possible completion for this token. returns 0 -/// on success or and a negative value on error. -/// -/// get_help() fills the dstbuf with the help for the token. It returns -/// -1 on error and 0 on success. +#[doc = " A token is defined by this structure."] +#[doc = ""] +#[doc = " parse() takes the token as first argument, then the source buffer"] +#[doc = " starting at the token we want to parse. The 3rd arg is a pointer"] +#[doc = " where we store the parsed data (as binary). It returns the number of"] +#[doc = " parsed chars on success and a negative value on error."] +#[doc = ""] +#[doc = " complete_get_nb() returns the number of possible values for this"] +#[doc = " token if completion is possible. If it is NULL or if it returns 0,"] +#[doc = " no completion is possible."] +#[doc = ""] +#[doc = " complete_get_elt() copy in dstbuf (the size is specified in the"] +#[doc = " parameter) the i-th possible completion for this token. returns 0"] +#[doc = " on success or and a negative value on error."] +#[doc = ""] +#[doc = " get_help() fills the dstbuf with the help for the token. It returns"] +#[doc = " -1 on error and 0 on success."] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct cmdline_token_ops { - /// parse(token ptr, buf, res pts, buf len) + #[doc = " parse(token ptr, buf, res pts, buf len)"] pub parse: ::std::option::Option< unsafe extern "C" fn( arg1: *mut cmdline_parse_token_hdr_t, @@ -78,11 +83,11 @@ pub struct cmdline_token_ops { arg4: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >, - /// return the num of possible choices for this token + #[doc = " return the num of possible choices for this token"] pub complete_get_nb: ::std::option::Option< unsafe extern "C" fn(arg1: *mut cmdline_parse_token_hdr_t) -> ::std::os::raw::c_int, >, - /// return the elt x for this token (token, idx, dstbuf, size) + #[doc = " return the elt x for this token (token, idx, dstbuf, size)"] pub complete_get_elt: ::std::option::Option< unsafe extern "C" fn( arg1: *mut cmdline_parse_token_hdr_t, @@ -91,7 +96,7 @@ pub struct cmdline_token_ops { arg4: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >, - /// get help for this token (token, dstbuf, size) + #[doc = " get help for this token (token, dstbuf, size)"] pub get_help: ::std::option::Option< unsafe extern "C" fn( arg1: *mut cmdline_parse_token_hdr_t, diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 68aef5c6..77e3d845 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -16,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -25,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -64,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -83,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -138,36 +122,36 @@ pub const RTE_ETH_FLOW_GENEVE: u32 = 20; pub const RTE_ETH_FLOW_NVGRE: u32 = 21; pub const RTE_ETH_FLOW_MAX: u32 = 22; #[repr(u32)] -/// A set of values to identify what method is to be used to route -/// packets to multiple queues. +#[doc = " A set of values to identify what method is to be used to route"] +#[doc = " packets to multiple queues."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_rx_mq_mode { - /// None of DCB,RSS or VMDQ mode + #[doc = " None of DCB,RSS or VMDQ mode"] ETH_MQ_RX_NONE = 0, - /// For RX side, only RSS is on + #[doc = " For RX side, only RSS is on"] ETH_MQ_RX_RSS = 1, - /// For RX side,only DCB is on. + #[doc = " For RX side,only DCB is on."] ETH_MQ_RX_DCB = 2, - /// Both DCB and RSS enable + #[doc = " Both DCB and RSS enable"] ETH_MQ_RX_DCB_RSS = 3, - /// Only VMDQ, no RSS nor DCB + #[doc = " Only VMDQ, no RSS nor DCB"] ETH_MQ_RX_VMDQ_ONLY = 4, - /// RSS mode with VMDQ + #[doc = " RSS mode with VMDQ"] ETH_MQ_RX_VMDQ_RSS = 5, - /// Use VMDQ+DCB to route traffic to queues + #[doc = " Use VMDQ+DCB to route traffic to queues"] ETH_MQ_RX_VMDQ_DCB = 6, - /// Enable both VMDQ and DCB in VMDq + #[doc = " Enable both VMDQ and DCB in VMDq"] ETH_MQ_RX_VMDQ_DCB_RSS = 7, } -/// A structure used to configure the RX features of an Ethernet port. +#[doc = " A structure used to configure the RX features of an Ethernet port."] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { - /// The multi-queue packet distribution mode to be used, e.g. RSS. + #[doc = " The multi-queue packet distribution mode to be used, e.g. RSS."] pub mq_mode: rte_eth_rx_mq_mode, - ///< Only used if jumbo_frame enabled. + #[doc = "< Only used if jumbo_frame enabled."] pub max_rx_pkt_len: u32, - ///< hdr buf size (header_split enabled). + #[doc = "< hdr buf size (header_split enabled)."] pub split_hdr_size: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, } @@ -373,24 +357,24 @@ impl rte_eth_rxmode { } } #[repr(u32)] -/// A set of values to identify what method is to be used to transmit -/// packets using multi-TCs. +#[doc = " A set of values to identify what method is to be used to transmit"] +#[doc = " packets using multi-TCs."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_tx_mq_mode { - ///< It is in neither DCB nor VT mode. + #[doc = "< It is in neither DCB nor VT mode."] ETH_MQ_TX_NONE = 0, - ///< For TX side,only DCB is on. + #[doc = "< For TX side,only DCB is on."] ETH_MQ_TX_DCB = 1, - ///< For TX side,both DCB and VT is on. + #[doc = "< For TX side,both DCB and VT is on."] ETH_MQ_TX_VMDQ_DCB = 2, - ///< Only VT on, no DCB + #[doc = "< Only VT on, no DCB"] ETH_MQ_TX_VMDQ_ONLY = 3, } -/// A structure used to configure the TX features of an Ethernet port. +#[doc = " A structure used to configure the TX features of an Ethernet port."] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { - ///< TX multi-queues mode. + #[doc = "< TX multi-queues mode."] pub mq_mode: rte_eth_tx_mq_mode, pub pvid: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -492,29 +476,29 @@ impl rte_eth_txmode { __bindgen_bitfield_unit } } -/// A structure used to configure the Receive Side Scaling (RSS) feature -/// of an Ethernet port. -/// If not NULL, the *rss_key* pointer of the *rss_conf* structure points -/// to an array holding the RSS key to use for hashing specific header -/// fields of received packets. The length of this array should be indicated -/// by *rss_key_len* below. Otherwise, a default random hash key is used by -/// the device driver. -/// -/// The *rss_key_len* field of the *rss_conf* structure indicates the length -/// in bytes of the array pointed by *rss_key*. To be compatible, this length -/// will be checked in i40e only. Others assume 40 bytes to be used as before. -/// -/// The *rss_hf* field of the *rss_conf* structure indicates the different -/// types of IPv4/IPv6 packets to which the RSS hashing must be applied. -/// Supplying an *rss_hf* equal to zero disables the RSS feature. +#[doc = " A structure used to configure the Receive Side Scaling (RSS) feature"] +#[doc = " of an Ethernet port."] +#[doc = " If not NULL, the *rss_key* pointer of the *rss_conf* structure points"] +#[doc = " to an array holding the RSS key to use for hashing specific header"] +#[doc = " fields of received packets. The length of this array should be indicated"] +#[doc = " by *rss_key_len* below. Otherwise, a default random hash key is used by"] +#[doc = " the device driver."] +#[doc = ""] +#[doc = " The *rss_key_len* field of the *rss_conf* structure indicates the length"] +#[doc = " in bytes of the array pointed by *rss_key*. To be compatible, this length"] +#[doc = " will be checked in i40e only. Others assume 40 bytes to be used as before."] +#[doc = ""] +#[doc = " The *rss_hf* field of the *rss_conf* structure indicates the different"] +#[doc = " types of IPv4/IPv6 packets to which the RSS hashing must be applied."] +#[doc = " Supplying an *rss_hf* equal to zero disables the RSS feature."] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { - ///< If not NULL, 40-byte hash key. + #[doc = "< If not NULL, 40-byte hash key."] pub rss_key: *mut u8, - ///< hash key length in bytes. + #[doc = "< hash key length in bytes."] pub rss_key_len: u8, - ///< Hash functions to apply - see below. + #[doc = "< Hash functions to apply - see below."] pub rss_hf: u64, } #[test] @@ -566,59 +550,59 @@ impl Default for rte_eth_rss_conf { } } #[repr(u32)] -/// This enum indicates the possible number of traffic classes -/// in DCB configratioins +#[doc = " This enum indicates the possible number of traffic classes"] +#[doc = " in DCB configratioins"] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { - ///< 4 TCs with DCB. + #[doc = "< 4 TCs with DCB."] ETH_4_TCS = 4, - ///< 8 TCs with DCB. + #[doc = "< 8 TCs with DCB."] ETH_8_TCS = 8, } #[repr(u32)] -/// This enum indicates the possible number of queue pools -/// in VMDQ configurations. +#[doc = " This enum indicates the possible number of queue pools"] +#[doc = " in VMDQ configurations."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { - ///< 8 VMDq pools. + #[doc = "< 8 VMDq pools."] ETH_8_POOLS = 8, - ///< 16 VMDq pools. + #[doc = "< 16 VMDq pools."] ETH_16_POOLS = 16, - ///< 32 VMDq pools. + #[doc = "< 32 VMDq pools."] ETH_32_POOLS = 32, - ///< 64 VMDq pools. + #[doc = "< 64 VMDq pools."] ETH_64_POOLS = 64, } -/// A structure used to configure the VMDQ+DCB feature -/// of an Ethernet port. -/// -/// Using this feature, packets are routed to a pool of queues, based -/// on the vlan id in the vlan tag, and then to a specific queue within -/// that pool, using the user priority vlan tag field. -/// -/// A default pool may be used, if desired, to route all traffic which -/// does not match the vlan filter rules. +#[doc = " A structure used to configure the VMDQ+DCB feature"] +#[doc = " of an Ethernet port."] +#[doc = ""] +#[doc = " Using this feature, packets are routed to a pool of queues, based"] +#[doc = " on the vlan id in the vlan tag, and then to a specific queue within"] +#[doc = " that pool, using the user priority vlan tag field."] +#[doc = ""] +#[doc = " A default pool may be used, if desired, to route all traffic which"] +#[doc = " does not match the vlan filter rules."] #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_vmdq_dcb_conf { - ///< With DCB, 16 or 32 pools + #[doc = "< With DCB, 16 or 32 pools"] pub nb_queue_pools: rte_eth_nb_pools, - ///< If non-zero, use a default pool + #[doc = "< If non-zero, use a default pool"] pub enable_default_pool: u8, - ///< The default pool, if applicable + #[doc = "< The default pool, if applicable"] pub default_pool: u8, - ///< We can have up to 64 filters/mappings + #[doc = "< We can have up to 64 filters/mappings"] pub nb_pool_maps: u8, - ///< VMDq vlan pool maps. + #[doc = "< VMDq vlan pool maps."] pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], pub dcb_tc: [u8; 8usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - ///< The vlan id of the received frame + #[doc = "< The vlan id of the received frame"] pub vlan_id: u16, - ///< Bitmask of pools for packet rx + #[doc = "< Bitmask of pools for packet rx"] pub pools: u64, } #[test] @@ -753,9 +737,9 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { - ///< Possible DCB TCs, 4 or 8 TCs + #[doc = "< Possible DCB TCs, 4 or 8 TCs"] pub nb_tcs: rte_eth_nb_tcs, - /// Traffic class each UP mapped to. + #[doc = " Traffic class each UP mapped to."] pub dcb_tc: [u8; 8usize], } #[test] @@ -799,9 +783,9 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { - ///< With DCB, 16 or 32 pools. + #[doc = "< With DCB, 16 or 32 pools."] pub nb_queue_pools: rte_eth_nb_pools, - /// Traffic class each UP mapped to. + #[doc = " Traffic class each UP mapped to."] pub dcb_tc: [u8; 8usize], } #[test] @@ -847,9 +831,9 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { - ///< Possible DCB TCs, 4 or 8 TCs. + #[doc = "< Possible DCB TCs, 4 or 8 TCs."] pub nb_tcs: rte_eth_nb_tcs, - /// Traffic class each UP mapped to. + #[doc = " Traffic class each UP mapped to."] pub dcb_tc: [u8; 8usize], } #[test] @@ -893,7 +877,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { - ///< VMDq mode, 64 pools. + #[doc = "< VMDq mode, 64 pools."] pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -929,27 +913,27 @@ impl Default for rte_eth_vmdq_tx_conf { #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_vmdq_rx_conf { - ///< VMDq only mode, 8 or 64 pools + #[doc = "< VMDq only mode, 8 or 64 pools"] pub nb_queue_pools: rte_eth_nb_pools, - ///< If non-zero, use a default pool + #[doc = "< If non-zero, use a default pool"] pub enable_default_pool: u8, - ///< The default pool, if applicable + #[doc = "< The default pool, if applicable"] pub default_pool: u8, - ///< Enable VT loop back + #[doc = "< Enable VT loop back"] pub enable_loop_back: u8, - ///< We can have up to 64 filters/mappings + #[doc = "< We can have up to 64 filters/mappings"] pub nb_pool_maps: u8, - ///< Flags from ETH_VMDQ_ACCEPT_* + #[doc = "< Flags from ETH_VMDQ_ACCEPT_*"] pub rx_mode: u32, - ///< VMDq vlan pool maps. + #[doc = "< VMDq vlan pool maps."] pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - ///< The vlan id of the received frame + #[doc = "< The vlan id of the received frame"] pub vlan_id: u16, - ///< Bitmask of pools for packet rx + #[doc = "< Bitmask of pools for packet rx"] pub pools: u64, } #[test] @@ -1094,56 +1078,56 @@ impl Default for rte_eth_vmdq_rx_conf { } } #[repr(u32)] -/// Flow Director setting modes: none, signature or perfect. +#[doc = " Flow Director setting modes: none, signature or perfect."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { - ///< Disable FDIR support. + #[doc = "< Disable FDIR support."] RTE_FDIR_MODE_NONE = 0, - ///< Enable FDIR signature filter mode. + #[doc = "< Enable FDIR signature filter mode."] RTE_FDIR_MODE_SIGNATURE = 1, - ///< Enable FDIR perfect filter mode. + #[doc = "< Enable FDIR perfect filter mode."] RTE_FDIR_MODE_PERFECT = 2, - ///< Enable FDIR filter mode - MAC VLAN. + #[doc = "< Enable FDIR filter mode - MAC VLAN."] RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - ///< Enable FDIR filter mode - tunnel. + #[doc = "< Enable FDIR filter mode - tunnel."] RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] -/// Memory space that can be configured to store Flow Director filters -/// in the board memory. +#[doc = " Memory space that can be configured to store Flow Director filters"] +#[doc = " in the board memory."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { - ///< 64k. + #[doc = "< 64k."] RTE_FDIR_PBALLOC_64K = 0, - ///< 128k. + #[doc = "< 128k."] RTE_FDIR_PBALLOC_128K = 1, - ///< 256k. + #[doc = "< 256k."] RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] -/// Select report mode of FDIR hash information in RX descriptors. +#[doc = " Select report mode of FDIR hash information in RX descriptors."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { - ///< Never report FDIR hash. + #[doc = "< Never report FDIR hash."] RTE_FDIR_NO_REPORT_STATUS = 0, - ///< Only report FDIR hash for matching pkts. + #[doc = "< Only report FDIR hash for matching pkts."] RTE_FDIR_REPORT_STATUS = 1, - ///< Always report FDIR hash. + #[doc = "< Always report FDIR hash."] RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } -/// A structure used to define the input for IPV4 flow +#[doc = " A structure used to define the input for IPV4 flow"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { - ///< IPv4 source address in big endian. + #[doc = "< IPv4 source address in big endian."] pub src_ip: u32, - ///< IPv4 destination address in big endian. + #[doc = "< IPv4 destination address in big endian."] pub dst_ip: u32, - ///< Type of service to match. + #[doc = "< Type of service to match."] pub tos: u8, - ///< Time to live to match. + #[doc = "< Time to live to match."] pub ttl: u8, - ///< Protocol, next header in big endian. + #[doc = "< Protocol, next header in big endian."] pub proto: u8, } #[test] @@ -1209,19 +1193,19 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() { ) ); } -/// A structure used to define the input for IPV6 flow +#[doc = " A structure used to define the input for IPV6 flow"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { - ///< IPv6 source address in big endian. + #[doc = "< IPv6 source address in big endian."] pub src_ip: [u32; 4usize], - ///< IPv6 destination address in big endian. + #[doc = "< IPv6 destination address in big endian."] pub dst_ip: [u32; 4usize], - ///< Traffic class to match. + #[doc = "< Traffic class to match."] pub tc: u8, - ///< Protocol, next header to match. + #[doc = "< Protocol, next header to match."] pub proto: u8, - ///< Hop limits to match. + #[doc = "< Hop limits to match."] pub hop_limits: u8, } #[test] @@ -1287,28 +1271,28 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() { ) ); } -/// A structure used to configure FDIR masks that are used by the device -/// to match the various fields of RX packet headers. +#[doc = " A structure used to configure FDIR masks that are used by the device"] +#[doc = " to match the various fields of RX packet headers."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { - ///< Bit mask for vlan_tci in big endian + #[doc = "< Bit mask for vlan_tci in big endian"] pub vlan_tci_mask: u16, - /// Bit mask for ipv4 flow in big endian. + #[doc = " Bit mask for ipv4 flow in big endian."] pub ipv4_mask: rte_eth_ipv4_flow, - /// Bit maks for ipv6 flow in big endian. + #[doc = " Bit maks for ipv6 flow in big endian."] pub ipv6_mask: rte_eth_ipv6_flow, - /// Bit mask for L4 source port in big endian. + #[doc = " Bit mask for L4 source port in big endian."] pub src_port_mask: u16, - /// Bit mask for L4 destination port in big endian. + #[doc = " Bit mask for L4 destination port in big endian."] pub dst_port_mask: u16, - /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the - ///first byte on the wire + #[doc = " 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the"] + #[doc = "first byte on the wire"] pub mac_addr_byte_mask: u8, - /// Bit mask for tunnel ID in big endian. + #[doc = " Bit mask for tunnel ID in big endian."] pub tunnel_id_mask: u32, - ///< 1 - Match tunnel type, - ///0 - Ignore tunnel type. + #[doc = "< 1 - Match tunnel type,"] + #[doc = "0 - Ignore tunnel type."] pub tunnel_type_mask: u8, } #[test] @@ -1417,7 +1401,7 @@ fn bindgen_test_layout_rte_eth_fdir_masks() { ); } #[repr(u32)] -/// Payload type +#[doc = " Payload type"] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_payload_type { RTE_ETH_PAYLOAD_UNKNOWN = 0, @@ -1427,12 +1411,12 @@ pub enum rte_eth_payload_type { RTE_ETH_L4_PAYLOAD = 4, RTE_ETH_PAYLOAD_MAX = 8, } -/// A structure used to select bytes extracted from the protocol layers to -/// flexible payload for filter +#[doc = " A structure used to select bytes extracted from the protocol layers to"] +#[doc = " flexible payload for filter"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { - ///< Payload type + #[doc = "< Payload type"] pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1476,8 +1460,8 @@ impl Default for rte_eth_flex_payload_cfg { unsafe { ::std::mem::zeroed() } } } -/// A structure used to define FDIR masks for flexible payload -/// for each flow type +#[doc = " A structure used to define FDIR masks for flexible payload"] +#[doc = " for each flow type"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { @@ -1519,14 +1503,14 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() { ) ); } -/// A structure used to define all flexible payload related setting -/// include flex payload and flex mask +#[doc = " A structure used to define all flexible payload related setting"] +#[doc = " include flex payload and flex mask"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { - ///< The number of following payload cfg + #[doc = "< The number of following payload cfg"] pub nb_payloads: u16, - ///< The number of following mask + #[doc = "< The number of following mask"] pub nb_flexmasks: u16, pub flex_set: [rte_eth_flex_payload_cfg; 8usize], pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], @@ -1595,20 +1579,20 @@ impl Default for rte_eth_fdir_flex_conf { unsafe { ::std::mem::zeroed() } } } -/// A structure used to configure the Flow Director (FDIR) feature -/// of an Ethernet port. -/// -/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. +#[doc = " A structure used to configure the Flow Director (FDIR) feature"] +#[doc = " of an Ethernet port."] +#[doc = ""] +#[doc = " If mode is RTE_FDIR_DISABLE, the pballoc value is ignored."] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { - ///< Flow Director mode. + #[doc = "< Flow Director mode."] pub mode: rte_fdir_mode, - ///< Space for FDIR filters. + #[doc = "< Space for FDIR filters."] pub pballoc: rte_fdir_pballoc_type, - ///< How to report FDIR hash. + #[doc = "< How to report FDIR hash."] pub status: rte_fdir_status_mode, - /// RX queue of packets matching a "drop" filter in perfect mode. + #[doc = " RX queue of packets matching a \"drop\" filter in perfect mode."] pub drop_queue: u8, pub mask: rte_eth_fdir_masks, pub flex_conf: rte_eth_fdir_flex_conf, @@ -1691,13 +1675,13 @@ impl Default for rte_fdir_conf { unsafe { ::std::mem::zeroed() } } } -/// A structure used to enable/disable specific device interrupts. +#[doc = " A structure used to enable/disable specific device interrupts."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_intr_conf { - /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable + #[doc = " enable/disable lsc interrupt. 0 (default) - disable, 1 enable"] pub lsc: u16, - /// enable/disable rxq interrupt. 0 (default) - disable, 1 enable + #[doc = " enable/disable rxq interrupt. 0 (default) - disable, 1 enable"] pub rxq: u16, } #[test] @@ -1733,46 +1717,46 @@ fn bindgen_test_layout_rte_intr_conf() { ) ); } -/// A structure used to configure an Ethernet port. -/// Depending upon the RX multi-queue mode, extra advanced -/// configuration settings may be needed. +#[doc = " A structure used to configure an Ethernet port."] +#[doc = " Depending upon the RX multi-queue mode, extra advanced"] +#[doc = " configuration settings may be needed."] #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_conf { - ///< bitmap of ETH_LINK_SPEED_XXX of speeds to be - ///used. ETH_LINK_SPEED_FIXED disables link - ///autonegotiation, and a unique speed shall be - ///set. Otherwise, the bitmap defines the set of - ///speeds to be advertised. If the special value - ///ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - ///supported are advertised. + #[doc = "< bitmap of ETH_LINK_SPEED_XXX of speeds to be"] + #[doc = "used. ETH_LINK_SPEED_FIXED disables link"] + #[doc = "autonegotiation, and a unique speed shall be"] + #[doc = "set. Otherwise, the bitmap defines the set of"] + #[doc = "speeds to be advertised. If the special value"] + #[doc = "ETH_LINK_SPEED_AUTONEG (0) is used, all speeds"] + #[doc = "supported are advertised."] pub link_speeds: u32, - ///< Port RX configuration. + #[doc = "< Port RX configuration."] pub rxmode: rte_eth_rxmode, - ///< Port TX configuration. + #[doc = "< Port TX configuration."] pub txmode: rte_eth_txmode, - ///< Loopback operation mode. By default the value - ///is 0, meaning the loopback mode is disabled. - ///Read the datasheet of given ethernet controller - ///for details. The possible values of this field - ///are defined in implementation of each driver. + #[doc = "< Loopback operation mode. By default the value"] + #[doc = "is 0, meaning the loopback mode is disabled."] + #[doc = "Read the datasheet of given ethernet controller"] + #[doc = "for details. The possible values of this field"] + #[doc = "are defined in implementation of each driver."] pub lpbk_mode: u32, - ///< Port RX filtering configuration (union). + #[doc = "< Port RX filtering configuration (union)."] pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - ///< Port TX DCB configuration (union). + #[doc = "< Port TX DCB configuration (union)."] pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, - /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC - ///is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. + #[doc = " Currently,Priority Flow Control(PFC) are supported,if DCB with PFC"] + #[doc = "is needed,and the variable must be set ETH_DCB_PFC_SUPPORT."] pub dcb_capability_en: u32, - ///< FDIR configuration. + #[doc = "< FDIR configuration."] pub fdir_conf: rte_fdir_conf, - ///< Interrupt mode configuration. + #[doc = "< Interrupt mode configuration."] pub intr_conf: rte_intr_conf, } #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_conf__bindgen_ty_1 { - ///< Port RSS configuration + #[doc = "< Port RSS configuration"] pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, pub dcb_rx_conf: rte_eth_dcb_rx_conf, diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs index 381ec8ac..ad86bc07 100644 --- a/tests/expectations/tests/layout_eth_conf_1_0.rs +++ b/tests/expectations/tests/layout_eth_conf_1_0.rs @@ -16,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -25,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -64,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -83,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -181,36 +165,36 @@ pub const RTE_ETH_FLOW_GENEVE: u32 = 20; pub const RTE_ETH_FLOW_NVGRE: u32 = 21; pub const RTE_ETH_FLOW_MAX: u32 = 22; #[repr(u32)] -/// A set of values to identify what method is to be used to route -/// packets to multiple queues. +#[doc = " A set of values to identify what method is to be used to route"] +#[doc = " packets to multiple queues."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_rx_mq_mode { - /// None of DCB,RSS or VMDQ mode + #[doc = " None of DCB,RSS or VMDQ mode"] ETH_MQ_RX_NONE = 0, - /// For RX side, only RSS is on + #[doc = " For RX side, only RSS is on"] ETH_MQ_RX_RSS = 1, - /// For RX side,only DCB is on. + #[doc = " For RX side,only DCB is on."] ETH_MQ_RX_DCB = 2, - /// Both DCB and RSS enable + #[doc = " Both DCB and RSS enable"] ETH_MQ_RX_DCB_RSS = 3, - /// Only VMDQ, no RSS nor DCB + #[doc = " Only VMDQ, no RSS nor DCB"] ETH_MQ_RX_VMDQ_ONLY = 4, - /// RSS mode with VMDQ + #[doc = " RSS mode with VMDQ"] ETH_MQ_RX_VMDQ_RSS = 5, - /// Use VMDQ+DCB to route traffic to queues + #[doc = " Use VMDQ+DCB to route traffic to queues"] ETH_MQ_RX_VMDQ_DCB = 6, - /// Enable both VMDQ and DCB in VMDq + #[doc = " Enable both VMDQ and DCB in VMDq"] ETH_MQ_RX_VMDQ_DCB_RSS = 7, } -/// A structure used to configure the RX features of an Ethernet port. +#[doc = " A structure used to configure the RX features of an Ethernet port."] #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { - /// The multi-queue packet distribution mode to be used, e.g. RSS. + #[doc = " The multi-queue packet distribution mode to be used, e.g. RSS."] pub mq_mode: rte_eth_rx_mq_mode, - ///< Only used if jumbo_frame enabled. + #[doc = "< Only used if jumbo_frame enabled."] pub max_rx_pkt_len: u32, - ///< hdr buf size (header_split enabled). + #[doc = "< hdr buf size (header_split enabled)."] pub split_hdr_size: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, } @@ -421,24 +405,24 @@ impl rte_eth_rxmode { } } #[repr(u32)] -/// A set of values to identify what method is to be used to transmit -/// packets using multi-TCs. +#[doc = " A set of values to identify what method is to be used to transmit"] +#[doc = " packets using multi-TCs."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_tx_mq_mode { - ///< It is in neither DCB nor VT mode. + #[doc = "< It is in neither DCB nor VT mode."] ETH_MQ_TX_NONE = 0, - ///< For TX side,only DCB is on. + #[doc = "< For TX side,only DCB is on."] ETH_MQ_TX_DCB = 1, - ///< For TX side,both DCB and VT is on. + #[doc = "< For TX side,both DCB and VT is on."] ETH_MQ_TX_VMDQ_DCB = 2, - ///< Only VT on, no DCB + #[doc = "< Only VT on, no DCB"] ETH_MQ_TX_VMDQ_ONLY = 3, } -/// A structure used to configure the TX features of an Ethernet port. +#[doc = " A structure used to configure the TX features of an Ethernet port."] #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { - ///< TX multi-queues mode. + #[doc = "< TX multi-queues mode."] pub mq_mode: rte_eth_tx_mq_mode, pub pvid: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -545,29 +529,29 @@ impl rte_eth_txmode { __bindgen_bitfield_unit } } -/// A structure used to configure the Receive Side Scaling (RSS) feature -/// of an Ethernet port. -/// If not NULL, the *rss_key* pointer of the *rss_conf* structure points -/// to an array holding the RSS key to use for hashing specific header -/// fields of received packets. The length of this array should be indicated -/// by *rss_key_len* below. Otherwise, a default random hash key is used by -/// the device driver. -/// -/// The *rss_key_len* field of the *rss_conf* structure indicates the length -/// in bytes of the array pointed by *rss_key*. To be compatible, this length -/// will be checked in i40e only. Others assume 40 bytes to be used as before. -/// -/// The *rss_hf* field of the *rss_conf* structure indicates the different -/// types of IPv4/IPv6 packets to which the RSS hashing must be applied. -/// Supplying an *rss_hf* equal to zero disables the RSS feature. +#[doc = " A structure used to configure the Receive Side Scaling (RSS) feature"] +#[doc = " of an Ethernet port."] +#[doc = " If not NULL, the *rss_key* pointer of the *rss_conf* structure points"] +#[doc = " to an array holding the RSS key to use for hashing specific header"] +#[doc = " fields of received packets. The length of this array should be indicated"] +#[doc = " by *rss_key_len* below. Otherwise, a default random hash key is used by"] +#[doc = " the device driver."] +#[doc = ""] +#[doc = " The *rss_key_len* field of the *rss_conf* structure indicates the length"] +#[doc = " in bytes of the array pointed by *rss_key*. To be compatible, this length"] +#[doc = " will be checked in i40e only. Others assume 40 bytes to be used as before."] +#[doc = ""] +#[doc = " The *rss_hf* field of the *rss_conf* structure indicates the different"] +#[doc = " types of IPv4/IPv6 packets to which the RSS hashing must be applied."] +#[doc = " Supplying an *rss_hf* equal to zero disables the RSS feature."] #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { - ///< If not NULL, 40-byte hash key. + #[doc = "< If not NULL, 40-byte hash key."] pub rss_key: *mut u8, - ///< hash key length in bytes. + #[doc = "< hash key length in bytes."] pub rss_key_len: u8, - ///< Hash functions to apply - see below. + #[doc = "< Hash functions to apply - see below."] pub rss_hf: u64, } #[test] @@ -624,59 +608,59 @@ impl Default for rte_eth_rss_conf { } } #[repr(u32)] -/// This enum indicates the possible number of traffic classes -/// in DCB configratioins +#[doc = " This enum indicates the possible number of traffic classes"] +#[doc = " in DCB configratioins"] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { - ///< 4 TCs with DCB. + #[doc = "< 4 TCs with DCB."] ETH_4_TCS = 4, - ///< 8 TCs with DCB. + #[doc = "< 8 TCs with DCB."] ETH_8_TCS = 8, } #[repr(u32)] -/// This enum indicates the possible number of queue pools -/// in VMDQ configurations. +#[doc = " This enum indicates the possible number of queue pools"] +#[doc = " in VMDQ configurations."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { - ///< 8 VMDq pools. + #[doc = "< 8 VMDq pools."] ETH_8_POOLS = 8, - ///< 16 VMDq pools. + #[doc = "< 16 VMDq pools."] ETH_16_POOLS = 16, - ///< 32 VMDq pools. + #[doc = "< 32 VMDq pools."] ETH_32_POOLS = 32, - ///< 64 VMDq pools. + #[doc = "< 64 VMDq pools."] ETH_64_POOLS = 64, } -/// A structure used to configure the VMDQ+DCB feature -/// of an Ethernet port. -/// -/// Using this feature, packets are routed to a pool of queues, based -/// on the vlan id in the vlan tag, and then to a specific queue within -/// that pool, using the user priority vlan tag field. -/// -/// A default pool may be used, if desired, to route all traffic which -/// does not match the vlan filter rules. +#[doc = " A structure used to configure the VMDQ+DCB feature"] +#[doc = " of an Ethernet port."] +#[doc = ""] +#[doc = " Using this feature, packets are routed to a pool of queues, based"] +#[doc = " on the vlan id in the vlan tag, and then to a specific queue within"] +#[doc = " that pool, using the user priority vlan tag field."] +#[doc = ""] +#[doc = " A default pool may be used, if desired, to route all traffic which"] +#[doc = " does not match the vlan filter rules."] #[repr(C)] #[derive(Copy)] pub struct rte_eth_vmdq_dcb_conf { - ///< With DCB, 16 or 32 pools + #[doc = "< With DCB, 16 or 32 pools"] pub nb_queue_pools: rte_eth_nb_pools, - ///< If non-zero, use a default pool + #[doc = "< If non-zero, use a default pool"] pub enable_default_pool: u8, - ///< The default pool, if applicable + #[doc = "< The default pool, if applicable"] pub default_pool: u8, - ///< We can have up to 64 filters/mappings + #[doc = "< We can have up to 64 filters/mappings"] pub nb_pool_maps: u8, - ///< VMDq vlan pool maps. + #[doc = "< VMDq vlan pool maps."] pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], pub dcb_tc: [u8; 8usize], } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - ///< The vlan id of the received frame + #[doc = "< The vlan id of the received frame"] pub vlan_id: u16, - ///< Bitmask of pools for packet rx + #[doc = "< Bitmask of pools for packet rx"] pub pools: u64, } #[test] @@ -821,9 +805,9 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { - ///< Possible DCB TCs, 4 or 8 TCs + #[doc = "< Possible DCB TCs, 4 or 8 TCs"] pub nb_tcs: rte_eth_nb_tcs, - /// Traffic class each UP mapped to. + #[doc = " Traffic class each UP mapped to."] pub dcb_tc: [u8; 8usize], } #[test] @@ -872,9 +856,9 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { - ///< With DCB, 16 or 32 pools. + #[doc = "< With DCB, 16 or 32 pools."] pub nb_queue_pools: rte_eth_nb_pools, - /// Traffic class each UP mapped to. + #[doc = " Traffic class each UP mapped to."] pub dcb_tc: [u8; 8usize], } #[test] @@ -925,9 +909,9 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { - ///< Possible DCB TCs, 4 or 8 TCs. + #[doc = "< Possible DCB TCs, 4 or 8 TCs."] pub nb_tcs: rte_eth_nb_tcs, - /// Traffic class each UP mapped to. + #[doc = " Traffic class each UP mapped to."] pub dcb_tc: [u8; 8usize], } #[test] @@ -976,7 +960,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { - ///< VMDq mode, 64 pools. + #[doc = "< VMDq mode, 64 pools."] pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -1017,27 +1001,27 @@ impl Default for rte_eth_vmdq_tx_conf { #[repr(C)] #[derive(Copy)] pub struct rte_eth_vmdq_rx_conf { - ///< VMDq only mode, 8 or 64 pools + #[doc = "< VMDq only mode, 8 or 64 pools"] pub nb_queue_pools: rte_eth_nb_pools, - ///< If non-zero, use a default pool + #[doc = "< If non-zero, use a default pool"] pub enable_default_pool: u8, - ///< The default pool, if applicable + #[doc = "< The default pool, if applicable"] pub default_pool: u8, - ///< Enable VT loop back + #[doc = "< Enable VT loop back"] pub enable_loop_back: u8, - ///< We can have up to 64 filters/mappings + #[doc = "< We can have up to 64 filters/mappings"] pub nb_pool_maps: u8, - ///< Flags from ETH_VMDQ_ACCEPT_* + #[doc = "< Flags from ETH_VMDQ_ACCEPT_*"] pub rx_mode: u32, - ///< VMDq vlan pool maps. + #[doc = "< VMDq vlan pool maps."] pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - ///< The vlan id of the received frame + #[doc = "< The vlan id of the received frame"] pub vlan_id: u16, - ///< Bitmask of pools for packet rx + #[doc = "< Bitmask of pools for packet rx"] pub pools: u64, } #[test] @@ -1192,56 +1176,56 @@ impl Default for rte_eth_vmdq_rx_conf { } } #[repr(u32)] -/// Flow Director setting modes: none, signature or perfect. +#[doc = " Flow Director setting modes: none, signature or perfect."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { - ///< Disable FDIR support. + #[doc = "< Disable FDIR support."] RTE_FDIR_MODE_NONE = 0, - ///< Enable FDIR signature filter mode. + #[doc = "< Enable FDIR signature filter mode."] RTE_FDIR_MODE_SIGNATURE = 1, - ///< Enable FDIR perfect filter mode. + #[doc = "< Enable FDIR perfect filter mode."] RTE_FDIR_MODE_PERFECT = 2, - ///< Enable FDIR filter mode - MAC VLAN. + #[doc = "< Enable FDIR filter mode - MAC VLAN."] RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - ///< Enable FDIR filter mode - tunnel. + #[doc = "< Enable FDIR filter mode - tunnel."] RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] -/// Memory space that can be configured to store Flow Director filters -/// in the board memory. +#[doc = " Memory space that can be configured to store Flow Director filters"] +#[doc = " in the board memory."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { - ///< 64k. + #[doc = "< 64k."] RTE_FDIR_PBALLOC_64K = 0, - ///< 128k. + #[doc = "< 128k."] RTE_FDIR_PBALLOC_128K = 1, - ///< 256k. + #[doc = "< 256k."] RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] -/// Select report mode of FDIR hash information in RX descriptors. +#[doc = " Select report mode of FDIR hash information in RX descriptors."] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { - ///< Never report FDIR hash. + #[doc = "< Never report FDIR hash."] RTE_FDIR_NO_REPORT_STATUS = 0, - ///< Only report FDIR hash for matching pkts. + #[doc = "< Only report FDIR hash for matching pkts."] RTE_FDIR_REPORT_STATUS = 1, - ///< Always report FDIR hash. + #[doc = "< Always report FDIR hash."] RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } -/// A structure used to define the input for IPV4 flow +#[doc = " A structure used to define the input for IPV4 flow"] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { - ///< IPv4 source address in big endian. + #[doc = "< IPv4 source address in big endian."] pub src_ip: u32, - ///< IPv4 destination address in big endian. + #[doc = "< IPv4 destination address in big endian."] pub dst_ip: u32, - ///< Type of service to match. + #[doc = "< Type of service to match."] pub tos: u8, - ///< Time to live to match. + #[doc = "< Time to live to match."] pub ttl: u8, - ///< Protocol, next header in big endian. + #[doc = "< Protocol, next header in big endian."] pub proto: u8, } #[test] @@ -1312,19 +1296,19 @@ impl Clone for rte_eth_ipv4_flow { *self } } -/// A structure used to define the input for IPV6 flow +#[doc = " A structure used to define the input for IPV6 flow"] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { - ///< IPv6 source address in big endian. + #[doc = "< IPv6 source address in big endian."] pub src_ip: [u32; 4usize], - ///< IPv6 destination address in big endian. + #[doc = "< IPv6 destination address in big endian."] pub dst_ip: [u32; 4usize], - ///< Traffic class to match. + #[doc = "< Traffic class to match."] pub tc: u8, - ///< Protocol, next header to match. + #[doc = "< Protocol, next header to match."] pub proto: u8, - ///< Hop limits to match. + #[doc = "< Hop limits to match."] pub hop_limits: u8, } #[test] @@ -1395,28 +1379,28 @@ impl Clone for rte_eth_ipv6_flow { *self } } -/// A structure used to configure FDIR masks that are used by the device -/// to match the various fields of RX packet headers. +#[doc = " A structure used to configure FDIR masks that are used by the device"] +#[doc = " to match the various fields of RX packet headers."] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { - ///< Bit mask for vlan_tci in big endian + #[doc = "< Bit mask for vlan_tci in big endian"] pub vlan_tci_mask: u16, - /// Bit mask for ipv4 flow in big endian. + #[doc = " Bit mask for ipv4 flow in big endian."] pub ipv4_mask: rte_eth_ipv4_flow, - /// Bit maks for ipv6 flow in big endian. + #[doc = " Bit maks for ipv6 flow in big endian."] pub ipv6_mask: rte_eth_ipv6_flow, - /// Bit mask for L4 source port in big endian. + #[doc = " Bit mask for L4 source port in big endian."] pub src_port_mask: u16, - /// Bit mask for L4 destination port in big endian. + #[doc = " Bit mask for L4 destination port in big endian."] pub dst_port_mask: u16, - /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the - ///first byte on the wire + #[doc = " 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the"] + #[doc = "first byte on the wire"] pub mac_addr_byte_mask: u8, - /// Bit mask for tunnel ID in big endian. + #[doc = " Bit mask for tunnel ID in big endian."] pub tunnel_id_mask: u32, - ///< 1 - Match tunnel type, - ///0 - Ignore tunnel type. + #[doc = "< 1 - Match tunnel type,"] + #[doc = "0 - Ignore tunnel type."] pub tunnel_type_mask: u8, } #[test] @@ -1530,7 +1514,7 @@ impl Clone for rte_eth_fdir_masks { } } #[repr(u32)] -/// Payload type +#[doc = " Payload type"] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_payload_type { RTE_ETH_PAYLOAD_UNKNOWN = 0, @@ -1540,12 +1524,12 @@ pub enum rte_eth_payload_type { RTE_ETH_L4_PAYLOAD = 4, RTE_ETH_PAYLOAD_MAX = 8, } -/// A structure used to select bytes extracted from the protocol layers to -/// flexible payload for filter +#[doc = " A structure used to select bytes extracted from the protocol layers to"] +#[doc = " flexible payload for filter"] #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { - ///< Payload type + #[doc = "< Payload type"] pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1594,8 +1578,8 @@ impl Default for rte_eth_flex_payload_cfg { unsafe { ::std::mem::zeroed() } } } -/// A structure used to define FDIR masks for flexible payload -/// for each flow type +#[doc = " A structure used to define FDIR masks for flexible payload"] +#[doc = " for each flow type"] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { @@ -1642,14 +1626,14 @@ impl Clone for rte_eth_fdir_flex_mask { *self } } -/// A structure used to define all flexible payload related setting -/// include flex payload and flex mask +#[doc = " A structure used to define all flexible payload related setting"] +#[doc = " include flex payload and flex mask"] #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { - ///< The number of following payload cfg + #[doc = "< The number of following payload cfg"] pub nb_payloads: u16, - ///< The number of following mask + #[doc = "< The number of following mask"] pub nb_flexmasks: u16, pub flex_set: [rte_eth_flex_payload_cfg; 8usize], pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], @@ -1723,20 +1707,20 @@ impl Default for rte_eth_fdir_flex_conf { unsafe { ::std::mem::zeroed() } } } -/// A structure used to configure the Flow Director (FDIR) feature -/// of an Ethernet port. -/// -/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. +#[doc = " A structure used to configure the Flow Director (FDIR) feature"] +#[doc = " of an Ethernet port."] +#[doc = ""] +#[doc = " If mode is RTE_FDIR_DISABLE, the pballoc value is ignored."] #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { - ///< Flow Director mode. + #[doc = "< Flow Director mode."] pub mode: rte_fdir_mode, - ///< Space for FDIR filters. + #[doc = "< Space for FDIR filters."] pub pballoc: rte_fdir_pballoc_type, - ///< How to report FDIR hash. + #[doc = "< How to report FDIR hash."] pub status: rte_fdir_status_mode, - /// RX queue of packets matching a "drop" filter in perfect mode. + #[doc = " RX queue of packets matching a \"drop\" filter in perfect mode."] pub drop_queue: u8, pub mask: rte_eth_fdir_masks, pub flex_conf: rte_eth_fdir_flex_conf, @@ -1824,13 +1808,13 @@ impl Default for rte_fdir_conf { unsafe { ::std::mem::zeroed() } } } -/// A structure used to enable/disable specific device interrupts. +#[doc = " A structure used to enable/disable specific device interrupts."] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_intr_conf { - /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable + #[doc = " enable/disable lsc interrupt. 0 (default) - disable, 1 enable"] pub lsc: u16, - /// enable/disable rxq interrupt. 0 (default) - disable, 1 enable + #[doc = " enable/disable rxq interrupt. 0 (default) - disable, 1 enable"] pub rxq: u16, } #[test] @@ -1871,46 +1855,46 @@ impl Clone for rte_intr_conf { *self } } -/// A structure used to configure an Ethernet port. -/// Depending upon the RX multi-queue mode, extra advanced -/// configuration settings may be needed. +#[doc = " A structure used to configure an Ethernet port."] +#[doc = " Depending upon the RX multi-queue mode, extra advanced"] +#[doc = " configuration settings may be needed."] #[repr(C)] #[derive(Copy)] pub struct rte_eth_conf { - ///< bitmap of ETH_LINK_SPEED_XXX of speeds to be - ///used. ETH_LINK_SPEED_FIXED disables link - ///autonegotiation, and a unique speed shall be - ///set. Otherwise, the bitmap defines the set of - ///speeds to be advertised. If the special value - ///ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - ///supported are advertised. + #[doc = "< bitmap of ETH_LINK_SPEED_XXX of speeds to be"] + #[doc = "used. ETH_LINK_SPEED_FIXED disables link"] + #[doc = "autonegotiation, and a unique speed shall be"] + #[doc = "set. Otherwise, the bitmap defines the set of"] + #[doc = "speeds to be advertised. If the special value"] + #[doc = "ETH_LINK_SPEED_AUTONEG (0) is used, all speeds"] + #[doc = "supported are advertised."] pub link_speeds: u32, - ///< Port RX configuration. + #[doc = "< Port RX configuration."] pub rxmode: rte_eth_rxmode, - ///< Port TX configuration. + #[doc = "< Port TX configuration."] pub txmode: rte_eth_txmode, - ///< Loopback operation mode. By default the value - ///is 0, meaning the loopback mode is disabled. - ///Read the datasheet of given ethernet controller - ///for details. The possible values of this field - ///are defined in implementation of each driver. + #[doc = "< Loopback operation mode. By default the value"] + #[doc = "is 0, meaning the loopback mode is disabled."] + #[doc = "Read the datasheet of given ethernet controller"] + #[doc = "for details. The possible values of this field"] + #[doc = "are defined in implementation of each driver."] pub lpbk_mode: u32, - ///< Port RX filtering configuration (union). + #[doc = "< Port RX filtering configuration (union)."] pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - ///< Port TX DCB configuration (union). + #[doc = "< Port TX DCB configuration (union)."] pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, - /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC - ///is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. + #[doc = " Currently,Priority Flow Control(PFC) are supported,if DCB with PFC"] + #[doc = "is needed,and the variable must be set ETH_DCB_PFC_SUPPORT."] pub dcb_capability_en: u32, - ///< FDIR configuration. + #[doc = "< FDIR configuration."] pub fdir_conf: rte_fdir_conf, - ///< Interrupt mode configuration. + #[doc = "< Interrupt mode configuration."] pub intr_conf: rte_intr_conf, } #[repr(C)] #[derive(Copy)] pub struct rte_eth_conf__bindgen_ty_1 { - ///< Port RSS configuration + #[doc = "< Port RSS configuration"] pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, pub dcb_rx_conf: rte_eth_dcb_rx_conf, diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index cd456881..8d233cd4 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -15,18 +15,18 @@ pub struct rte_kni_mbuf { pub buf_addr: *mut ::std::os::raw::c_void, pub buf_physaddr: u64, pub pad0: [::std::os::raw::c_char; 2usize], - ///< Start address of data in segment buffer. + #[doc = "< Start address of data in segment buffer."] pub data_off: u16, pub pad1: [::std::os::raw::c_char; 2usize], - ///< Number of segments. + #[doc = "< Number of segments."] pub nb_segs: u8, pub pad4: [::std::os::raw::c_char; 1usize], - ///< Offload features. + #[doc = "< Offload features."] pub ol_flags: u64, pub pad2: [::std::os::raw::c_char; 4usize], - ///< Total pkt len: sum of all segment data_len. + #[doc = "< Total pkt len: sum of all segment data_len."] pub pkt_len: u32, - ///< Amount of data in segment buffer. + #[doc = "< Amount of data in segment buffer."] pub data_len: u16, pub __bindgen_padding_0: [u8; 22usize], pub pad3: [::std::os::raw::c_char; 8usize], diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index 5a865189..d2f33a55 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -53,23 +53,23 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_1 { - ///< index of last fragment + #[doc = "< index of last fragment"] IP_LAST_FRAG_IDX = 0, - ///< index of first fragment + #[doc = "< index of first fragment"] IP_FIRST_FRAG_IDX = 1, - ///< minimum number of fragments + #[doc = "< minimum number of fragments"] IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } -/// @internal fragmented mbuf +#[doc = " @internal fragmented mbuf"] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ip_frag { - ///< offset into the packet + #[doc = "< offset into the packet"] pub ofs: u16, - ///< length of fragment + #[doc = "< length of fragment"] pub len: u16, - ///< fragment mbuf + #[doc = "< fragment mbuf"] pub mb: *mut rte_mbuf, } #[test] @@ -120,15 +120,15 @@ impl Default for ip_frag { unsafe { ::std::mem::zeroed() } } } -/// @internal to uniquely indetify fragmented datagram. +#[doc = " @internal to uniquely indetify fragmented datagram."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ip_frag_key { - ///< src address, first 8 bytes used for IPv4 + #[doc = "< src address, first 8 bytes used for IPv4"] pub src_dst: [u64; 4usize], - ///< dst address + #[doc = "< dst address"] pub id: u32, - ///< src/dst key length + #[doc = "< src/dst key length"] pub key_len: u32, } #[test] @@ -174,24 +174,24 @@ fn bindgen_test_layout_ip_frag_key() { ) ); } -/// @internal Fragmented packet to reassemble. -/// First two entries in the frags[] array are for the last and first fragments. +#[doc = " @internal Fragmented packet to reassemble."] +#[doc = " First two entries in the frags[] array are for the last and first fragments."] #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_pkt { - ///< LRU list + #[doc = "< LRU list"] pub lru: ip_frag_pkt__bindgen_ty_1, - ///< fragmentation key + #[doc = "< fragmentation key"] pub key: ip_frag_key, - ///< creation timestamp + #[doc = "< creation timestamp"] pub start: u64, - ///< expected reassembled size + #[doc = "< expected reassembled size"] pub total_size: u32, - ///< size of fragments received + #[doc = "< size of fragments received"] pub frag_size: u32, - ///< index of next entry to fill + #[doc = "< index of next entry to fill"] pub last_idx: u32, - ///< fragments + #[doc = "< fragments"] pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -370,21 +370,21 @@ impl Default for ip_pkt_list { unsafe { ::std::mem::zeroed() } } } -/// fragmentation table statistics +#[doc = " fragmentation table statistics"] #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_tbl_stat { - ///< total # of find/insert attempts. + #[doc = "< total # of find/insert attempts."] pub find_num: u64, - ///< # of add ops. + #[doc = "< # of add ops."] pub add_num: u64, - ///< # of del ops. + #[doc = "< # of del ops."] pub del_num: u64, - ///< # of reuse (del/add) ops. + #[doc = "< # of reuse (del/add) ops."] pub reuse_num: u64, - ///< total # of add failures. + #[doc = "< total # of add failures."] pub fail_total: u64, - ///< # of 'no space' add failures. + #[doc = "< # of \'no space\' add failures."] pub fail_nospace: u64, pub __bindgen_padding_0: [u64; 2usize], } @@ -461,31 +461,31 @@ impl Default for ip_frag_tbl_stat { unsafe { ::std::mem::zeroed() } } } -/// fragmentation table +#[doc = " fragmentation table"] #[repr(C)] pub struct rte_ip_frag_tbl { - ///< ttl for table entries. + #[doc = "< ttl for table entries."] pub max_cycles: u64, - ///< hash value mask. + #[doc = "< hash value mask."] pub entry_mask: u32, - ///< max entries allowed. + #[doc = "< max entries allowed."] pub max_entries: u32, - ///< entries in use. + #[doc = "< entries in use."] pub use_entries: u32, - ///< hash assocaitivity. + #[doc = "< hash assocaitivity."] pub bucket_entries: u32, - ///< total size of the table. + #[doc = "< total size of the table."] pub nb_entries: u32, - ///< num of associativity lines. + #[doc = "< num of associativity lines."] pub nb_buckets: u32, - ///< last used entry. + #[doc = "< last used entry."] pub last: *mut ip_frag_pkt, - ///< LRU list for table entries. + #[doc = "< LRU list for table entries."] pub lru: ip_pkt_list, pub __bindgen_padding_0: u64, - ///< statistics counters. + #[doc = "< statistics counters."] pub stat: ip_frag_tbl_stat, - ///< hash table. + #[doc = "< hash table."] pub pkt: __IncompleteArrayField, } #[test] @@ -611,7 +611,7 @@ impl Default for rte_ip_frag_tbl { unsafe { ::std::mem::zeroed() } } } -///< fragment mbuf +#[doc = "< fragment mbuf"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 79b6d687..78131f87 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -16,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -25,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -64,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -83,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -111,11 +95,11 @@ pub type phys_addr_t = u64; pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; -/// The atomic counter structure. +#[doc = " The atomic counter structure."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { - ///< An internal counter value. + #[doc = "< An internal counter value."] pub cnt: i16, } #[test] @@ -141,65 +125,65 @@ fn bindgen_test_layout_rte_atomic16_t() { ) ); } -/// The generic rte_mbuf, containing a packet mbuf. +#[doc = " The generic rte_mbuf, containing a packet mbuf."] #[repr(C)] pub struct rte_mbuf { pub cacheline0: MARKER, - ///< Virtual address of segment buffer. + #[doc = "< Virtual address of segment buffer."] pub buf_addr: *mut ::std::os::raw::c_void, - ///< Physical address of segment buffer. + #[doc = "< Physical address of segment buffer."] pub buf_physaddr: phys_addr_t, - ///< Length of segment buffer. + #[doc = "< Length of segment buffer."] pub buf_len: u16, pub rearm_data: MARKER8, pub data_off: u16, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - ///< Number of segments. + #[doc = "< Number of segments."] pub nb_segs: u8, - ///< Input port. + #[doc = "< Input port."] pub port: u8, - ///< Offload features. + #[doc = "< Offload features."] pub ol_flags: u64, pub rx_descriptor_fields1: MARKER, pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - ///< Total pkt len: sum of all segments. + #[doc = "< Total pkt len: sum of all segments."] pub pkt_len: u32, - ///< Amount of data in segment buffer. + #[doc = "< Amount of data in segment buffer."] pub data_len: u16, - /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. + #[doc = " VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set."] pub vlan_tci: u16, - ///< hash information + #[doc = "< hash information"] pub hash: rte_mbuf__bindgen_ty_3, - ///< Sequence number. See also rte_reorder_insert() + #[doc = "< Sequence number. See also rte_reorder_insert()"] pub seqn: u32, - /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. + #[doc = " Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set."] pub vlan_tci_outer: u16, pub cacheline1: MARKER, pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - ///< Pool from which mbuf was allocated. + #[doc = "< Pool from which mbuf was allocated."] pub pool: *mut rte_mempool, - ///< Next segment of scattered packet. + #[doc = "< Next segment of scattered packet."] pub next: *mut rte_mbuf, pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, - /// Size of the application private data. In case of an indirect - /// mbuf, it stores the direct mbuf private data size. + #[doc = " Size of the application private data. In case of an indirect"] + #[doc = " mbuf, it stores the direct mbuf private data size."] pub priv_size: u16, - /// Timesync flags for use with IEEE1588. + #[doc = " Timesync flags for use with IEEE1588."] pub timesync: u16, pub __bindgen_padding_0: [u32; 7usize], } -/// 16-bit Reference counter. -/// It should only be accessed using the following functions: -/// rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -/// rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -/// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -/// config option. +#[doc = " 16-bit Reference counter."] +#[doc = " It should only be accessed using the following functions:"] +#[doc = " rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and"] +#[doc = " rte_mbuf_refcnt_set(). The functionality of these functions (atomic,"] +#[doc = " or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC"] +#[doc = " config option."] #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_1 { - ///< Atomically accessed refcnt + #[doc = "< Atomically accessed refcnt"] pub refcnt_atomic: rte_atomic16_t, - ///< Non-atomically accessed refcnt + #[doc = "< Non-atomically accessed refcnt"] pub refcnt: u16, _bindgen_union_align: u16, } @@ -246,7 +230,7 @@ impl Default for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_2 { - ///< L2/L3/L4 and tunnel information. + #[doc = "< L2/L3/L4 and tunnel information."] pub packet_type: u32, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_2__bindgen_ty_1, _bindgen_union_align: u32, @@ -430,13 +414,13 @@ impl Default for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3 { - ///< RSS hash result if RSS enabled + #[doc = "< RSS hash result if RSS enabled"] pub rss: u32, - ///< Filter identifier if FDIR enabled + #[doc = "< Filter identifier if FDIR enabled"] pub fdir: rte_mbuf__bindgen_ty_3__bindgen_ty_1, - ///< Hierarchical scheduler + #[doc = "< Hierarchical scheduler"] pub sched: rte_mbuf__bindgen_ty_3__bindgen_ty_2, - ///< User defined tags. See rte_distributor_process() + #[doc = "< User defined tags. See rte_distributor_process()"] pub usr: u32, _bindgen_union_align: [u32; 2usize], } @@ -685,9 +669,9 @@ impl Default for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_4 { - ///< Can be used for external metadata + #[doc = "< Can be used for external metadata"] pub userdata: *mut ::std::os::raw::c_void, - ///< Allow 8-byte userdata on 32-bit + #[doc = "< Allow 8-byte userdata on 32-bit"] pub udata64: u64, _bindgen_union_align: u64, } @@ -732,7 +716,7 @@ impl Default for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_5 { - ///< combined for easy fetch + #[doc = "< combined for easy fetch"] pub tx_offload: u64, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_5__bindgen_ty_1, _bindgen_union_align: u64, @@ -1120,7 +1104,7 @@ impl Default for rte_mbuf { unsafe { ::std::mem::zeroed() } } } -///< Pool from which mbuf was allocated. +#[doc = "< Pool from which mbuf was allocated."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mempool { diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs index 71becc5f..ab5126cb 100644 --- a/tests/expectations/tests/layout_mbuf_1_0.rs +++ b/tests/expectations/tests/layout_mbuf_1_0.rs @@ -16,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -25,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -64,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -83,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; @@ -154,11 +138,11 @@ pub type phys_addr_t = u64; pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; -/// The atomic counter structure. +#[doc = " The atomic counter structure."] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { - ///< An internal counter value. + #[doc = "< An internal counter value."] pub cnt: i16, } #[test] @@ -189,65 +173,65 @@ impl Clone for rte_atomic16_t { *self } } -/// The generic rte_mbuf, containing a packet mbuf. +#[doc = " The generic rte_mbuf, containing a packet mbuf."] #[repr(C)] pub struct rte_mbuf { pub cacheline0: MARKER, - ///< Virtual address of segment buffer. + #[doc = "< Virtual address of segment buffer."] pub buf_addr: *mut ::std::os::raw::c_void, - ///< Physical address of segment buffer. + #[doc = "< Physical address of segment buffer."] pub buf_physaddr: phys_addr_t, - ///< Length of segment buffer. + #[doc = "< Length of segment buffer."] pub buf_len: u16, pub rearm_data: MARKER8, pub data_off: u16, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - ///< Number of segments. + #[doc = "< Number of segments."] pub nb_segs: u8, - ///< Input port. + #[doc = "< Input port."] pub port: u8, - ///< Offload features. + #[doc = "< Offload features."] pub ol_flags: u64, pub rx_descriptor_fields1: MARKER, pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - ///< Total pkt len: sum of all segments. + #[doc = "< Total pkt len: sum of all segments."] pub pkt_len: u32, - ///< Amount of data in segment buffer. + #[doc = "< Amount of data in segment buffer."] pub data_len: u16, - /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. + #[doc = " VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set."] pub vlan_tci: u16, - ///< hash information + #[doc = "< hash information"] pub hash: rte_mbuf__bindgen_ty_3, - ///< Sequence number. See also rte_reorder_insert() + #[doc = "< Sequence number. See also rte_reorder_insert()"] pub seqn: u32, - /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. + #[doc = " Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set."] pub vlan_tci_outer: u16, pub cacheline1: MARKER, pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - ///< Pool from which mbuf was allocated. + #[doc = "< Pool from which mbuf was allocated."] pub pool: *mut rte_mempool, - ///< Next segment of scattered packet. + #[doc = "< Next segment of scattered packet."] pub next: *mut rte_mbuf, pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, - /// Size of the application private data. In case of an indirect - /// mbuf, it stores the direct mbuf private data size. + #[doc = " Size of the application private data. In case of an indirect"] + #[doc = " mbuf, it stores the direct mbuf private data size."] pub priv_size: u16, - /// Timesync flags for use with IEEE1588. + #[doc = " Timesync flags for use with IEEE1588."] pub timesync: u16, pub __bindgen_padding_0: [u32; 7usize], } -/// 16-bit Reference counter. -/// It should only be accessed using the following functions: -/// rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and -/// rte_mbuf_refcnt_set(). The functionality of these functions (atomic, -/// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC -/// config option. +#[doc = " 16-bit Reference counter."] +#[doc = " It should only be accessed using the following functions:"] +#[doc = " rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and"] +#[doc = " rte_mbuf_refcnt_set(). The functionality of these functions (atomic,"] +#[doc = " or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC"] +#[doc = " config option."] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_1 { - ///< Atomically accessed refcnt + #[doc = "< Atomically accessed refcnt"] pub refcnt_atomic: __BindgenUnionField, - ///< Non-atomically accessed refcnt + #[doc = "< Non-atomically accessed refcnt"] pub refcnt: __BindgenUnionField, pub bindgen_union_field: u16, } @@ -294,7 +278,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2 { - ///< L2/L3/L4 and tunnel information. + #[doc = "< L2/L3/L4 and tunnel information."] pub packet_type: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, @@ -483,13 +467,13 @@ impl Clone for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3 { - ///< RSS hash result if RSS enabled + #[doc = "< RSS hash result if RSS enabled"] pub rss: __BindgenUnionField, - ///< Filter identifier if FDIR enabled + #[doc = "< Filter identifier if FDIR enabled"] pub fdir: __BindgenUnionField, - ///< Hierarchical scheduler + #[doc = "< Hierarchical scheduler"] pub sched: __BindgenUnionField, - ///< User defined tags. See rte_distributor_process() + #[doc = "< User defined tags. See rte_distributor_process()"] pub usr: __BindgenUnionField, pub bindgen_union_field: [u32; 2usize], } @@ -749,9 +733,9 @@ impl Clone for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_4 { - ///< Can be used for external metadata + #[doc = "< Can be used for external metadata"] pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, - ///< Allow 8-byte userdata on 32-bit + #[doc = "< Allow 8-byte userdata on 32-bit"] pub udata64: __BindgenUnionField, pub bindgen_union_field: u64, } @@ -796,7 +780,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5 { - ///< combined for easy fetch + #[doc = "< combined for easy fetch"] pub tx_offload: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u64, @@ -1189,7 +1173,7 @@ impl Default for rte_mbuf { unsafe { ::std::mem::zeroed() } } } -///< Pool from which mbuf was allocated. +#[doc = "< Pool from which mbuf was allocated."] #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mempool { diff --git a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs index a0d9ade6..9c972a18 100644 --- a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs @@ -32,5 +32,5 @@ fn bindgen_test_layout_Rooted() { ) ); } -///
+#[doc = "
"] pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs index a0d9ade6..9c972a18 100644 --- a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs @@ -32,5 +32,5 @@ fn bindgen_test_layout_Rooted() { ) ); } -///
+#[doc = "
"] pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs index a09323a8..bd10e1b3 100644 --- a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs @@ -37,7 +37,7 @@ impl Default for Rooted { unsafe { ::std::mem::zeroed() } } } -///
+#[doc = "
"] pub type MaybeWrapped
= a; #[test] fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { diff --git a/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs index a09323a8..851dc4e1 100644 --- a/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs @@ -1,9 +1,7 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Rooted { @@ -37,7 +35,7 @@ impl Default for Rooted { unsafe { ::std::mem::zeroed() } } } -///
+#[doc = "
"] pub type MaybeWrapped
= a; #[test] fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs index 6272d773..e353fa5f 100644 --- a/tests/expectations/tests/no-derive-debug.rs +++ b/tests/expectations/tests/no-derive-debug.rs @@ -1,7 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Default)] @@ -9,10 +13,9 @@ pub struct foo { bar: ::std::os::raw::c_int, } - -/// bar should compile. It will normally derive debug, but our blacklist of foo -/// and replacement for another type that doesn't implement it would prevent it -/// from building if --no-derive-debug didn't work. +#[doc = " bar should compile. It will normally derive debug, but our blacklist of foo"] +#[doc = " and replacement for another type that doesn\'t implement it would prevent it"] +#[doc = " from building if --no-derive-debug didn\'t work."] #[repr(C)] pub struct bar { pub foo: foo, diff --git a/tests/expectations/tests/no-derive-default.rs b/tests/expectations/tests/no-derive-default.rs index da5e1001..9e14693f 100644 --- a/tests/expectations/tests/no-derive-default.rs +++ b/tests/expectations/tests/no-derive-default.rs @@ -1,7 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug)] @@ -9,10 +13,9 @@ pub struct foo { bar: ::std::os::raw::c_int, } - -/// bar should compile. It will normally derive default, but our blacklist of foo -/// and replacement for another type that doesn't implement it would prevent it -/// from building if --no-derive-default didn't work. +#[doc = " bar should compile. It will normally derive default, but our blacklist of foo"] +#[doc = " and replacement for another type that doesn\'t implement it would prevent it"] +#[doc = " from building if --no-derive-default didn\'t work."] #[repr(C)] pub struct bar { pub foo: foo, diff --git a/tests/expectations/tests/no_copy.rs b/tests/expectations/tests/no_copy.rs index 45249668..96fd542c 100644 --- a/tests/expectations/tests/no_copy.rs +++ b/tests/expectations/tests/no_copy.rs @@ -1,11 +1,8 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default)] pub struct CopiableButWait { diff --git a/tests/expectations/tests/only_bitfields.rs b/tests/expectations/tests/only_bitfields.rs index 13713ed2..9d925217 100644 --- a/tests/expectations/tests/only_bitfields.rs +++ b/tests/expectations/tests/only_bitfields.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs index 99e507b8..0245a1ae 100644 --- a/tests/expectations/tests/opaque-template-inst-member-2.rs +++ b/tests/expectations/tests/opaque-template-inst-member-2.rs @@ -1,18 +1,20 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// This is like `opaque-template-inst-member.hpp` except exercising the cases -/// where we are OK to derive Debug/Hash/PartialEq. +#[doc = " This is like `opaque-template-inst-member.hpp` except exercising the cases"] +#[doc = " where we are OK to derive Debug/Hash/PartialEq."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OpaqueTemplate { pub _address: u8, } -/// Should derive Debug/Hash/PartialEq. +#[doc = " Should derive Debug/Hash/PartialEq."] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ContainsOpaqueTemplate { @@ -52,7 +54,7 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() { ) ); } -/// Should also derive Debug/Hash/PartialEq. +#[doc = " Should also derive Debug/Hash/PartialEq."] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct InheritsOpaqueTemplate { diff --git a/tests/expectations/tests/opaque-template-inst-member.rs b/tests/expectations/tests/opaque-template-inst-member.rs index 66531232..4c5af91f 100644 --- a/tests/expectations/tests/opaque-template-inst-member.rs +++ b/tests/expectations/tests/opaque-template-inst-member.rs @@ -1,16 +1,19 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OpaqueTemplate { pub _address: u8, } -/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive -/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash. +#[doc = " This should not end up deriving Debug/Hash because its `mBlah` field cannot derive"] +#[doc = " Debug/Hash because the instantiation\'s definition cannot derive Debug/Hash."] #[repr(C)] pub struct ContainsOpaqueTemplate { pub mBlah: [u32; 101usize], @@ -59,8 +62,8 @@ impl ::std::cmp::PartialEq for ContainsOpaqueTemplate { &self.mBlah[..] == &other.mBlah[..] && self.mBaz == other.mBaz } } -/// This should not end up deriving Debug/Hash either, for similar reasons, although -/// we're exercising base member edges now. +#[doc = " This should not end up deriving Debug/Hash either, for similar reasons, although"] +#[doc = " we\'re exercising base member edges now."] #[repr(C)] pub struct InheritsOpaqueTemplate { pub _base: [u8; 401usize], diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index 59848581..650edf68 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -1,11 +1,8 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct opaque { diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 736655a4..9dbce043 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -1,11 +1,8 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OtherOpaque { @@ -24,7 +21,7 @@ fn bindgen_test_layout_OtherOpaque() { concat!("Alignment of ", stringify!(OtherOpaque)) ); } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs index 96df276c..3f9defd3 100644 --- a/tests/expectations/tests/opaque_typedef.rs +++ b/tests/expectations/tests/opaque_typedef.rs @@ -1,14 +1,12 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct RandomTemplate { pub _address: u8, } -///
+#[doc = "
"] pub type ShouldBeOpaque = u8; pub type ShouldNotBeOpaque = RandomTemplate; diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index 52da1ae4..3329067c 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -1,14 +1,12 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct HasPrivate { pub mNotPrivate: ::std::os::raw::c_int, - ///
+ #[doc = "
"] mIsPrivate: ::std::os::raw::c_int, } #[test] @@ -44,7 +42,7 @@ fn bindgen_test_layout_HasPrivate() { ) ); } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct VeryPrivate { @@ -84,11 +82,11 @@ fn bindgen_test_layout_VeryPrivate() { ) ); } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ContradictPrivate { - ///
+ #[doc = "
"] pub mNotPrivate: ::std::os::raw::c_int, mIsPrivate: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index 38f0cc22..374f2d4b 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -1,9 +1,7 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { #[allow(unused_imports)] @@ -11,7 +9,7 @@ pub mod root { pub mod foo { #[allow(unused_imports)] use self::super::super::root; - ///
+ #[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { diff --git a/tests/expectations/tests/replace_template_alias.rs b/tests/expectations/tests/replace_template_alias.rs index 3ddde177..c82e8b6d 100644 --- a/tests/expectations/tests/replace_template_alias.rs +++ b/tests/expectations/tests/replace_template_alias.rs @@ -1,13 +1,15 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// But the replacement type does use T! -/// -///
+#[doc = " But the replacement type does use T!"] +#[doc = ""] +#[doc = "
"] pub type JS_detail_MaybeWrapped = T; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index c5184b77..c188c27e 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -1,11 +1,8 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct nsTArray { diff --git a/tests/expectations/tests/replaces_double.rs b/tests/expectations/tests/replaces_double.rs index 9d49052e..381e17e7 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -1,9 +1,7 @@ /* automatically generated by rust-bindgen */ - #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Wrapper_Wrapped { @@ -22,7 +20,7 @@ pub struct Rooted { pub ptr: Rooted_MaybeWrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -///
+#[doc = "
"] pub type Rooted_MaybeWrapped = T; impl Default for Rooted { fn default() -> Self { diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/tests/expectations/tests/struct_with_bitfields.rs index 7abd1087..31459452 100644 --- a/tests/expectations/tests/struct_with_bitfields.rs +++ b/tests/expectations/tests/struct_with_bitfields.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index 6083265c..a3d7122c 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] @@ -326,7 +331,7 @@ impl Default for PODButContainsDtor { unsafe { ::std::mem::zeroed() } } } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { @@ -360,7 +365,7 @@ fn bindgen_test_layout_POD() { ) ); } -///
+#[doc = "
"] #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct NestedReplaced { @@ -430,10 +435,10 @@ fn bindgen_test_layout_Untemplated() { pub struct Templated { pub m_untemplated: Untemplated, } -/// If the replacement doesn't happen at the parse level the container would be -/// copy and the replacement wouldn't, so this wouldn't compile. -/// -///
+#[doc = " If the replacement doesn\'t happen at the parse level the container would be"] +#[doc = " copy and the replacement wouldn\'t, so this wouldn\'t compile."] +#[doc = ""] +#[doc = "
"] #[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct ReplacedWithoutDestructor { @@ -467,10 +472,10 @@ impl Default for ShouldNotBeCopiableAsWell { unsafe { ::std::mem::zeroed() } } } -/// If the replacement doesn't happen at the parse level the container would be -/// copy and the replacement wouldn't, so this wouldn't compile. -/// -///
+#[doc = " If the replacement doesn\'t happen at the parse level the container would be"] +#[doc = " copy and the replacement wouldn\'t, so this wouldn\'t compile."] +#[doc = ""] +#[doc = "
"] #[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct ReplacedWithoutDestructorFwd { diff --git a/tests/expectations/tests/templatized-bitfield.rs b/tests/expectations/tests/templatized-bitfield.rs index 68ab6716..239cc9a0 100644 --- a/tests/expectations/tests/templatized-bitfield.rs +++ b/tests/expectations/tests/templatized-bitfield.rs @@ -1,13 +1,15 @@ /* automatically generated by rust-bindgen */ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - - - -/// We don't get a layout for this bitfield, since we don't know what `T` will -/// be, so we cannot allocate bitfield units. The best thing we can do is make -/// the struct opaque. +#[doc = " We don\'t get a layout for this bitfield, since we don\'t know what `T` will"] +#[doc = " be, so we cannot allocate bitfield units. The best thing we can do is make"] +#[doc = " the struct opaque."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct TemplatizedBitfield { diff --git a/tests/expectations/tests/union_bitfield.rs b/tests/expectations/tests/union_bitfield.rs index 0f884bfc..d6f52ef5 100644 --- a/tests/expectations/tests/union_bitfield.rs +++ b/tests/expectations/tests/union_bitfield.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/union_bitfield_1_0.rs b/tests/expectations/tests/union_bitfield_1_0.rs index a86cee18..abc7c4b0 100644 --- a/tests/expectations/tests/union_bitfield_1_0.rs +++ b/tests/expectations/tests/union_bitfield_1_0.rs @@ -16,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -25,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -64,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -83,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/tests/expectations/tests/union_with_anon_struct_bitfield.rs index f5986246..e41fc973 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs index 9a976071..83ee80eb 100644 --- a/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs +++ b/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/weird_bitfields.rs b/tests/expectations/tests/weird_bitfields.rs index 5bedcadd..32220edb 100644 --- a/tests/expectations/tests/weird_bitfields.rs +++ b/tests/expectations/tests/weird_bitfields.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -11,7 +16,6 @@ where storage: Storage, align: [Align; 0], } - impl __BindgenBitfieldUnit where Storage: AsRef<[u8]> + AsMut<[u8]>, @@ -20,38 +24,29 @@ where pub fn new(storage: Storage) -> Self { Self { storage, align: [] } } - #[inline] pub fn get_bit(&self, index: usize) -> bool { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = self.storage.as_ref()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; - byte & mask == mask } - #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { debug_assert!(index / 8 < self.storage.as_ref().len()); - let byte_index = index / 8; let byte = &mut self.storage.as_mut()[byte_index]; - let bit_index = if cfg!(target_endian = "big") { 7 - (index % 8) } else { index % 8 }; - let mask = 1 << bit_index; if val { *byte |= mask; @@ -59,15 +54,12 @@ where *byte &= !mask; } } - #[inline] pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - let mut val = 0; - for i in 0..(bit_width as usize) { if self.get_bit(i + bit_offset) { let index = if cfg!(target_endian = "big") { @@ -78,16 +70,13 @@ where val |= 1 << index; } } - val } - #[inline] pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { debug_assert!(bit_width <= 64); debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); - for i in 0..(bit_width as usize) { let mask = 1 << i; let val_bit_is_set = val & mask == mask; diff --git a/tests/expectations/tests/zero-sized-array.rs b/tests/expectations/tests/zero-sized-array.rs index 11ad0fe6..04788c0b 100644 --- a/tests/expectations/tests/zero-sized-array.rs +++ b/tests/expectations/tests/zero-sized-array.rs @@ -1,8 +1,11 @@ /* automatically generated by rust-bindgen */ - -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] - +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Default)] @@ -41,7 +44,7 @@ impl ::std::clone::Clone for __IncompleteArrayField { } } impl ::std::marker::Copy for __IncompleteArrayField {} -/// Bizarrely enough, this should *not* get an `_address` field. +#[doc = " Bizarrely enough, this should *not* get an `_address` field."] #[repr(C)] #[derive(Debug, Default)] pub struct ZeroSizedArray { @@ -70,7 +73,7 @@ fn bindgen_test_layout_ZeroSizedArray() { ) ); } -/// And nor should this get an `_address` field. +#[doc = " And nor should this get an `_address` field."] #[repr(C)] #[derive(Debug, Default)] pub struct ContainsZeroSizedArray { @@ -99,8 +102,8 @@ fn bindgen_test_layout_ContainsZeroSizedArray() { ) ); } -/// Inheriting from ZeroSizedArray shouldn't cause an `_address` to be inserted -/// either. +#[doc = " Inheriting from ZeroSizedArray shouldn\'t cause an `_address` to be inserted"] +#[doc = " either."] #[repr(C)] #[derive(Debug, Default)] pub struct InheritsZeroSizedArray { @@ -119,7 +122,7 @@ fn bindgen_test_layout_InheritsZeroSizedArray() { concat!("Alignment of ", stringify!(InheritsZeroSizedArray)) ); } -/// And this should not get an `_address` field either. +#[doc = " And this should not get an `_address` field either."] #[repr(C, packed)] #[derive(Debug, Default)] pub struct DynamicallySizedArray { @@ -138,7 +141,7 @@ fn bindgen_test_layout_DynamicallySizedArray() { concat!("Alignment of ", stringify!(DynamicallySizedArray)) ); } -/// No `_address` field here either. +#[doc = " No `_address` field here either."] #[repr(C)] #[derive(Debug, Default)] pub struct ContainsDynamicallySizedArray { -- cgit v1.2.3 From a194b01256a22714ad1fb9afa724b4967bc9b28f Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Mon, 5 Nov 2018 14:55:13 +0100 Subject: Use rustfmt's normalize_doc_attributes, to mostly preserve behavior re. doc comments. --- src/ir/comment.rs | 25 +- tests/expectations/tests/accessors.rs | 22 +- tests/expectations/tests/annotation_hide.rs | 2 +- .../tests/array-of-zero-sized-types.rs | 6 +- .../expectations/tests/blacklist-and-impl-debug.rs | 2 +- tests/expectations/tests/class_use_as.rs | 2 +- tests/expectations/tests/comment-indent.rs | 36 +-- tests/expectations/tests/constify-enum.rs | 2 +- .../tests/contains-vs-inherits-zero-sized.rs | 10 +- .../tests/convert-cpp-comment-to-rust.rs | 8 +- .../tests/derive-bitfield-method-same-name.rs | 6 +- tests/expectations/tests/derive-clone.rs | 2 +- tests/expectations/tests/derive-clone_1_0.rs | 4 +- .../tests/derive-default-and-blacklist.rs | 4 +- .../tests/derive-hash-and-blacklist.rs | 2 +- .../expectations/tests/derive-hash-blacklisting.rs | 6 +- .../derive-hash-struct-with-anon-struct-float.rs | 2 +- .../tests/derive-hash-struct-with-float-array.rs | 2 +- .../tests/derive-hash-struct-with-pointer.rs | 2 +- .../tests/derive-hash-template-def-float.rs | 2 +- .../tests/derive-hash-template-inst-float.rs | 6 +- .../tests/derive-partialeq-and-blacklist.rs | 4 +- tests/expectations/tests/derive-partialeq-union.rs | 2 +- .../tests/derive-partialeq-union_1_0.rs | 2 +- tests/expectations/tests/doggo-or-null.rs | 12 +- tests/expectations/tests/enum-doc-bitfield.rs | 20 +- tests/expectations/tests/enum-doc-mod.rs | 20 +- tests/expectations/tests/enum-doc-rusty.rs | 20 +- tests/expectations/tests/enum-doc.rs | 20 +- tests/expectations/tests/enum-variant-replaces.rs | 14 +- ...erit-from-template-instantiation-with-vtable.rs | 12 +- tests/expectations/tests/issue-537.rs | 20 +- .../tests/issue-648-derive-debug-with-padding.rs | 16 +- .../tests/issue-848-replacement-system-include.rs | 12 +- .../issue-944-derive-copy-and-blacklisting.rs | 9 +- tests/expectations/tests/issue_315.rs | 2 +- tests/expectations/tests/jsval_layout_opaque.rs | 38 +-- .../expectations/tests/jsval_layout_opaque_1_0.rs | 38 +-- tests/expectations/tests/layout_align.rs | 12 +- tests/expectations/tests/layout_arp.rs | 32 +- tests/expectations/tests/layout_array.rs | 64 ++-- tests/expectations/tests/layout_array_too_long.rs | 42 +-- tests/expectations/tests/layout_cmdline_token.rs | 46 +-- tests/expectations/tests/layout_eth_conf.rs | 332 ++++++++++----------- tests/expectations/tests/layout_eth_conf_1_0.rs | 332 ++++++++++----------- tests/expectations/tests/layout_kni_mbuf.rs | 10 +- .../expectations/tests/layout_large_align_field.rs | 80 ++--- tests/expectations/tests/layout_mbuf.rs | 74 ++--- tests/expectations/tests/layout_mbuf_1_0.rs | 74 ++--- .../type_alias_template_specialized.rs | 2 +- .../type_alias_template_specialized.rs | 2 +- .../libclang-4/type_alias_template_specialized.rs | 2 +- .../libclang-5/type_alias_template_specialized.rs | 9 +- tests/expectations/tests/no-derive-debug.rs | 6 +- tests/expectations/tests/no-derive-default.rs | 6 +- tests/expectations/tests/no_copy.rs | 9 +- .../tests/opaque-template-inst-member-2.rs | 8 +- .../tests/opaque-template-inst-member.rs | 8 +- tests/expectations/tests/opaque_in_struct.rs | 9 +- tests/expectations/tests/opaque_pointer.rs | 11 +- tests/expectations/tests/opaque_typedef.rs | 9 +- tests/expectations/tests/private.rs | 15 +- tests/expectations/tests/reparented_replacement.rs | 9 +- tests/expectations/tests/replace_template_alias.rs | 6 +- tests/expectations/tests/replace_use.rs | 9 +- tests/expectations/tests/replaces_double.rs | 9 +- tests/expectations/tests/template.rs | 20 +- tests/expectations/tests/templatized-bitfield.rs | 6 +- tests/expectations/tests/zero-sized-array.rs | 12 +- tests/rustfmt.toml | 2 +- 70 files changed, 872 insertions(+), 809 deletions(-) diff --git a/src/ir/comment.rs b/src/ir/comment.rs index 1a76542c..446e10b4 100644 --- a/src/ir/comment.rs +++ b/src/ir/comment.rs @@ -38,6 +38,19 @@ fn make_indent(indent: usize) -> String { iter::repeat(' ').take(indent * RUST_INDENTATION).collect() } +/// For a comment like `/// foo`, proc_macro2 will turn it into +/// `#[doc = " foo"]`, and rustfmt into `/// foo`, so prevent this by removing +/// the first space of the comment if present. +/// +/// This is a bit hacky. +fn format_line(line: &str) -> &str { + if line.starts_with(" ") { + &line[1..] + } else { + line + } +} + /// Preprocesses multiple single line comments. /// /// Handles lines starting with both `//` and `///`. @@ -52,7 +65,7 @@ fn preprocess_single_lines(comment: &str, indent: usize) -> String { .map(|l| { let indent = if is_first { "" } else { &*indent }; is_first = false; - format!("{}///{}", indent, l) + format!("{}///{}", indent, format_line(l)) }) .collect(); lines.join("\n") @@ -73,7 +86,7 @@ fn preprocess_multi_line(comment: &str, indent: usize) -> String { .map(|line| { let indent = if is_first { "" } else { &*indent }; is_first = false; - format!("{}///{}", indent, line) + format!("{}///{}", indent, format_line(line)) }) .collect(); @@ -97,16 +110,16 @@ mod test { #[test] fn processes_single_lines_correctly() { - assert_eq!(preprocess("/// hello", 0), "/// hello"); - assert_eq!(preprocess("// hello", 0), "/// hello"); - assert_eq!(preprocess("// hello", 0), "/// hello"); + assert_eq!(preprocess("/// hello", 0), "///hello"); + assert_eq!(preprocess("// hello", 0), "///hello"); + assert_eq!(preprocess("// hello", 0), "/// hello"); } #[test] fn processes_multi_lines_correctly() { assert_eq!( preprocess("/** hello \n * world \n * foo \n */", 0), - "/// hello\n/// world\n/// foo" + "///hello\n///world\n///foo" ); assert_eq!( diff --git a/tests/expectations/tests/accessors.rs b/tests/expectations/tests/accessors.rs index b7c41bda..df52a6d5 100644 --- a/tests/expectations/tests/accessors.rs +++ b/tests/expectations/tests/accessors.rs @@ -11,11 +11,11 @@ #[derive(Debug, Default, Copy, Clone)] pub struct SomeAccessors { pub mNoAccessor: ::std::os::raw::c_int, - #[doc = "
"] + ///
pub mBothAccessors: ::std::os::raw::c_int, - #[doc = "
"] + ///
pub mUnsafeAccessors: ::std::os::raw::c_int, - #[doc = "
"] + ///
pub mImmutableAccessor: ::std::os::raw::c_int, } #[test] @@ -95,7 +95,7 @@ impl SomeAccessors { &self.mImmutableAccessor } } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AllAccessors { @@ -153,7 +153,7 @@ impl AllAccessors { &mut self.mAlsoBothAccessors } } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AllUnsafeAccessors { @@ -215,16 +215,16 @@ impl AllUnsafeAccessors { &mut self.mAlsoBothAccessors } } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ContradictAccessors { pub mBothAccessors: ::std::os::raw::c_int, - #[doc = "
"] + ///
pub mNoAccessors: ::std::os::raw::c_int, - #[doc = "
"] + ///
pub mUnsafeAccessors: ::std::os::raw::c_int, - #[doc = "
"] + ///
pub mImmutableAccessor: ::std::os::raw::c_int, } #[test] @@ -310,7 +310,7 @@ impl ContradictAccessors { &self.mImmutableAccessor } } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Replaced { @@ -349,7 +349,7 @@ impl Replaced { &mut self.mAccessor } } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Wrapper { diff --git a/tests/expectations/tests/annotation_hide.rs b/tests/expectations/tests/annotation_hide.rs index d6e854de..d59ed05c 100644 --- a/tests/expectations/tests/annotation_hide.rs +++ b/tests/expectations/tests/annotation_hide.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct D { diff --git a/tests/expectations/tests/array-of-zero-sized-types.rs b/tests/expectations/tests/array-of-zero-sized-types.rs index be8446a6..65442b94 100644 --- a/tests/expectations/tests/array-of-zero-sized-types.rs +++ b/tests/expectations/tests/array-of-zero-sized-types.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " This should get an `_address` byte."] +/// This should get an `_address` byte. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Empty { @@ -26,8 +26,8 @@ fn bindgen_test_layout_Empty() { concat!("Alignment of ", stringify!(Empty)) ); } -#[doc = " This should not get an `_address` byte, since each `Empty` gets one, meaning"] -#[doc = " that this object is addressable."] +/// This should not get an `_address` byte, since each `Empty` gets one, meaning +/// that this object is addressable. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct HasArrayOfEmpty { diff --git a/tests/expectations/tests/blacklist-and-impl-debug.rs b/tests/expectations/tests/blacklist-and-impl-debug.rs index ec757d8f..69f28a56 100644 --- a/tests/expectations/tests/blacklist-and-impl-debug.rs +++ b/tests/expectations/tests/blacklist-and-impl-debug.rs @@ -9,7 +9,7 @@ pub struct BlacklistMe(u8); -#[doc = " Because this type contains a blacklisted type, it should not derive Debug."] +/// Because this type contains a blacklisted type, it should not derive Debug. #[repr(C)] pub struct ShouldManuallyImplDebug { pub a: BlacklistMe, diff --git a/tests/expectations/tests/class_use_as.rs b/tests/expectations/tests/class_use_as.rs index b60e4780..d1f6a5c0 100644 --- a/tests/expectations/tests/class_use_as.rs +++ b/tests/expectations/tests/class_use_as.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct whatever { diff --git a/tests/expectations/tests/comment-indent.rs b/tests/expectations/tests/comment-indent.rs index 78acaf14..2e44746d 100644 --- a/tests/expectations/tests/comment-indent.rs +++ b/tests/expectations/tests/comment-indent.rs @@ -11,17 +11,17 @@ pub mod root { #[allow(unused_imports)] use self::super::root; - #[doc = " This is a multi-line doc comment."] - #[doc = ""] - #[doc = " This class is really really interesting, look!"] + /// This is a multi-line doc comment. + /// + /// This class is really really interesting, look! #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo { pub _address: u8, } - #[doc = " This nested class is also a multi-line doc comment."] - #[doc = ""] - #[doc = " This class is not so interesting, but worth a bit of docs too!"] + /// This nested class is also a multi-line doc comment. + /// + /// This class is not so interesting, but worth a bit of docs too! #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Foo_Bar { @@ -56,18 +56,18 @@ pub mod root { pub mod test { #[allow(unused_imports)] use self::super::super::root; - #[doc = " I\'m in a namespace, and thus I may be on a rust module, most of the time."] - #[doc = " My documentation is pretty extensive, I guess."] + /// I'm in a namespace, and thus I may be on a rust module, most of the time. + /// My documentation is pretty extensive, I guess. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Baz { - #[doc = " This member is plain awesome, just amazing."] - #[doc = ""] - #[doc = " It also has super-extensive docs, with even a nice ascii-art diagram."] - #[doc = ""] - #[doc = " +------+ +-------+"] - #[doc = " | foo | ----> | bar |"] - #[doc = " +------+ +-------+"] + /// This member is plain awesome, just amazing. + /// + /// It also has super-extensive docs, with even a nice ascii-art diagram. + /// + /// +------+ +-------+ + /// | foo | ----> | bar | + /// +------+ +-------+ pub member: ::std::os::raw::c_int, } #[test] @@ -93,9 +93,9 @@ pub mod root { ) ); } - #[doc = " I\'m in an inline namespace, and as such I shouldn\'t get generated inside"] - #[doc = " a rust module, except when the relevant option is specified. Also, this"] - #[doc = " comment shouldn\'t be misaligned."] + /// I'm in an inline namespace, and as such I shouldn't get generated inside + /// a rust module, except when the relevant option is specified. Also, this + /// comment shouldn't be misaligned. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct InInlineNS { diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs index 53ef0b44..a1744a2a 100644 --- a/tests/expectations/tests/constify-enum.rs +++ b/tests/expectations/tests/constify-enum.rs @@ -19,6 +19,6 @@ pub enum nsCSSPropertyID { eCSSProperty_b = 1, eCSSPropertyAlias_aa = 2, eCSSPropertyAlias_bb = 3, - #[doc = "<
"] + /// <
eCSSProperty_COUNT_unexistingVariantValue = 4, } diff --git a/tests/expectations/tests/contains-vs-inherits-zero-sized.rs b/tests/expectations/tests/contains-vs-inherits-zero-sized.rs index 7f30a3b1..9036b12f 100644 --- a/tests/expectations/tests/contains-vs-inherits-zero-sized.rs +++ b/tests/expectations/tests/contains-vs-inherits-zero-sized.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " This should get an `_address` byte."] +/// This should get an `_address` byte. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Empty { @@ -26,8 +26,8 @@ fn bindgen_test_layout_Empty() { concat!("Alignment of ", stringify!(Empty)) ); } -#[doc = " This should not get an `_address` byte, so `sizeof(Inherits)` should be"] -#[doc = " `1`."] +/// This should not get an `_address` byte, so `sizeof(Inherits)` should be +/// `1`. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Inherits { @@ -56,8 +56,8 @@ fn bindgen_test_layout_Inherits() { ) ); } -#[doc = " This should not get an `_address` byte, but contains `Empty` which *does* get"] -#[doc = " one, so `sizeof(Contains)` should be `1 + 1`."] +/// This should not get an `_address` byte, but contains `Empty` which *does* get +/// one, so `sizeof(Contains)` should be `1 + 1`. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Contains { diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs index 6781cd1e..dfc3104b 100644 --- a/tests/expectations/tests/convert-cpp-comment-to-rust.rs +++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs @@ -8,15 +8,15 @@ )] pub type mbedtls_mpi_uint = ::std::os::raw::c_uint; -#[doc = " \\brief MPI structure"] +/// \brief MPI structure #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mbedtls_mpi { - #[doc = "< integer sign"] + /// < integer sign pub s: ::std::os::raw::c_int, - #[doc = "< total # of limbs"] + /// < total # of limbs pub n: ::std::os::raw::c_ulong, - #[doc = "< pointer to limbs"] + /// < pointer to limbs pub p: *mut mbedtls_mpi_uint, } #[test] diff --git a/tests/expectations/tests/derive-bitfield-method-same-name.rs b/tests/expectations/tests/derive-bitfield-method-same-name.rs index e8b33a81..70ee2973 100644 --- a/tests/expectations/tests/derive-bitfield-method-same-name.rs +++ b/tests/expectations/tests/derive-bitfield-method-same-name.rs @@ -89,9 +89,9 @@ where } } } -#[doc = " Because this struct have array larger than 32 items"] -#[doc = " and --with-derive-partialeq --impl-partialeq --impl-debug is provided,"] -#[doc = " this struct should manually implement `Debug` and `PartialEq`."] +/// Because this struct have array larger than 32 items +/// and --with-derive-partialeq --impl-partialeq --impl-debug is provided, +/// this struct should manually implement `Debug` and `PartialEq`. #[repr(C)] #[derive(Copy, Clone)] pub struct Foo { diff --git a/tests/expectations/tests/derive-clone.rs b/tests/expectations/tests/derive-clone.rs index 80dee43d..62042ffc 100644 --- a/tests/expectations/tests/derive-clone.rs +++ b/tests/expectations/tests/derive-clone.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " This struct should derive `Clone`."] +/// This struct should derive `Clone`. #[repr(C)] #[derive(Copy, Clone)] pub struct ShouldDeriveClone { diff --git a/tests/expectations/tests/derive-clone_1_0.rs b/tests/expectations/tests/derive-clone_1_0.rs index b56ded1d..c2fafe8f 100644 --- a/tests/expectations/tests/derive-clone_1_0.rs +++ b/tests/expectations/tests/derive-clone_1_0.rs @@ -7,8 +7,8 @@ non_upper_case_globals )] -#[doc = " Since builtin `Clone` impls were introduced in Rust 1.21 this struct"] -#[doc = " should impl `Clone` \"manually\"."] +/// Since builtin `Clone` impls were introduced in Rust 1.21 this struct +/// should impl `Clone` "manually". #[repr(C)] #[derive(Copy)] pub struct ShouldImplClone { diff --git a/tests/expectations/tests/derive-default-and-blacklist.rs b/tests/expectations/tests/derive-default-and-blacklist.rs index 292e51b0..1520aa3c 100644 --- a/tests/expectations/tests/derive-default-and-blacklist.rs +++ b/tests/expectations/tests/derive-default-and-blacklist.rs @@ -9,8 +9,8 @@ pub struct BlacklistMe(u8); -#[doc = " Because this type contains a blacklisted type, it should not derive"] -#[doc = " Default. Instead, we should emit a `mem::zeroed` implementation."] +/// Because this type contains a blacklisted type, it should not derive +/// Default. Instead, we should emit a `mem::zeroed` implementation. #[repr(C)] pub struct ShouldNotDeriveDefault { pub a: BlacklistMe, diff --git a/tests/expectations/tests/derive-hash-and-blacklist.rs b/tests/expectations/tests/derive-hash-and-blacklist.rs index 8e58055b..92e918ca 100644 --- a/tests/expectations/tests/derive-hash-and-blacklist.rs +++ b/tests/expectations/tests/derive-hash-and-blacklist.rs @@ -9,7 +9,7 @@ pub struct BlacklistMe(u8); -#[doc = " Because this type contains a blacklisted type, it should not derive Hash."] +/// Because this type contains a blacklisted type, it should not derive Hash. #[repr(C)] pub struct ShouldNotDeriveHash { pub a: BlacklistMe, diff --git a/tests/expectations/tests/derive-hash-blacklisting.rs b/tests/expectations/tests/derive-hash-blacklisting.rs index 2bbc4a16..f64db062 100644 --- a/tests/expectations/tests/derive-hash-blacklisting.rs +++ b/tests/expectations/tests/derive-hash-blacklisting.rs @@ -14,8 +14,8 @@ pub struct Blacklisted { pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -#[doc = " This would derive(Hash, Eq, PartialEq) if it didn\'t contain a blacklisted type,"] -#[doc = " causing us to conservatively avoid deriving hash/Eq/PartialEq for it."] +/// This would derive(Hash, Eq, PartialEq) if it didn't contain a blacklisted type, +/// causing us to conservatively avoid deriving hash/Eq/PartialEq for it. #[repr(C)] pub struct WhitelistedOne { pub a: Blacklisted<::std::os::raw::c_int>, @@ -48,7 +48,7 @@ impl Default for WhitelistedOne { unsafe { ::std::mem::zeroed() } } } -#[doc = " This can\'t derive(Hash/Eq) even if it didn\'t contain a blacklisted type."] +/// This can't derive(Hash/Eq) even if it didn't contain a blacklisted type. #[repr(C)] pub struct WhitelistedTwo { pub b: Blacklisted, diff --git a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs index bd0acb04..c3159532 100644 --- a/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs +++ b/tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " A struct containing a struct containing a float that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd"] +/// A struct containing a struct containing a float that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { diff --git a/tests/expectations/tests/derive-hash-struct-with-float-array.rs b/tests/expectations/tests/derive-hash-struct-with-float-array.rs index e2d05e0b..9ff64fde 100644 --- a/tests/expectations/tests/derive-hash-struct-with-float-array.rs +++ b/tests/expectations/tests/derive-hash-struct-with-float-array.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd"] +/// A struct containing an array of floats that cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { diff --git a/tests/expectations/tests/derive-hash-struct-with-pointer.rs b/tests/expectations/tests/derive-hash-struct-with-pointer.rs index 60f8ff46..c0b14b02 100644 --- a/tests/expectations/tests/derive-hash-struct-with-pointer.rs +++ b/tests/expectations/tests/derive-hash-struct-with-pointer.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " Pointers can derive Hash/PartialOrd/Ord/PartialEq/Eq"] +/// Pointers can derive Hash/PartialOrd/Ord/PartialEq/Eq #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct ConstPtrMutObj { diff --git a/tests/expectations/tests/derive-hash-template-def-float.rs b/tests/expectations/tests/derive-hash-template-def-float.rs index f2b338db..b4040802 100644 --- a/tests/expectations/tests/derive-hash-template-def-float.rs +++ b/tests/expectations/tests/derive-hash-template-def-float.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " Template definition containing a float, which cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd."] +/// Template definition containing a float, which cannot derive Hash/Eq/Ord but can derive PartialEq/PartialOrd. #[repr(C)] #[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] pub struct foo { diff --git a/tests/expectations/tests/derive-hash-template-inst-float.rs b/tests/expectations/tests/derive-hash-template-inst-float.rs index 20f7c46c..ee9b3f4c 100644 --- a/tests/expectations/tests/derive-hash-template-inst-float.rs +++ b/tests/expectations/tests/derive-hash-template-inst-float.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " Template definition that doesn\'t contain float can derive Hash/PartialOrd/Ord/PartialEq/Eq"] +/// Template definition that doesn't contain float can derive Hash/PartialOrd/Ord/PartialEq/Eq #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct foo { @@ -19,7 +19,7 @@ impl Default for foo { unsafe { ::std::mem::zeroed() } } } -#[doc = " Can derive Hash/PartialOrd/Ord/PartialEq/Eq when instantiated with int"] +/// Can derive Hash/PartialOrd/Ord/PartialEq/Eq when instantiated with int #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] pub struct IntStr { @@ -48,7 +48,7 @@ impl Default for IntStr { unsafe { ::std::mem::zeroed() } } } -#[doc = " Cannot derive Hash/Eq/Ord when instantiated with float but can derive PartialEq/PartialOrd"] +/// Cannot derive Hash/Eq/Ord when instantiated with float but can derive PartialEq/PartialOrd #[repr(C)] #[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] pub struct FloatStr { diff --git a/tests/expectations/tests/derive-partialeq-and-blacklist.rs b/tests/expectations/tests/derive-partialeq-and-blacklist.rs index 42ae1464..01fdc079 100644 --- a/tests/expectations/tests/derive-partialeq-and-blacklist.rs +++ b/tests/expectations/tests/derive-partialeq-and-blacklist.rs @@ -9,8 +9,8 @@ pub struct BlacklistMe(u8); -#[doc = " Because this type contains a blacklisted type, it should not derive"] -#[doc = " PartialEq."] +/// Because this type contains a blacklisted type, it should not derive +/// PartialEq. #[repr(C)] pub struct ShouldNotDerivePartialEq { pub a: BlacklistMe, diff --git a/tests/expectations/tests/derive-partialeq-union.rs b/tests/expectations/tests/derive-partialeq-union.rs index e8fd542f..a271f410 100644 --- a/tests/expectations/tests/derive-partialeq-union.rs +++ b/tests/expectations/tests/derive-partialeq-union.rs @@ -7,7 +7,7 @@ non_upper_case_globals )] -#[doc = " Deriving PartialEq for rust unions is not supported."] +/// Deriving PartialEq for rust unions is not supported. #[repr(C)] #[derive(Copy, Clone)] pub union ShouldNotDerivePartialEq { diff --git a/tests/expectations/tests/derive-partialeq-union_1_0.rs b/tests/expectations/tests/derive-partialeq-union_1_0.rs index 83fd8333..41a42dd7 100644 --- a/tests/expectations/tests/derive-partialeq-union_1_0.rs +++ b/tests/expectations/tests/derive-partialeq-union_1_0.rs @@ -50,7 +50,7 @@ impl ::std::cmp::PartialEq for __BindgenUnionField { } } impl ::std::cmp::Eq for __BindgenUnionField {} -#[doc = " This should manually derive PartialEq."] +/// This should manually derive PartialEq. #[repr(C)] #[derive(Copy)] pub struct ShouldDerivePartialEq { diff --git a/tests/expectations/tests/doggo-or-null.rs b/tests/expectations/tests/doggo-or-null.rs index 0b84b456..5a7aa86f 100644 --- a/tests/expectations/tests/doggo-or-null.rs +++ b/tests/expectations/tests/doggo-or-null.rs @@ -48,12 +48,12 @@ fn bindgen_test_layout_Null() { concat!("Alignment of ", stringify!(Null)) ); } -#[doc = " This type is an opaque union. Unions can\'t derive anything interesting like"] -#[doc = " Debug or Default, even if their layout can, because it would require knowing"] -#[doc = " which variant is in use. Opaque unions still end up as a `union` in the Rust"] -#[doc = " bindings, but they just have one variant. Even so, can\'t derive. We should"] -#[doc = " probably emit an opaque struct for opaque unions... but until then, we have"] -#[doc = " this test to make sure that opaque unions don\'t derive and still compile."] +/// This type is an opaque union. Unions can't derive anything interesting like +/// Debug or Default, even if their layout can, because it would require knowing +/// which variant is in use. Opaque unions still end up as a `union` in the Rust +/// bindings, but they just have one variant. Even so, can't derive. We should +/// probably emit an opaque struct for opaque unions... but until then, we have +/// this test to make sure that opaque unions don't derive and still compile. #[repr(C)] #[derive(Copy, Clone)] pub union DoggoOrNull { diff --git a/tests/expectations/tests/enum-doc-bitfield.rs b/tests/expectations/tests/enum-doc-bitfield.rs index 7b11d0c6..caa604e4 100644 --- a/tests/expectations/tests/enum-doc-bitfield.rs +++ b/tests/expectations/tests/enum-doc-bitfield.rs @@ -8,30 +8,30 @@ )] impl B { - #[doc = " Document field with three slashes"] + /// Document field with three slashes pub const VAR_A: B = B(0); } impl B { - #[doc = " Document field with preceeding star"] + /// Document field with preceeding star pub const VAR_B: B = B(1); } impl B { - #[doc = " Document field with preceeding exclamation"] + /// Document field with preceeding exclamation pub const VAR_C: B = B(2); } impl B { - #[doc = "< Document field with following star"] + /// < Document field with following star pub const VAR_D: B = B(3); } impl B { - #[doc = "< Document field with following exclamation"] + /// < Document field with following exclamation pub const VAR_E: B = B(4); } impl B { - #[doc = " Document field with preceeding star, with a loong long multiline"] - #[doc = " comment."] - #[doc = ""] - #[doc = " Very interesting documentation, definitely."] + /// Document field with preceeding star, with a loong long multiline + /// comment. + /// + /// Very interesting documentation, definitely. pub const VAR_F: B = B(5); } impl ::std::ops::BitOr for B { @@ -61,6 +61,6 @@ impl ::std::ops::BitAndAssign for B { } } #[repr(C)] -#[doc = " Document enum"] +/// Document enum #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct B(pub u32); diff --git a/tests/expectations/tests/enum-doc-mod.rs b/tests/expectations/tests/enum-doc-mod.rs index 35d671b0..18b27c80 100644 --- a/tests/expectations/tests/enum-doc-mod.rs +++ b/tests/expectations/tests/enum-doc-mod.rs @@ -8,21 +8,21 @@ )] pub mod B { - #[doc = " Document enum"] + /// Document enum pub type Type = u32; - #[doc = " Document field with three slashes"] + /// Document field with three slashes pub const VAR_A: Type = 0; - #[doc = " Document field with preceeding star"] + /// Document field with preceeding star pub const VAR_B: Type = 1; - #[doc = " Document field with preceeding exclamation"] + /// Document field with preceeding exclamation pub const VAR_C: Type = 2; - #[doc = "< Document field with following star"] + /// < Document field with following star pub const VAR_D: Type = 3; - #[doc = "< Document field with following exclamation"] + /// < Document field with following exclamation pub const VAR_E: Type = 4; - #[doc = " Document field with preceeding star, with a loong long multiline"] - #[doc = " comment."] - #[doc = ""] - #[doc = " Very interesting documentation, definitely."] + /// Document field with preceeding star, with a loong long multiline + /// comment. + /// + /// Very interesting documentation, definitely. pub const VAR_F: Type = 5; } diff --git a/tests/expectations/tests/enum-doc-rusty.rs b/tests/expectations/tests/enum-doc-rusty.rs index 8104a45a..a154f103 100644 --- a/tests/expectations/tests/enum-doc-rusty.rs +++ b/tests/expectations/tests/enum-doc-rusty.rs @@ -8,22 +8,22 @@ )] #[repr(u32)] -#[doc = " Document enum"] +/// Document enum #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum B { - #[doc = " Document field with three slashes"] + /// Document field with three slashes VAR_A = 0, - #[doc = " Document field with preceeding star"] + /// Document field with preceeding star VAR_B = 1, - #[doc = " Document field with preceeding exclamation"] + /// Document field with preceeding exclamation VAR_C = 2, - #[doc = "< Document field with following star"] + /// < Document field with following star VAR_D = 3, - #[doc = "< Document field with following exclamation"] + /// < Document field with following exclamation VAR_E = 4, - #[doc = " Document field with preceeding star, with a loong long multiline"] - #[doc = " comment."] - #[doc = ""] - #[doc = " Very interesting documentation, definitely."] + /// Document field with preceeding star, with a loong long multiline + /// comment. + /// + /// Very interesting documentation, definitely. VAR_F = 5, } diff --git a/tests/expectations/tests/enum-doc.rs b/tests/expectations/tests/enum-doc.rs index 4221ca80..9cde2974 100644 --- a/tests/expectations/tests/enum-doc.rs +++ b/tests/expectations/tests/enum-doc.rs @@ -7,20 +7,20 @@ non_upper_case_globals )] -#[doc = " Document field with three slashes"] +/// Document field with three slashes pub const B_VAR_A: B = 0; -#[doc = " Document field with preceeding star"] +/// Document field with preceeding star pub const B_VAR_B: B = 1; -#[doc = " Document field with preceeding exclamation"] +/// Document field with preceeding exclamation pub const B_VAR_C: B = 2; -#[doc = "< Document field with following star"] +/// < Document field with following star pub const B_VAR_D: B = 3; -#[doc = "< Document field with following exclamation"] +/// < Document field with following exclamation pub const B_VAR_E: B = 4; -#[doc = " Document field with preceeding star, with a loong long multiline"] -#[doc = " comment."] -#[doc = ""] -#[doc = " Very interesting documentation, definitely."] +/// Document field with preceeding star, with a loong long multiline +/// comment. +/// +/// Very interesting documentation, definitely. pub const B_VAR_F: B = 5; -#[doc = " Document enum"] +/// Document enum pub type B = u32; diff --git a/tests/expectations/tests/enum-variant-replaces.rs b/tests/expectations/tests/enum-variant-replaces.rs index 9cb48f85..d710e100 100644 --- a/tests/expectations/tests/enum-variant-replaces.rs +++ b/tests/expectations/tests/enum-variant-replaces.rs @@ -7,13 +7,13 @@ non_upper_case_globals )] -#[doc = "
"] -#[doc = ""] -#[doc = " Should see PASS below."] +///
+/// +/// Should see PASS below. pub const OGRErr_PASS: OGRErr = 0; -#[doc = "
"] -#[doc = ""] -#[doc = " Should see OGRERR_NONE instead of CUSTOM_OGRERR_NONE below."] +///
+/// +/// Should see OGRERR_NONE instead of CUSTOM_OGRERR_NONE below. pub const OGRErr_OGRERR_NONE: OGRErr = 1; -#[doc = "
"] +///
pub type OGRErr = u32; diff --git a/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs index 9be33800..19200ac1 100644 --- a/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs +++ b/tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs @@ -9,7 +9,7 @@ #[repr(C)] pub struct BaseWithVtable__bindgen_vtable(::std::os::raw::c_void); -#[doc = " This should have an explicit vtable."] +/// This should have an explicit vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct BaseWithVtable { @@ -22,7 +22,7 @@ impl Default for BaseWithVtable { unsafe { ::std::mem::zeroed() } } } -#[doc = " This should not have an explicit vtable."] +/// This should not have an explicit vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithNoVirtualMethods { @@ -46,7 +46,7 @@ impl Default for DerivedWithNoVirtualMethods { unsafe { ::std::mem::zeroed() } } } -#[doc = " This should not have an explicit vtable."] +/// This should not have an explicit vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithVirtualMethods { @@ -70,7 +70,7 @@ impl Default for DerivedWithVirtualMethods { unsafe { ::std::mem::zeroed() } } } -#[doc = " This should not have any vtable."] +/// This should not have any vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct BaseWithoutVtable { @@ -84,7 +84,7 @@ impl Default for BaseWithoutVtable { } #[repr(C)] pub struct DerivedWithVtable__bindgen_vtable(::std::os::raw::c_void); -#[doc = " This should have an explicit vtable."] +/// This should have an explicit vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithVtable { @@ -109,7 +109,7 @@ impl Default for DerivedWithVtable { unsafe { ::std::mem::zeroed() } } } -#[doc = " This should not have any vtable."] +/// This should not have any vtable. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DerivedWithoutVtable { diff --git a/tests/expectations/tests/issue-537.rs b/tests/expectations/tests/issue-537.rs index 98bc0a96..8913db36 100644 --- a/tests/expectations/tests/issue-537.rs +++ b/tests/expectations/tests/issue-537.rs @@ -7,8 +7,8 @@ non_upper_case_globals )] -#[doc = " This should not be opaque; we can see the attributes and can pack the"] -#[doc = " struct."] +/// This should not be opaque; we can see the attributes and can pack the +/// struct. #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct AlignedToOne { @@ -37,8 +37,8 @@ fn bindgen_test_layout_AlignedToOne() { ) ); } -#[doc = " This should be opaque because although we can see the attributes, Rust"] -#[doc = " doesn\'t have `#[repr(packed = \"N\")]` yet."] +/// This should be opaque because although we can see the attributes, Rust +/// doesn't have `#[repr(packed = "N")]` yet. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct AlignedToTwo { @@ -57,9 +57,9 @@ fn bindgen_test_layout_AlignedToTwo() { concat!("Alignment of ", stringify!(AlignedToTwo)) ); } -#[doc = " This should not be opaque because although `libclang` doesn\'t give us the"] -#[doc = " `#pragma pack(1)`, we can detect that alignment is 1 and add"] -#[doc = " `#[repr(packed)]` to the struct ourselves."] +/// This should not be opaque because although `libclang` doesn't give us the +/// `#pragma pack(1)`, we can detect that alignment is 1 and add +/// `#[repr(packed)]` to the struct ourselves. #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct PackedToOne { @@ -99,9 +99,9 @@ fn bindgen_test_layout_PackedToOne() { ) ); } -#[doc = " In this case, even if we can detect the weird alignment triggered by"] -#[doc = " `#pragma pack(2)`, we can\'t do anything about it because Rust doesn\'t have"] -#[doc = " `#[repr(packed = \"N\")]`. Therefore, we must make it opaque."] +/// In this case, even if we can detect the weird alignment triggered by +/// `#pragma pack(2)`, we can't do anything about it because Rust doesn't have +/// `#[repr(packed = "N")]`. Therefore, we must make it opaque. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct PackedToTwo { diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs index 6df8e4b5..ddd85455 100644 --- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs +++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs @@ -7,10 +7,10 @@ non_upper_case_globals )] -#[doc = " We emit a `[u8; 63usize]` padding field for this struct, which cannot derive"] -#[doc = " Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn\'t end"] -#[doc = " up with the reight alignment, we\'re waiting on `#[repr(align=\"N\")]` to land"] -#[doc = " in rustc)."] +/// We emit a `[u8; 63usize]` padding field for this struct, which cannot derive +/// Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end +/// up with the reight alignment, we're waiting on `#[repr(align="N")]` to land +/// in rustc). #[repr(C)] #[derive(Copy, Clone)] pub struct NoDebug { @@ -45,10 +45,10 @@ impl ::std::cmp::PartialEq for NoDebug { self.c == other.c } } -#[doc = " This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive"] -#[doc = " Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don\'t derive Debug/Hash because"] -#[doc = " we determine Debug derive-ability before we compute padding, which happens at"] -#[doc = " codegen. (Again, we expect to get the alignment wrong for similar reasons.)"] +/// This should derive Debug/Hash/PartialEq/Eq because the padding size is less than the max derive +/// Debug/Hash/PartialEq/Eq impl for arrays. However, we conservatively don't derive Debug/Hash because +/// we determine Debug derive-ability before we compute padding, which happens at +/// codegen. (Again, we expect to get the alignment wrong for similar reasons.) #[repr(C)] #[derive(Copy, Clone)] pub struct ShouldDeriveDebugButDoesNot { diff --git a/tests/expectations/tests/issue-848-replacement-system-include.rs b/tests/expectations/tests/issue-848-replacement-system-include.rs index 4e6efd6b..6e20983f 100644 --- a/tests/expectations/tests/issue-848-replacement-system-include.rs +++ b/tests/expectations/tests/issue-848-replacement-system-include.rs @@ -7,12 +7,12 @@ non_upper_case_globals )] -#[doc = " This is intended to replace another type, but won\'t if we treat this include"] -#[doc = " as a system include, because clang doesn\'t parse comments there."] -#[doc = ""] -#[doc = " See #848."] -#[doc = ""] -#[doc = "
"] +/// This is intended to replace another type, but won't if we treat this include +/// as a system include, because clang doesn't parse comments there. +/// +/// See #848. +/// +///
#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct nsTArray { diff --git a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs b/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs index 2570316b..5ca34ebb 100644 --- a/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs +++ b/tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs @@ -1,10 +1,15 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] pub struct BlacklistMe(u8); -#[doc = " Because this type contains a blacklisted type, it should not derive Copy."] +/// Because this type contains a blacklisted type, it should not derive Copy. #[repr(C)] pub struct ShouldNotBeCopy { pub a: BlacklistMe, diff --git a/tests/expectations/tests/issue_315.rs b/tests/expectations/tests/issue_315.rs index 983452de..1eb30119 100644 --- a/tests/expectations/tests/issue_315.rs +++ b/tests/expectations/tests/issue_315.rs @@ -7,5 +7,5 @@ non_upper_case_globals )] -#[doc = "
"] +///
pub type c
= a; diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/tests/expectations/tests/jsval_layout_opaque.rs index 3c2a0cbe..00b4301c 100644 --- a/tests/expectations/tests/jsval_layout_opaque.rs +++ b/tests/expectations/tests/jsval_layout_opaque.rs @@ -136,43 +136,43 @@ pub enum JSValueShiftedTag { #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSWhyMagic { - #[doc = " a hole in a native object\'s elements"] + /// a hole in a native object's elements JS_ELEMENTS_HOLE = 0, - #[doc = " there is not a pending iterator value"] + /// there is not a pending iterator value JS_NO_ITER_VALUE = 1, - #[doc = " exception value thrown when closing a generator"] + /// exception value thrown when closing a generator JS_GENERATOR_CLOSING = 2, - #[doc = " compiler sentinel value"] + /// compiler sentinel value JS_NO_CONSTANT = 3, - #[doc = " used in debug builds to catch tracing errors"] + /// used in debug builds to catch tracing errors JS_THIS_POISON = 4, - #[doc = " used in debug builds to catch tracing errors"] + /// used in debug builds to catch tracing errors JS_ARG_POISON = 5, - #[doc = " an empty subnode in the AST serializer"] + /// an empty subnode in the AST serializer JS_SERIALIZE_NO_NODE = 6, - #[doc = " lazy arguments value on the stack"] + /// lazy arguments value on the stack JS_LAZY_ARGUMENTS = 7, - #[doc = " optimized-away \'arguments\' value"] + /// optimized-away 'arguments' value JS_OPTIMIZED_ARGUMENTS = 8, - #[doc = " magic value passed to natives to indicate construction"] + /// magic value passed to natives to indicate construction JS_IS_CONSTRUCTING = 9, - #[doc = " arguments.callee has been overwritten"] + /// arguments.callee has been overwritten JS_OVERWRITTEN_CALLEE = 10, - #[doc = " value of static block object slot"] + /// value of static block object slot JS_BLOCK_NEEDS_CLONE = 11, - #[doc = " see class js::HashableValue"] + /// see class js::HashableValue JS_HASH_KEY_EMPTY = 12, - #[doc = " error while running Ion code"] + /// error while running Ion code JS_ION_ERROR = 13, - #[doc = " missing recover instruction result"] + /// missing recover instruction result JS_ION_BAILOUT = 14, - #[doc = " optimized out slot"] + /// optimized out slot JS_OPTIMIZED_OUT = 15, - #[doc = " uninitialized lexical bindings that produce ReferenceError on touch."] + /// uninitialized lexical bindings that produce ReferenceError on touch. JS_UNINITIALIZED_LEXICAL = 16, - #[doc = " for local use"] + /// for local use JS_GENERIC_MAGIC = 17, - #[doc = " for local use"] + /// for local use JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] diff --git a/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/tests/expectations/tests/jsval_layout_opaque_1_0.rs index 539465c3..7bd58819 100644 --- a/tests/expectations/tests/jsval_layout_opaque_1_0.rs +++ b/tests/expectations/tests/jsval_layout_opaque_1_0.rs @@ -179,43 +179,43 @@ pub enum JSValueShiftedTag { #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum JSWhyMagic { - #[doc = " a hole in a native object\'s elements"] + /// a hole in a native object's elements JS_ELEMENTS_HOLE = 0, - #[doc = " there is not a pending iterator value"] + /// there is not a pending iterator value JS_NO_ITER_VALUE = 1, - #[doc = " exception value thrown when closing a generator"] + /// exception value thrown when closing a generator JS_GENERATOR_CLOSING = 2, - #[doc = " compiler sentinel value"] + /// compiler sentinel value JS_NO_CONSTANT = 3, - #[doc = " used in debug builds to catch tracing errors"] + /// used in debug builds to catch tracing errors JS_THIS_POISON = 4, - #[doc = " used in debug builds to catch tracing errors"] + /// used in debug builds to catch tracing errors JS_ARG_POISON = 5, - #[doc = " an empty subnode in the AST serializer"] + /// an empty subnode in the AST serializer JS_SERIALIZE_NO_NODE = 6, - #[doc = " lazy arguments value on the stack"] + /// lazy arguments value on the stack JS_LAZY_ARGUMENTS = 7, - #[doc = " optimized-away \'arguments\' value"] + /// optimized-away 'arguments' value JS_OPTIMIZED_ARGUMENTS = 8, - #[doc = " magic value passed to natives to indicate construction"] + /// magic value passed to natives to indicate construction JS_IS_CONSTRUCTING = 9, - #[doc = " arguments.callee has been overwritten"] + /// arguments.callee has been overwritten JS_OVERWRITTEN_CALLEE = 10, - #[doc = " value of static block object slot"] + /// value of static block object slot JS_BLOCK_NEEDS_CLONE = 11, - #[doc = " see class js::HashableValue"] + /// see class js::HashableValue JS_HASH_KEY_EMPTY = 12, - #[doc = " error while running Ion code"] + /// error while running Ion code JS_ION_ERROR = 13, - #[doc = " missing recover instruction result"] + /// missing recover instruction result JS_ION_BAILOUT = 14, - #[doc = " optimized out slot"] + /// optimized out slot JS_OPTIMIZED_OUT = 15, - #[doc = " uninitialized lexical bindings that produce ReferenceError on touch."] + /// uninitialized lexical bindings that produce ReferenceError on touch. JS_UNINITIALIZED_LEXICAL = 16, - #[doc = " for local use"] + /// for local use JS_GENERIC_MAGIC = 17, - #[doc = " for local use"] + /// for local use JS_WHY_MAGIC_COUNT = 18, } #[repr(C)] diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs index 0979da1e..b994080b 100644 --- a/tests/expectations/tests/layout_align.rs +++ b/tests/expectations/tests/layout_align.rs @@ -129,15 +129,15 @@ impl ::std::marker::Copy for __IncompleteArrayField {} #[repr(C)] #[derive(Debug)] pub struct rte_kni_fifo { - #[doc = "< Next position to be written"] + /// < Next position to be written pub write: ::std::os::raw::c_uint, - #[doc = "< Next position to be read"] + /// < Next position to be read pub read: ::std::os::raw::c_uint, - #[doc = "< Circular buffer length"] + /// < Circular buffer length pub len: ::std::os::raw::c_uint, - #[doc = "< Pointer size - for 32/64 bit OS"] + /// < Pointer size - for 32/64 bit OS pub elem_size: ::std::os::raw::c_uint, - #[doc = "< The buffer contains mbuf pointers"] + /// < The buffer contains mbuf pointers pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, pub __bindgen_align: [u64; 0usize], } @@ -162,7 +162,7 @@ impl Default for rte_kni_fifo { #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct rte_eth_link { - #[doc = "< ETH_SPEED_NUM_"] + /// < ETH_SPEED_NUM_ pub link_speed: u32, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, pub __bindgen_padding_0: [u8; 3usize], diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index 9738393b..ad1762c0 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -15,19 +15,19 @@ pub const ARP_OP_REVREQUEST: u32 = 3; pub const ARP_OP_REVREPLY: u32 = 4; pub const ARP_OP_INVREQUEST: u32 = 8; pub const ARP_OP_INVREPLY: u32 = 9; -#[doc = " Ethernet address:"] -#[doc = " A universally administered address is uniquely assigned to a device by its"] -#[doc = " manufacturer. The first three octets (in transmission order) contain the"] -#[doc = " Organizationally Unique Identifier (OUI). The following three (MAC-48 and"] -#[doc = " EUI-48) octets are assigned by that organization with the only constraint"] -#[doc = " of uniqueness."] -#[doc = " A locally administered address is assigned to a device by a network"] -#[doc = " administrator and does not contain OUIs."] -#[doc = " See http://standards.ieee.org/regauth/groupmac/tutorial.html"] +/// Ethernet address: +/// A universally administered address is uniquely assigned to a device by its +/// manufacturer. The first three octets (in transmission order) contain the +/// Organizationally Unique Identifier (OUI). The following three (MAC-48 and +/// EUI-48) octets are assigned by that organization with the only constraint +/// of uniqueness. +/// A locally administered address is assigned to a device by a network +/// administrator and does not contain OUIs. +/// See http://standards.ieee.org/regauth/groupmac/tutorial.html #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct ether_addr { - #[doc = "< Addr bytes in tx order"] + /// < Addr bytes in tx order pub addr_bytes: [u8; 6usize], } #[test] @@ -53,17 +53,17 @@ fn bindgen_test_layout_ether_addr() { ) ); } -#[doc = " ARP header IPv4 payload."] +/// ARP header IPv4 payload. #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct arp_ipv4 { - #[doc = "< sender hardware address"] + /// < sender hardware address pub arp_sha: ether_addr, - #[doc = "< sender IP address"] + /// < sender IP address pub arp_sip: u32, - #[doc = "< target hardware address"] + /// < target hardware address pub arp_tha: ether_addr, - #[doc = "< target IP address"] + /// < target IP address pub arp_tip: u32, } #[test] @@ -119,7 +119,7 @@ fn bindgen_test_layout_arp_ipv4() { ) ); } -#[doc = " ARP header."] +/// ARP header. #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct arp_hdr { diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index 34e976f4..db57e420 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -16,19 +16,19 @@ pub const RTE_HEAP_NUM_FREELISTS: u32 = 13; pub struct rte_mempool { _unused: [u8; 0], } -#[doc = " Prototype for implementation specific data provisioning function."] -#[doc = ""] -#[doc = " The function should provide the implementation specific memory for"] -#[doc = " for use by the other mempool ops functions in a given mempool ops struct."] -#[doc = " E.g. the default ops provides an instance of the rte_ring for this purpose."] -#[doc = " it will most likely point to a different type of data structure, and"] -#[doc = " will be transparent to the application programmer."] -#[doc = " This function should set mp->pool_data."] +/// Prototype for implementation specific data provisioning function. +/// +/// The function should provide the implementation specific memory for +/// for use by the other mempool ops functions in a given mempool ops struct. +/// E.g. the default ops provides an instance of the rte_ring for this purpose. +/// it will most likely point to a different type of data structure, and +/// will be transparent to the application programmer. +/// This function should set mp->pool_data. pub type rte_mempool_alloc_t = ::std::option::Option ::std::os::raw::c_int>; -#[doc = " Free the opaque private data pointed to by mp->pool_data pointer."] +/// Free the opaque private data pointed to by mp->pool_data pointer. pub type rte_mempool_free_t = ::std::option::Option; -#[doc = " Enqueue an object into the external pool."] +/// Enqueue an object into the external pool. pub type rte_mempool_enqueue_t = ::std::option::Option< unsafe extern "C" fn( mp: *mut rte_mempool, @@ -36,7 +36,7 @@ pub type rte_mempool_enqueue_t = ::std::option::Option< n: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >; -#[doc = " Dequeue an object from the external pool."] +/// Dequeue an object from the external pool. pub type rte_mempool_dequeue_t = ::std::option::Option< unsafe extern "C" fn( mp: *mut rte_mempool, @@ -44,24 +44,24 @@ pub type rte_mempool_dequeue_t = ::std::option::Option< n: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >; -#[doc = " Return the number of available objects in the external pool."] +/// Return the number of available objects in the external pool. pub type rte_mempool_get_count = ::std::option::Option ::std::os::raw::c_uint>; -#[doc = " Structure defining mempool operations structure"] +/// Structure defining mempool operations structure #[repr(C)] #[derive(Copy, Clone)] pub struct rte_mempool_ops { - #[doc = "< Name of mempool ops struct."] + /// < Name of mempool ops struct. pub name: [::std::os::raw::c_char; 32usize], - #[doc = "< Allocate private data."] + /// < Allocate private data. pub alloc: rte_mempool_alloc_t, - #[doc = "< Free the external pool."] + /// < Free the external pool. pub free: rte_mempool_free_t, - #[doc = "< Enqueue an object."] + /// < Enqueue an object. pub enqueue: rte_mempool_enqueue_t, - #[doc = "< Dequeue an object."] + /// < Dequeue an object. pub dequeue: rte_mempool_dequeue_t, - #[doc = "< Get qty of available objs."] + /// < Get qty of available objs. pub get_count: rte_mempool_get_count, pub __bindgen_padding_0: [u64; 7usize], } @@ -148,11 +148,11 @@ impl ::std::cmp::PartialEq for rte_mempool_ops { && self.get_count == other.get_count } } -#[doc = " The rte_spinlock_t type."] +/// The rte_spinlock_t type. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_spinlock_t { - #[doc = "< lock status 0 = unlocked, 1 = locked"] + /// < lock status 0 = unlocked, 1 = locked pub locked: ::std::os::raw::c_int, } #[test] @@ -178,22 +178,22 @@ fn bindgen_test_layout_rte_spinlock_t() { ) ); } -#[doc = " Structure storing the table of registered ops structs, each of which contain"] -#[doc = " the function pointers for the mempool ops functions."] -#[doc = " Each process has its own storage for this ops struct array so that"] -#[doc = " the mempools can be shared across primary and secondary processes."] -#[doc = " The indices used to access the array are valid across processes, whereas"] -#[doc = " any function pointers stored directly in the mempool struct would not be."] -#[doc = " This results in us simply having \"ops_index\" in the mempool struct."] +/// Structure storing the table of registered ops structs, each of which contain +/// the function pointers for the mempool ops functions. +/// Each process has its own storage for this ops struct array so that +/// the mempools can be shared across primary and secondary processes. +/// The indices used to access the array are valid across processes, whereas +/// any function pointers stored directly in the mempool struct would not be. +/// This results in us simply having "ops_index" in the mempool struct. #[repr(C)] #[derive(Copy, Clone)] pub struct rte_mempool_ops_table { - #[doc = "< Spinlock for add/delete."] + /// < Spinlock for add/delete. pub sl: rte_spinlock_t, - #[doc = "< Number of used ops structs in the table."] + /// < Number of used ops structs in the table. pub num_ops: u32, pub __bindgen_padding_0: [u64; 7usize], - #[doc = " Storage for all possible ops structs."] + /// Storage for all possible ops structs. pub ops: [rte_mempool_ops; 16usize], } #[test] @@ -239,7 +239,7 @@ impl Default for rte_mempool_ops_table { unsafe { ::std::mem::zeroed() } } } -#[doc = " Structure to hold malloc heap"] +/// Structure to hold malloc heap #[repr(C)] #[derive(Copy, Clone)] pub struct malloc_heap { diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index c53b028e..f6a497f2 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -16,23 +16,23 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_1 { - #[doc = "< index of last fragment"] + /// < index of last fragment IP_LAST_FRAG_IDX = 0, - #[doc = "< index of first fragment"] + /// < index of first fragment IP_FIRST_FRAG_IDX = 1, - #[doc = "< minimum number of fragments"] + /// < minimum number of fragments IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } -#[doc = " @internal fragmented mbuf"] +/// @internal fragmented mbuf #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag { - #[doc = "< offset into the packet"] + /// < offset into the packet pub ofs: u16, - #[doc = "< length of fragment"] + /// < length of fragment pub len: u16, - #[doc = "< fragment mbuf"] + /// < fragment mbuf pub mb: *mut rte_mbuf, } #[test] @@ -83,15 +83,15 @@ impl Default for ip_frag { unsafe { ::std::mem::zeroed() } } } -#[doc = " @internal to uniquely indetify fragmented datagram."] +/// @internal to uniquely indetify fragmented datagram. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag_key { - #[doc = "< src address, first 8 bytes used for IPv4"] + /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], - #[doc = "< dst address"] + /// < dst address pub id: u32, - #[doc = "< src/dst key length"] + /// < src/dst key length pub key_len: u32, } #[test] @@ -137,24 +137,24 @@ fn bindgen_test_layout_ip_frag_key() { ) ); } -#[doc = " @internal Fragmented packet to reassemble."] -#[doc = " First two entries in the frags[] array are for the last and first fragments."] +/// @internal Fragmented packet to reassemble. +/// First two entries in the frags[] array are for the last and first fragments. #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_pkt { - #[doc = "< LRU list"] + /// < LRU list pub lru: ip_frag_pkt__bindgen_ty_1, - #[doc = "< fragmentation key"] + /// < fragmentation key pub key: ip_frag_key, - #[doc = "< creation timestamp"] + /// < creation timestamp pub start: u64, - #[doc = "< expected reassembled size"] + /// < expected reassembled size pub total_size: u32, - #[doc = "< size of fragments received"] + /// < size of fragments received pub frag_size: u32, - #[doc = "< index of next entry to fill"] + /// < index of next entry to fill pub last_idx: u32, - #[doc = "< fragments"] + /// < fragments pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -300,7 +300,7 @@ impl ::std::cmp::PartialEq for ip_frag_pkt { && self.frags == other.frags } } -#[doc = "< fragment mbuf"] +/// < fragment mbuf #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_cmdline_token.rs b/tests/expectations/tests/layout_cmdline_token.rs index f5b0d1d1..e8b72843 100644 --- a/tests/expectations/tests/layout_cmdline_token.rs +++ b/tests/expectations/tests/layout_cmdline_token.rs @@ -7,8 +7,8 @@ non_upper_case_globals )] -#[doc = " Stores a pointer to the ops struct, and the offset: the place to"] -#[doc = " write the parsed result in the destination structure."] +/// Stores a pointer to the ops struct, and the offset: the place to +/// write the parsed result in the destination structure. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct cmdline_token_hdr { @@ -54,27 +54,27 @@ impl Default for cmdline_token_hdr { } } pub type cmdline_parse_token_hdr_t = cmdline_token_hdr; -#[doc = " A token is defined by this structure."] -#[doc = ""] -#[doc = " parse() takes the token as first argument, then the source buffer"] -#[doc = " starting at the token we want to parse. The 3rd arg is a pointer"] -#[doc = " where we store the parsed data (as binary). It returns the number of"] -#[doc = " parsed chars on success and a negative value on error."] -#[doc = ""] -#[doc = " complete_get_nb() returns the number of possible values for this"] -#[doc = " token if completion is possible. If it is NULL or if it returns 0,"] -#[doc = " no completion is possible."] -#[doc = ""] -#[doc = " complete_get_elt() copy in dstbuf (the size is specified in the"] -#[doc = " parameter) the i-th possible completion for this token. returns 0"] -#[doc = " on success or and a negative value on error."] -#[doc = ""] -#[doc = " get_help() fills the dstbuf with the help for the token. It returns"] -#[doc = " -1 on error and 0 on success."] +/// A token is defined by this structure. +/// +/// parse() takes the token as first argument, then the source buffer +/// starting at the token we want to parse. The 3rd arg is a pointer +/// where we store the parsed data (as binary). It returns the number of +/// parsed chars on success and a negative value on error. +/// +/// complete_get_nb() returns the number of possible values for this +/// token if completion is possible. If it is NULL or if it returns 0, +/// no completion is possible. +/// +/// complete_get_elt() copy in dstbuf (the size is specified in the +/// parameter) the i-th possible completion for this token. returns 0 +/// on success or and a negative value on error. +/// +/// get_help() fills the dstbuf with the help for the token. It returns +/// -1 on error and 0 on success. #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct cmdline_token_ops { - #[doc = " parse(token ptr, buf, res pts, buf len)"] + /// parse(token ptr, buf, res pts, buf len) pub parse: ::std::option::Option< unsafe extern "C" fn( arg1: *mut cmdline_parse_token_hdr_t, @@ -83,11 +83,11 @@ pub struct cmdline_token_ops { arg4: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >, - #[doc = " return the num of possible choices for this token"] + /// return the num of possible choices for this token pub complete_get_nb: ::std::option::Option< unsafe extern "C" fn(arg1: *mut cmdline_parse_token_hdr_t) -> ::std::os::raw::c_int, >, - #[doc = " return the elt x for this token (token, idx, dstbuf, size)"] + /// return the elt x for this token (token, idx, dstbuf, size) pub complete_get_elt: ::std::option::Option< unsafe extern "C" fn( arg1: *mut cmdline_parse_token_hdr_t, @@ -96,7 +96,7 @@ pub struct cmdline_token_ops { arg4: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int, >, - #[doc = " get help for this token (token, dstbuf, size)"] + /// get help for this token (token, dstbuf, size) pub get_help: ::std::option::Option< unsafe extern "C" fn( arg1: *mut cmdline_parse_token_hdr_t, diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 77e3d845..7fde7a1a 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -122,36 +122,36 @@ pub const RTE_ETH_FLOW_GENEVE: u32 = 20; pub const RTE_ETH_FLOW_NVGRE: u32 = 21; pub const RTE_ETH_FLOW_MAX: u32 = 22; #[repr(u32)] -#[doc = " A set of values to identify what method is to be used to route"] -#[doc = " packets to multiple queues."] +/// A set of values to identify what method is to be used to route +/// packets to multiple queues. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_rx_mq_mode { - #[doc = " None of DCB,RSS or VMDQ mode"] + /// None of DCB,RSS or VMDQ mode ETH_MQ_RX_NONE = 0, - #[doc = " For RX side, only RSS is on"] + /// For RX side, only RSS is on ETH_MQ_RX_RSS = 1, - #[doc = " For RX side,only DCB is on."] + /// For RX side,only DCB is on. ETH_MQ_RX_DCB = 2, - #[doc = " Both DCB and RSS enable"] + /// Both DCB and RSS enable ETH_MQ_RX_DCB_RSS = 3, - #[doc = " Only VMDQ, no RSS nor DCB"] + /// Only VMDQ, no RSS nor DCB ETH_MQ_RX_VMDQ_ONLY = 4, - #[doc = " RSS mode with VMDQ"] + /// RSS mode with VMDQ ETH_MQ_RX_VMDQ_RSS = 5, - #[doc = " Use VMDQ+DCB to route traffic to queues"] + /// Use VMDQ+DCB to route traffic to queues ETH_MQ_RX_VMDQ_DCB = 6, - #[doc = " Enable both VMDQ and DCB in VMDq"] + /// Enable both VMDQ and DCB in VMDq ETH_MQ_RX_VMDQ_DCB_RSS = 7, } -#[doc = " A structure used to configure the RX features of an Ethernet port."] +/// A structure used to configure the RX features of an Ethernet port. #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { - #[doc = " The multi-queue packet distribution mode to be used, e.g. RSS."] + /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, - #[doc = "< Only used if jumbo_frame enabled."] + /// < Only used if jumbo_frame enabled. pub max_rx_pkt_len: u32, - #[doc = "< hdr buf size (header_split enabled)."] + /// < hdr buf size (header_split enabled). pub split_hdr_size: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, } @@ -357,24 +357,24 @@ impl rte_eth_rxmode { } } #[repr(u32)] -#[doc = " A set of values to identify what method is to be used to transmit"] -#[doc = " packets using multi-TCs."] +/// A set of values to identify what method is to be used to transmit +/// packets using multi-TCs. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_tx_mq_mode { - #[doc = "< It is in neither DCB nor VT mode."] + /// < It is in neither DCB nor VT mode. ETH_MQ_TX_NONE = 0, - #[doc = "< For TX side,only DCB is on."] + /// < For TX side,only DCB is on. ETH_MQ_TX_DCB = 1, - #[doc = "< For TX side,both DCB and VT is on."] + /// < For TX side,both DCB and VT is on. ETH_MQ_TX_VMDQ_DCB = 2, - #[doc = "< Only VT on, no DCB"] + /// < Only VT on, no DCB ETH_MQ_TX_VMDQ_ONLY = 3, } -#[doc = " A structure used to configure the TX features of an Ethernet port."] +/// A structure used to configure the TX features of an Ethernet port. #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { - #[doc = "< TX multi-queues mode."] + /// < TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, pub pvid: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -476,29 +476,29 @@ impl rte_eth_txmode { __bindgen_bitfield_unit } } -#[doc = " A structure used to configure the Receive Side Scaling (RSS) feature"] -#[doc = " of an Ethernet port."] -#[doc = " If not NULL, the *rss_key* pointer of the *rss_conf* structure points"] -#[doc = " to an array holding the RSS key to use for hashing specific header"] -#[doc = " fields of received packets. The length of this array should be indicated"] -#[doc = " by *rss_key_len* below. Otherwise, a default random hash key is used by"] -#[doc = " the device driver."] -#[doc = ""] -#[doc = " The *rss_key_len* field of the *rss_conf* structure indicates the length"] -#[doc = " in bytes of the array pointed by *rss_key*. To be compatible, this length"] -#[doc = " will be checked in i40e only. Others assume 40 bytes to be used as before."] -#[doc = ""] -#[doc = " The *rss_hf* field of the *rss_conf* structure indicates the different"] -#[doc = " types of IPv4/IPv6 packets to which the RSS hashing must be applied."] -#[doc = " Supplying an *rss_hf* equal to zero disables the RSS feature."] +/// A structure used to configure the Receive Side Scaling (RSS) feature +/// of an Ethernet port. +/// If not NULL, the *rss_key* pointer of the *rss_conf* structure points +/// to an array holding the RSS key to use for hashing specific header +/// fields of received packets. The length of this array should be indicated +/// by *rss_key_len* below. Otherwise, a default random hash key is used by +/// the device driver. +/// +/// The *rss_key_len* field of the *rss_conf* structure indicates the length +/// in bytes of the array pointed by *rss_key*. To be compatible, this length +/// will be checked in i40e only. Others assume 40 bytes to be used as before. +/// +/// The *rss_hf* field of the *rss_conf* structure indicates the different +/// types of IPv4/IPv6 packets to which the RSS hashing must be applied. +/// Supplying an *rss_hf* equal to zero disables the RSS feature. #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { - #[doc = "< If not NULL, 40-byte hash key."] + /// < If not NULL, 40-byte hash key. pub rss_key: *mut u8, - #[doc = "< hash key length in bytes."] + /// < hash key length in bytes. pub rss_key_len: u8, - #[doc = "< Hash functions to apply - see below."] + /// < Hash functions to apply - see below. pub rss_hf: u64, } #[test] @@ -550,59 +550,59 @@ impl Default for rte_eth_rss_conf { } } #[repr(u32)] -#[doc = " This enum indicates the possible number of traffic classes"] -#[doc = " in DCB configratioins"] +/// This enum indicates the possible number of traffic classes +/// in DCB configratioins #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { - #[doc = "< 4 TCs with DCB."] + /// < 4 TCs with DCB. ETH_4_TCS = 4, - #[doc = "< 8 TCs with DCB."] + /// < 8 TCs with DCB. ETH_8_TCS = 8, } #[repr(u32)] -#[doc = " This enum indicates the possible number of queue pools"] -#[doc = " in VMDQ configurations."] +/// This enum indicates the possible number of queue pools +/// in VMDQ configurations. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { - #[doc = "< 8 VMDq pools."] + /// < 8 VMDq pools. ETH_8_POOLS = 8, - #[doc = "< 16 VMDq pools."] + /// < 16 VMDq pools. ETH_16_POOLS = 16, - #[doc = "< 32 VMDq pools."] + /// < 32 VMDq pools. ETH_32_POOLS = 32, - #[doc = "< 64 VMDq pools."] + /// < 64 VMDq pools. ETH_64_POOLS = 64, } -#[doc = " A structure used to configure the VMDQ+DCB feature"] -#[doc = " of an Ethernet port."] -#[doc = ""] -#[doc = " Using this feature, packets are routed to a pool of queues, based"] -#[doc = " on the vlan id in the vlan tag, and then to a specific queue within"] -#[doc = " that pool, using the user priority vlan tag field."] -#[doc = ""] -#[doc = " A default pool may be used, if desired, to route all traffic which"] -#[doc = " does not match the vlan filter rules."] +/// A structure used to configure the VMDQ+DCB feature +/// of an Ethernet port. +/// +/// Using this feature, packets are routed to a pool of queues, based +/// on the vlan id in the vlan tag, and then to a specific queue within +/// that pool, using the user priority vlan tag field. +/// +/// A default pool may be used, if desired, to route all traffic which +/// does not match the vlan filter rules. #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_vmdq_dcb_conf { - #[doc = "< With DCB, 16 or 32 pools"] + /// < With DCB, 16 or 32 pools pub nb_queue_pools: rte_eth_nb_pools, - #[doc = "< If non-zero, use a default pool"] + /// < If non-zero, use a default pool pub enable_default_pool: u8, - #[doc = "< The default pool, if applicable"] + /// < The default pool, if applicable pub default_pool: u8, - #[doc = "< We can have up to 64 filters/mappings"] + /// < We can have up to 64 filters/mappings pub nb_pool_maps: u8, - #[doc = "< VMDq vlan pool maps."] + /// < VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], pub dcb_tc: [u8; 8usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - #[doc = "< The vlan id of the received frame"] + /// < The vlan id of the received frame pub vlan_id: u16, - #[doc = "< Bitmask of pools for packet rx"] + /// < Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -737,9 +737,9 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { - #[doc = "< Possible DCB TCs, 4 or 8 TCs"] + /// < Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, - #[doc = " Traffic class each UP mapped to."] + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -783,9 +783,9 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { - #[doc = "< With DCB, 16 or 32 pools."] + /// < With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, - #[doc = " Traffic class each UP mapped to."] + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -831,9 +831,9 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { - #[doc = "< Possible DCB TCs, 4 or 8 TCs."] + /// < Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, - #[doc = " Traffic class each UP mapped to."] + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -877,7 +877,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { - #[doc = "< VMDq mode, 64 pools."] + /// < VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -913,27 +913,27 @@ impl Default for rte_eth_vmdq_tx_conf { #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_vmdq_rx_conf { - #[doc = "< VMDq only mode, 8 or 64 pools"] + /// < VMDq only mode, 8 or 64 pools pub nb_queue_pools: rte_eth_nb_pools, - #[doc = "< If non-zero, use a default pool"] + /// < If non-zero, use a default pool pub enable_default_pool: u8, - #[doc = "< The default pool, if applicable"] + /// < The default pool, if applicable pub default_pool: u8, - #[doc = "< Enable VT loop back"] + /// < Enable VT loop back pub enable_loop_back: u8, - #[doc = "< We can have up to 64 filters/mappings"] + /// < We can have up to 64 filters/mappings pub nb_pool_maps: u8, - #[doc = "< Flags from ETH_VMDQ_ACCEPT_*"] + /// < Flags from ETH_VMDQ_ACCEPT_* pub rx_mode: u32, - #[doc = "< VMDq vlan pool maps."] + /// < VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - #[doc = "< The vlan id of the received frame"] + /// < The vlan id of the received frame pub vlan_id: u16, - #[doc = "< Bitmask of pools for packet rx"] + /// < Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -1078,56 +1078,56 @@ impl Default for rte_eth_vmdq_rx_conf { } } #[repr(u32)] -#[doc = " Flow Director setting modes: none, signature or perfect."] +/// Flow Director setting modes: none, signature or perfect. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { - #[doc = "< Disable FDIR support."] + /// < Disable FDIR support. RTE_FDIR_MODE_NONE = 0, - #[doc = "< Enable FDIR signature filter mode."] + /// < Enable FDIR signature filter mode. RTE_FDIR_MODE_SIGNATURE = 1, - #[doc = "< Enable FDIR perfect filter mode."] + /// < Enable FDIR perfect filter mode. RTE_FDIR_MODE_PERFECT = 2, - #[doc = "< Enable FDIR filter mode - MAC VLAN."] + /// < Enable FDIR filter mode - MAC VLAN. RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - #[doc = "< Enable FDIR filter mode - tunnel."] + /// < Enable FDIR filter mode - tunnel. RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] -#[doc = " Memory space that can be configured to store Flow Director filters"] -#[doc = " in the board memory."] +/// Memory space that can be configured to store Flow Director filters +/// in the board memory. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { - #[doc = "< 64k."] + /// < 64k. RTE_FDIR_PBALLOC_64K = 0, - #[doc = "< 128k."] + /// < 128k. RTE_FDIR_PBALLOC_128K = 1, - #[doc = "< 256k."] + /// < 256k. RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] -#[doc = " Select report mode of FDIR hash information in RX descriptors."] +/// Select report mode of FDIR hash information in RX descriptors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { - #[doc = "< Never report FDIR hash."] + /// < Never report FDIR hash. RTE_FDIR_NO_REPORT_STATUS = 0, - #[doc = "< Only report FDIR hash for matching pkts."] + /// < Only report FDIR hash for matching pkts. RTE_FDIR_REPORT_STATUS = 1, - #[doc = "< Always report FDIR hash."] + /// < Always report FDIR hash. RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } -#[doc = " A structure used to define the input for IPV4 flow"] +/// A structure used to define the input for IPV4 flow #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { - #[doc = "< IPv4 source address in big endian."] + /// < IPv4 source address in big endian. pub src_ip: u32, - #[doc = "< IPv4 destination address in big endian."] + /// < IPv4 destination address in big endian. pub dst_ip: u32, - #[doc = "< Type of service to match."] + /// < Type of service to match. pub tos: u8, - #[doc = "< Time to live to match."] + /// < Time to live to match. pub ttl: u8, - #[doc = "< Protocol, next header in big endian."] + /// < Protocol, next header in big endian. pub proto: u8, } #[test] @@ -1193,19 +1193,19 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() { ) ); } -#[doc = " A structure used to define the input for IPV6 flow"] +/// A structure used to define the input for IPV6 flow #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { - #[doc = "< IPv6 source address in big endian."] + /// < IPv6 source address in big endian. pub src_ip: [u32; 4usize], - #[doc = "< IPv6 destination address in big endian."] + /// < IPv6 destination address in big endian. pub dst_ip: [u32; 4usize], - #[doc = "< Traffic class to match."] + /// < Traffic class to match. pub tc: u8, - #[doc = "< Protocol, next header to match."] + /// < Protocol, next header to match. pub proto: u8, - #[doc = "< Hop limits to match."] + /// < Hop limits to match. pub hop_limits: u8, } #[test] @@ -1271,28 +1271,28 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() { ) ); } -#[doc = " A structure used to configure FDIR masks that are used by the device"] -#[doc = " to match the various fields of RX packet headers."] +/// A structure used to configure FDIR masks that are used by the device +/// to match the various fields of RX packet headers. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { - #[doc = "< Bit mask for vlan_tci in big endian"] + /// < Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, - #[doc = " Bit mask for ipv4 flow in big endian."] + /// Bit mask for ipv4 flow in big endian. pub ipv4_mask: rte_eth_ipv4_flow, - #[doc = " Bit maks for ipv6 flow in big endian."] + /// Bit maks for ipv6 flow in big endian. pub ipv6_mask: rte_eth_ipv6_flow, - #[doc = " Bit mask for L4 source port in big endian."] + /// Bit mask for L4 source port in big endian. pub src_port_mask: u16, - #[doc = " Bit mask for L4 destination port in big endian."] + /// Bit mask for L4 destination port in big endian. pub dst_port_mask: u16, - #[doc = " 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the"] - #[doc = "first byte on the wire"] + /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the + /// first byte on the wire pub mac_addr_byte_mask: u8, - #[doc = " Bit mask for tunnel ID in big endian."] + /// Bit mask for tunnel ID in big endian. pub tunnel_id_mask: u32, - #[doc = "< 1 - Match tunnel type,"] - #[doc = "0 - Ignore tunnel type."] + /// < 1 - Match tunnel type, + /// 0 - Ignore tunnel type. pub tunnel_type_mask: u8, } #[test] @@ -1401,7 +1401,7 @@ fn bindgen_test_layout_rte_eth_fdir_masks() { ); } #[repr(u32)] -#[doc = " Payload type"] +/// Payload type #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_payload_type { RTE_ETH_PAYLOAD_UNKNOWN = 0, @@ -1411,12 +1411,12 @@ pub enum rte_eth_payload_type { RTE_ETH_L4_PAYLOAD = 4, RTE_ETH_PAYLOAD_MAX = 8, } -#[doc = " A structure used to select bytes extracted from the protocol layers to"] -#[doc = " flexible payload for filter"] +/// A structure used to select bytes extracted from the protocol layers to +/// flexible payload for filter #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { - #[doc = "< Payload type"] + /// < Payload type pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1460,8 +1460,8 @@ impl Default for rte_eth_flex_payload_cfg { unsafe { ::std::mem::zeroed() } } } -#[doc = " A structure used to define FDIR masks for flexible payload"] -#[doc = " for each flow type"] +/// A structure used to define FDIR masks for flexible payload +/// for each flow type #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { @@ -1503,14 +1503,14 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() { ) ); } -#[doc = " A structure used to define all flexible payload related setting"] -#[doc = " include flex payload and flex mask"] +/// A structure used to define all flexible payload related setting +/// include flex payload and flex mask #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { - #[doc = "< The number of following payload cfg"] + /// < The number of following payload cfg pub nb_payloads: u16, - #[doc = "< The number of following mask"] + /// < The number of following mask pub nb_flexmasks: u16, pub flex_set: [rte_eth_flex_payload_cfg; 8usize], pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], @@ -1579,20 +1579,20 @@ impl Default for rte_eth_fdir_flex_conf { unsafe { ::std::mem::zeroed() } } } -#[doc = " A structure used to configure the Flow Director (FDIR) feature"] -#[doc = " of an Ethernet port."] -#[doc = ""] -#[doc = " If mode is RTE_FDIR_DISABLE, the pballoc value is ignored."] +/// A structure used to configure the Flow Director (FDIR) feature +/// of an Ethernet port. +/// +/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { - #[doc = "< Flow Director mode."] + /// < Flow Director mode. pub mode: rte_fdir_mode, - #[doc = "< Space for FDIR filters."] + /// < Space for FDIR filters. pub pballoc: rte_fdir_pballoc_type, - #[doc = "< How to report FDIR hash."] + /// < How to report FDIR hash. pub status: rte_fdir_status_mode, - #[doc = " RX queue of packets matching a \"drop\" filter in perfect mode."] + /// RX queue of packets matching a "drop" filter in perfect mode. pub drop_queue: u8, pub mask: rte_eth_fdir_masks, pub flex_conf: rte_eth_fdir_flex_conf, @@ -1675,13 +1675,13 @@ impl Default for rte_fdir_conf { unsafe { ::std::mem::zeroed() } } } -#[doc = " A structure used to enable/disable specific device interrupts."] +/// A structure used to enable/disable specific device interrupts. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_intr_conf { - #[doc = " enable/disable lsc interrupt. 0 (default) - disable, 1 enable"] + /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable pub lsc: u16, - #[doc = " enable/disable rxq interrupt. 0 (default) - disable, 1 enable"] + /// enable/disable rxq interrupt. 0 (default) - disable, 1 enable pub rxq: u16, } #[test] @@ -1717,46 +1717,46 @@ fn bindgen_test_layout_rte_intr_conf() { ) ); } -#[doc = " A structure used to configure an Ethernet port."] -#[doc = " Depending upon the RX multi-queue mode, extra advanced"] -#[doc = " configuration settings may be needed."] +/// A structure used to configure an Ethernet port. +/// Depending upon the RX multi-queue mode, extra advanced +/// configuration settings may be needed. #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_conf { - #[doc = "< bitmap of ETH_LINK_SPEED_XXX of speeds to be"] - #[doc = "used. ETH_LINK_SPEED_FIXED disables link"] - #[doc = "autonegotiation, and a unique speed shall be"] - #[doc = "set. Otherwise, the bitmap defines the set of"] - #[doc = "speeds to be advertised. If the special value"] - #[doc = "ETH_LINK_SPEED_AUTONEG (0) is used, all speeds"] - #[doc = "supported are advertised."] + /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be + /// used. ETH_LINK_SPEED_FIXED disables link + /// autonegotiation, and a unique speed shall be + /// set. Otherwise, the bitmap defines the set of + /// speeds to be advertised. If the special value + /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + /// supported are advertised. pub link_speeds: u32, - #[doc = "< Port RX configuration."] + /// < Port RX configuration. pub rxmode: rte_eth_rxmode, - #[doc = "< Port TX configuration."] + /// < Port TX configuration. pub txmode: rte_eth_txmode, - #[doc = "< Loopback operation mode. By default the value"] - #[doc = "is 0, meaning the loopback mode is disabled."] - #[doc = "Read the datasheet of given ethernet controller"] - #[doc = "for details. The possible values of this field"] - #[doc = "are defined in implementation of each driver."] + /// < Loopback operation mode. By default the value + /// is 0, meaning the loopback mode is disabled. + /// Read the datasheet of given ethernet controller + /// for details. The possible values of this field + /// are defined in implementation of each driver. pub lpbk_mode: u32, - #[doc = "< Port RX filtering configuration (union)."] + /// < Port RX filtering configuration (union). pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - #[doc = "< Port TX DCB configuration (union)."] + /// < Port TX DCB configuration (union). pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, - #[doc = " Currently,Priority Flow Control(PFC) are supported,if DCB with PFC"] - #[doc = "is needed,and the variable must be set ETH_DCB_PFC_SUPPORT."] + /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC + /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. pub dcb_capability_en: u32, - #[doc = "< FDIR configuration."] + /// < FDIR configuration. pub fdir_conf: rte_fdir_conf, - #[doc = "< Interrupt mode configuration."] + /// < Interrupt mode configuration. pub intr_conf: rte_intr_conf, } #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_conf__bindgen_ty_1 { - #[doc = "< Port RSS configuration"] + /// < Port RSS configuration pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, pub dcb_rx_conf: rte_eth_dcb_rx_conf, diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs index ad86bc07..220a4f7c 100644 --- a/tests/expectations/tests/layout_eth_conf_1_0.rs +++ b/tests/expectations/tests/layout_eth_conf_1_0.rs @@ -165,36 +165,36 @@ pub const RTE_ETH_FLOW_GENEVE: u32 = 20; pub const RTE_ETH_FLOW_NVGRE: u32 = 21; pub const RTE_ETH_FLOW_MAX: u32 = 22; #[repr(u32)] -#[doc = " A set of values to identify what method is to be used to route"] -#[doc = " packets to multiple queues."] +/// A set of values to identify what method is to be used to route +/// packets to multiple queues. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_rx_mq_mode { - #[doc = " None of DCB,RSS or VMDQ mode"] + /// None of DCB,RSS or VMDQ mode ETH_MQ_RX_NONE = 0, - #[doc = " For RX side, only RSS is on"] + /// For RX side, only RSS is on ETH_MQ_RX_RSS = 1, - #[doc = " For RX side,only DCB is on."] + /// For RX side,only DCB is on. ETH_MQ_RX_DCB = 2, - #[doc = " Both DCB and RSS enable"] + /// Both DCB and RSS enable ETH_MQ_RX_DCB_RSS = 3, - #[doc = " Only VMDQ, no RSS nor DCB"] + /// Only VMDQ, no RSS nor DCB ETH_MQ_RX_VMDQ_ONLY = 4, - #[doc = " RSS mode with VMDQ"] + /// RSS mode with VMDQ ETH_MQ_RX_VMDQ_RSS = 5, - #[doc = " Use VMDQ+DCB to route traffic to queues"] + /// Use VMDQ+DCB to route traffic to queues ETH_MQ_RX_VMDQ_DCB = 6, - #[doc = " Enable both VMDQ and DCB in VMDq"] + /// Enable both VMDQ and DCB in VMDq ETH_MQ_RX_VMDQ_DCB_RSS = 7, } -#[doc = " A structure used to configure the RX features of an Ethernet port."] +/// A structure used to configure the RX features of an Ethernet port. #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rxmode { - #[doc = " The multi-queue packet distribution mode to be used, e.g. RSS."] + /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, - #[doc = "< Only used if jumbo_frame enabled."] + /// < Only used if jumbo_frame enabled. pub max_rx_pkt_len: u32, - #[doc = "< hdr buf size (header_split enabled)."] + /// < hdr buf size (header_split enabled). pub split_hdr_size: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, } @@ -405,24 +405,24 @@ impl rte_eth_rxmode { } } #[repr(u32)] -#[doc = " A set of values to identify what method is to be used to transmit"] -#[doc = " packets using multi-TCs."] +/// A set of values to identify what method is to be used to transmit +/// packets using multi-TCs. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_tx_mq_mode { - #[doc = "< It is in neither DCB nor VT mode."] + /// < It is in neither DCB nor VT mode. ETH_MQ_TX_NONE = 0, - #[doc = "< For TX side,only DCB is on."] + /// < For TX side,only DCB is on. ETH_MQ_TX_DCB = 1, - #[doc = "< For TX side,both DCB and VT is on."] + /// < For TX side,both DCB and VT is on. ETH_MQ_TX_VMDQ_DCB = 2, - #[doc = "< Only VT on, no DCB"] + /// < Only VT on, no DCB ETH_MQ_TX_VMDQ_ONLY = 3, } -#[doc = " A structure used to configure the TX features of an Ethernet port."] +/// A structure used to configure the TX features of an Ethernet port. #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { - #[doc = "< TX multi-queues mode."] + /// < TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, pub pvid: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -529,29 +529,29 @@ impl rte_eth_txmode { __bindgen_bitfield_unit } } -#[doc = " A structure used to configure the Receive Side Scaling (RSS) feature"] -#[doc = " of an Ethernet port."] -#[doc = " If not NULL, the *rss_key* pointer of the *rss_conf* structure points"] -#[doc = " to an array holding the RSS key to use for hashing specific header"] -#[doc = " fields of received packets. The length of this array should be indicated"] -#[doc = " by *rss_key_len* below. Otherwise, a default random hash key is used by"] -#[doc = " the device driver."] -#[doc = ""] -#[doc = " The *rss_key_len* field of the *rss_conf* structure indicates the length"] -#[doc = " in bytes of the array pointed by *rss_key*. To be compatible, this length"] -#[doc = " will be checked in i40e only. Others assume 40 bytes to be used as before."] -#[doc = ""] -#[doc = " The *rss_hf* field of the *rss_conf* structure indicates the different"] -#[doc = " types of IPv4/IPv6 packets to which the RSS hashing must be applied."] -#[doc = " Supplying an *rss_hf* equal to zero disables the RSS feature."] +/// A structure used to configure the Receive Side Scaling (RSS) feature +/// of an Ethernet port. +/// If not NULL, the *rss_key* pointer of the *rss_conf* structure points +/// to an array holding the RSS key to use for hashing specific header +/// fields of received packets. The length of this array should be indicated +/// by *rss_key_len* below. Otherwise, a default random hash key is used by +/// the device driver. +/// +/// The *rss_key_len* field of the *rss_conf* structure indicates the length +/// in bytes of the array pointed by *rss_key*. To be compatible, this length +/// will be checked in i40e only. Others assume 40 bytes to be used as before. +/// +/// The *rss_hf* field of the *rss_conf* structure indicates the different +/// types of IPv4/IPv6 packets to which the RSS hashing must be applied. +/// Supplying an *rss_hf* equal to zero disables the RSS feature. #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { - #[doc = "< If not NULL, 40-byte hash key."] + /// < If not NULL, 40-byte hash key. pub rss_key: *mut u8, - #[doc = "< hash key length in bytes."] + /// < hash key length in bytes. pub rss_key_len: u8, - #[doc = "< Hash functions to apply - see below."] + /// < Hash functions to apply - see below. pub rss_hf: u64, } #[test] @@ -608,59 +608,59 @@ impl Default for rte_eth_rss_conf { } } #[repr(u32)] -#[doc = " This enum indicates the possible number of traffic classes"] -#[doc = " in DCB configratioins"] +/// This enum indicates the possible number of traffic classes +/// in DCB configratioins #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { - #[doc = "< 4 TCs with DCB."] + /// < 4 TCs with DCB. ETH_4_TCS = 4, - #[doc = "< 8 TCs with DCB."] + /// < 8 TCs with DCB. ETH_8_TCS = 8, } #[repr(u32)] -#[doc = " This enum indicates the possible number of queue pools"] -#[doc = " in VMDQ configurations."] +/// This enum indicates the possible number of queue pools +/// in VMDQ configurations. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { - #[doc = "< 8 VMDq pools."] + /// < 8 VMDq pools. ETH_8_POOLS = 8, - #[doc = "< 16 VMDq pools."] + /// < 16 VMDq pools. ETH_16_POOLS = 16, - #[doc = "< 32 VMDq pools."] + /// < 32 VMDq pools. ETH_32_POOLS = 32, - #[doc = "< 64 VMDq pools."] + /// < 64 VMDq pools. ETH_64_POOLS = 64, } -#[doc = " A structure used to configure the VMDQ+DCB feature"] -#[doc = " of an Ethernet port."] -#[doc = ""] -#[doc = " Using this feature, packets are routed to a pool of queues, based"] -#[doc = " on the vlan id in the vlan tag, and then to a specific queue within"] -#[doc = " that pool, using the user priority vlan tag field."] -#[doc = ""] -#[doc = " A default pool may be used, if desired, to route all traffic which"] -#[doc = " does not match the vlan filter rules."] +/// A structure used to configure the VMDQ+DCB feature +/// of an Ethernet port. +/// +/// Using this feature, packets are routed to a pool of queues, based +/// on the vlan id in the vlan tag, and then to a specific queue within +/// that pool, using the user priority vlan tag field. +/// +/// A default pool may be used, if desired, to route all traffic which +/// does not match the vlan filter rules. #[repr(C)] #[derive(Copy)] pub struct rte_eth_vmdq_dcb_conf { - #[doc = "< With DCB, 16 or 32 pools"] + /// < With DCB, 16 or 32 pools pub nb_queue_pools: rte_eth_nb_pools, - #[doc = "< If non-zero, use a default pool"] + /// < If non-zero, use a default pool pub enable_default_pool: u8, - #[doc = "< The default pool, if applicable"] + /// < The default pool, if applicable pub default_pool: u8, - #[doc = "< We can have up to 64 filters/mappings"] + /// < We can have up to 64 filters/mappings pub nb_pool_maps: u8, - #[doc = "< VMDq vlan pool maps."] + /// < VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], pub dcb_tc: [u8; 8usize], } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - #[doc = "< The vlan id of the received frame"] + /// < The vlan id of the received frame pub vlan_id: u16, - #[doc = "< Bitmask of pools for packet rx"] + /// < Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -805,9 +805,9 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { - #[doc = "< Possible DCB TCs, 4 or 8 TCs"] + /// < Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, - #[doc = " Traffic class each UP mapped to."] + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -856,9 +856,9 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { - #[doc = "< With DCB, 16 or 32 pools."] + /// < With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, - #[doc = " Traffic class each UP mapped to."] + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -909,9 +909,9 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { - #[doc = "< Possible DCB TCs, 4 or 8 TCs."] + /// < Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, - #[doc = " Traffic class each UP mapped to."] + /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], } #[test] @@ -960,7 +960,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { - #[doc = "< VMDq mode, 64 pools."] + /// < VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -1001,27 +1001,27 @@ impl Default for rte_eth_vmdq_tx_conf { #[repr(C)] #[derive(Copy)] pub struct rte_eth_vmdq_rx_conf { - #[doc = "< VMDq only mode, 8 or 64 pools"] + /// < VMDq only mode, 8 or 64 pools pub nb_queue_pools: rte_eth_nb_pools, - #[doc = "< If non-zero, use a default pool"] + /// < If non-zero, use a default pool pub enable_default_pool: u8, - #[doc = "< The default pool, if applicable"] + /// < The default pool, if applicable pub default_pool: u8, - #[doc = "< Enable VT loop back"] + /// < Enable VT loop back pub enable_loop_back: u8, - #[doc = "< We can have up to 64 filters/mappings"] + /// < We can have up to 64 filters/mappings pub nb_pool_maps: u8, - #[doc = "< Flags from ETH_VMDQ_ACCEPT_*"] + /// < Flags from ETH_VMDQ_ACCEPT_* pub rx_mode: u32, - #[doc = "< VMDq vlan pool maps."] + /// < VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - #[doc = "< The vlan id of the received frame"] + /// < The vlan id of the received frame pub vlan_id: u16, - #[doc = "< Bitmask of pools for packet rx"] + /// < Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -1176,56 +1176,56 @@ impl Default for rte_eth_vmdq_rx_conf { } } #[repr(u32)] -#[doc = " Flow Director setting modes: none, signature or perfect."] +/// Flow Director setting modes: none, signature or perfect. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { - #[doc = "< Disable FDIR support."] + /// < Disable FDIR support. RTE_FDIR_MODE_NONE = 0, - #[doc = "< Enable FDIR signature filter mode."] + /// < Enable FDIR signature filter mode. RTE_FDIR_MODE_SIGNATURE = 1, - #[doc = "< Enable FDIR perfect filter mode."] + /// < Enable FDIR perfect filter mode. RTE_FDIR_MODE_PERFECT = 2, - #[doc = "< Enable FDIR filter mode - MAC VLAN."] + /// < Enable FDIR filter mode - MAC VLAN. RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - #[doc = "< Enable FDIR filter mode - tunnel."] + /// < Enable FDIR filter mode - tunnel. RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] -#[doc = " Memory space that can be configured to store Flow Director filters"] -#[doc = " in the board memory."] +/// Memory space that can be configured to store Flow Director filters +/// in the board memory. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { - #[doc = "< 64k."] + /// < 64k. RTE_FDIR_PBALLOC_64K = 0, - #[doc = "< 128k."] + /// < 128k. RTE_FDIR_PBALLOC_128K = 1, - #[doc = "< 256k."] + /// < 256k. RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] -#[doc = " Select report mode of FDIR hash information in RX descriptors."] +/// Select report mode of FDIR hash information in RX descriptors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { - #[doc = "< Never report FDIR hash."] + /// < Never report FDIR hash. RTE_FDIR_NO_REPORT_STATUS = 0, - #[doc = "< Only report FDIR hash for matching pkts."] + /// < Only report FDIR hash for matching pkts. RTE_FDIR_REPORT_STATUS = 1, - #[doc = "< Always report FDIR hash."] + /// < Always report FDIR hash. RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } -#[doc = " A structure used to define the input for IPV4 flow"] +/// A structure used to define the input for IPV4 flow #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { - #[doc = "< IPv4 source address in big endian."] + /// < IPv4 source address in big endian. pub src_ip: u32, - #[doc = "< IPv4 destination address in big endian."] + /// < IPv4 destination address in big endian. pub dst_ip: u32, - #[doc = "< Type of service to match."] + /// < Type of service to match. pub tos: u8, - #[doc = "< Time to live to match."] + /// < Time to live to match. pub ttl: u8, - #[doc = "< Protocol, next header in big endian."] + /// < Protocol, next header in big endian. pub proto: u8, } #[test] @@ -1296,19 +1296,19 @@ impl Clone for rte_eth_ipv4_flow { *self } } -#[doc = " A structure used to define the input for IPV6 flow"] +/// A structure used to define the input for IPV6 flow #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { - #[doc = "< IPv6 source address in big endian."] + /// < IPv6 source address in big endian. pub src_ip: [u32; 4usize], - #[doc = "< IPv6 destination address in big endian."] + /// < IPv6 destination address in big endian. pub dst_ip: [u32; 4usize], - #[doc = "< Traffic class to match."] + /// < Traffic class to match. pub tc: u8, - #[doc = "< Protocol, next header to match."] + /// < Protocol, next header to match. pub proto: u8, - #[doc = "< Hop limits to match."] + /// < Hop limits to match. pub hop_limits: u8, } #[test] @@ -1379,28 +1379,28 @@ impl Clone for rte_eth_ipv6_flow { *self } } -#[doc = " A structure used to configure FDIR masks that are used by the device"] -#[doc = " to match the various fields of RX packet headers."] +/// A structure used to configure FDIR masks that are used by the device +/// to match the various fields of RX packet headers. #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { - #[doc = "< Bit mask for vlan_tci in big endian"] + /// < Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, - #[doc = " Bit mask for ipv4 flow in big endian."] + /// Bit mask for ipv4 flow in big endian. pub ipv4_mask: rte_eth_ipv4_flow, - #[doc = " Bit maks for ipv6 flow in big endian."] + /// Bit maks for ipv6 flow in big endian. pub ipv6_mask: rte_eth_ipv6_flow, - #[doc = " Bit mask for L4 source port in big endian."] + /// Bit mask for L4 source port in big endian. pub src_port_mask: u16, - #[doc = " Bit mask for L4 destination port in big endian."] + /// Bit mask for L4 destination port in big endian. pub dst_port_mask: u16, - #[doc = " 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the"] - #[doc = "first byte on the wire"] + /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the + /// first byte on the wire pub mac_addr_byte_mask: u8, - #[doc = " Bit mask for tunnel ID in big endian."] + /// Bit mask for tunnel ID in big endian. pub tunnel_id_mask: u32, - #[doc = "< 1 - Match tunnel type,"] - #[doc = "0 - Ignore tunnel type."] + /// < 1 - Match tunnel type, + /// 0 - Ignore tunnel type. pub tunnel_type_mask: u8, } #[test] @@ -1514,7 +1514,7 @@ impl Clone for rte_eth_fdir_masks { } } #[repr(u32)] -#[doc = " Payload type"] +/// Payload type #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_payload_type { RTE_ETH_PAYLOAD_UNKNOWN = 0, @@ -1524,12 +1524,12 @@ pub enum rte_eth_payload_type { RTE_ETH_L4_PAYLOAD = 4, RTE_ETH_PAYLOAD_MAX = 8, } -#[doc = " A structure used to select bytes extracted from the protocol layers to"] -#[doc = " flexible payload for filter"] +/// A structure used to select bytes extracted from the protocol layers to +/// flexible payload for filter #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { - #[doc = "< Payload type"] + /// < Payload type pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1578,8 +1578,8 @@ impl Default for rte_eth_flex_payload_cfg { unsafe { ::std::mem::zeroed() } } } -#[doc = " A structure used to define FDIR masks for flexible payload"] -#[doc = " for each flow type"] +/// A structure used to define FDIR masks for flexible payload +/// for each flow type #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_mask { @@ -1626,14 +1626,14 @@ impl Clone for rte_eth_fdir_flex_mask { *self } } -#[doc = " A structure used to define all flexible payload related setting"] -#[doc = " include flex payload and flex mask"] +/// A structure used to define all flexible payload related setting +/// include flex payload and flex mask #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { - #[doc = "< The number of following payload cfg"] + /// < The number of following payload cfg pub nb_payloads: u16, - #[doc = "< The number of following mask"] + /// < The number of following mask pub nb_flexmasks: u16, pub flex_set: [rte_eth_flex_payload_cfg; 8usize], pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], @@ -1707,20 +1707,20 @@ impl Default for rte_eth_fdir_flex_conf { unsafe { ::std::mem::zeroed() } } } -#[doc = " A structure used to configure the Flow Director (FDIR) feature"] -#[doc = " of an Ethernet port."] -#[doc = ""] -#[doc = " If mode is RTE_FDIR_DISABLE, the pballoc value is ignored."] +/// A structure used to configure the Flow Director (FDIR) feature +/// of an Ethernet port. +/// +/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored. #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { - #[doc = "< Flow Director mode."] + /// < Flow Director mode. pub mode: rte_fdir_mode, - #[doc = "< Space for FDIR filters."] + /// < Space for FDIR filters. pub pballoc: rte_fdir_pballoc_type, - #[doc = "< How to report FDIR hash."] + /// < How to report FDIR hash. pub status: rte_fdir_status_mode, - #[doc = " RX queue of packets matching a \"drop\" filter in perfect mode."] + /// RX queue of packets matching a "drop" filter in perfect mode. pub drop_queue: u8, pub mask: rte_eth_fdir_masks, pub flex_conf: rte_eth_fdir_flex_conf, @@ -1808,13 +1808,13 @@ impl Default for rte_fdir_conf { unsafe { ::std::mem::zeroed() } } } -#[doc = " A structure used to enable/disable specific device interrupts."] +/// A structure used to enable/disable specific device interrupts. #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_intr_conf { - #[doc = " enable/disable lsc interrupt. 0 (default) - disable, 1 enable"] + /// enable/disable lsc interrupt. 0 (default) - disable, 1 enable pub lsc: u16, - #[doc = " enable/disable rxq interrupt. 0 (default) - disable, 1 enable"] + /// enable/disable rxq interrupt. 0 (default) - disable, 1 enable pub rxq: u16, } #[test] @@ -1855,46 +1855,46 @@ impl Clone for rte_intr_conf { *self } } -#[doc = " A structure used to configure an Ethernet port."] -#[doc = " Depending upon the RX multi-queue mode, extra advanced"] -#[doc = " configuration settings may be needed."] +/// A structure used to configure an Ethernet port. +/// Depending upon the RX multi-queue mode, extra advanced +/// configuration settings may be needed. #[repr(C)] #[derive(Copy)] pub struct rte_eth_conf { - #[doc = "< bitmap of ETH_LINK_SPEED_XXX of speeds to be"] - #[doc = "used. ETH_LINK_SPEED_FIXED disables link"] - #[doc = "autonegotiation, and a unique speed shall be"] - #[doc = "set. Otherwise, the bitmap defines the set of"] - #[doc = "speeds to be advertised. If the special value"] - #[doc = "ETH_LINK_SPEED_AUTONEG (0) is used, all speeds"] - #[doc = "supported are advertised."] + /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be + /// used. ETH_LINK_SPEED_FIXED disables link + /// autonegotiation, and a unique speed shall be + /// set. Otherwise, the bitmap defines the set of + /// speeds to be advertised. If the special value + /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + /// supported are advertised. pub link_speeds: u32, - #[doc = "< Port RX configuration."] + /// < Port RX configuration. pub rxmode: rte_eth_rxmode, - #[doc = "< Port TX configuration."] + /// < Port TX configuration. pub txmode: rte_eth_txmode, - #[doc = "< Loopback operation mode. By default the value"] - #[doc = "is 0, meaning the loopback mode is disabled."] - #[doc = "Read the datasheet of given ethernet controller"] - #[doc = "for details. The possible values of this field"] - #[doc = "are defined in implementation of each driver."] + /// < Loopback operation mode. By default the value + /// is 0, meaning the loopback mode is disabled. + /// Read the datasheet of given ethernet controller + /// for details. The possible values of this field + /// are defined in implementation of each driver. pub lpbk_mode: u32, - #[doc = "< Port RX filtering configuration (union)."] + /// < Port RX filtering configuration (union). pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - #[doc = "< Port TX DCB configuration (union)."] + /// < Port TX DCB configuration (union). pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, - #[doc = " Currently,Priority Flow Control(PFC) are supported,if DCB with PFC"] - #[doc = "is needed,and the variable must be set ETH_DCB_PFC_SUPPORT."] + /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC + /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. pub dcb_capability_en: u32, - #[doc = "< FDIR configuration."] + /// < FDIR configuration. pub fdir_conf: rte_fdir_conf, - #[doc = "< Interrupt mode configuration."] + /// < Interrupt mode configuration. pub intr_conf: rte_intr_conf, } #[repr(C)] #[derive(Copy)] pub struct rte_eth_conf__bindgen_ty_1 { - #[doc = "< Port RSS configuration"] + /// < Port RSS configuration pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, pub dcb_rx_conf: rte_eth_dcb_rx_conf, diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index 8d233cd4..409dad17 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -15,18 +15,18 @@ pub struct rte_kni_mbuf { pub buf_addr: *mut ::std::os::raw::c_void, pub buf_physaddr: u64, pub pad0: [::std::os::raw::c_char; 2usize], - #[doc = "< Start address of data in segment buffer."] + /// < Start address of data in segment buffer. pub data_off: u16, pub pad1: [::std::os::raw::c_char; 2usize], - #[doc = "< Number of segments."] + /// < Number of segments. pub nb_segs: u8, pub pad4: [::std::os::raw::c_char; 1usize], - #[doc = "< Offload features."] + /// < Offload features. pub ol_flags: u64, pub pad2: [::std::os::raw::c_char; 4usize], - #[doc = "< Total pkt len: sum of all segment data_len."] + /// < Total pkt len: sum of all segment data_len. pub pkt_len: u32, - #[doc = "< Amount of data in segment buffer."] + /// < Amount of data in segment buffer. pub data_len: u16, pub __bindgen_padding_0: [u8; 22usize], pub pad3: [::std::os::raw::c_char; 8usize], diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index d2f33a55..599d813d 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -53,23 +53,23 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_1 { - #[doc = "< index of last fragment"] + /// < index of last fragment IP_LAST_FRAG_IDX = 0, - #[doc = "< index of first fragment"] + /// < index of first fragment IP_FIRST_FRAG_IDX = 1, - #[doc = "< minimum number of fragments"] + /// < minimum number of fragments IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } -#[doc = " @internal fragmented mbuf"] +/// @internal fragmented mbuf #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ip_frag { - #[doc = "< offset into the packet"] + /// < offset into the packet pub ofs: u16, - #[doc = "< length of fragment"] + /// < length of fragment pub len: u16, - #[doc = "< fragment mbuf"] + /// < fragment mbuf pub mb: *mut rte_mbuf, } #[test] @@ -120,15 +120,15 @@ impl Default for ip_frag { unsafe { ::std::mem::zeroed() } } } -#[doc = " @internal to uniquely indetify fragmented datagram."] +/// @internal to uniquely indetify fragmented datagram. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ip_frag_key { - #[doc = "< src address, first 8 bytes used for IPv4"] + /// < src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], - #[doc = "< dst address"] + /// < dst address pub id: u32, - #[doc = "< src/dst key length"] + /// < src/dst key length pub key_len: u32, } #[test] @@ -174,24 +174,24 @@ fn bindgen_test_layout_ip_frag_key() { ) ); } -#[doc = " @internal Fragmented packet to reassemble."] -#[doc = " First two entries in the frags[] array are for the last and first fragments."] +/// @internal Fragmented packet to reassemble. +/// First two entries in the frags[] array are for the last and first fragments. #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_pkt { - #[doc = "< LRU list"] + /// < LRU list pub lru: ip_frag_pkt__bindgen_ty_1, - #[doc = "< fragmentation key"] + /// < fragmentation key pub key: ip_frag_key, - #[doc = "< creation timestamp"] + /// < creation timestamp pub start: u64, - #[doc = "< expected reassembled size"] + /// < expected reassembled size pub total_size: u32, - #[doc = "< size of fragments received"] + /// < size of fragments received pub frag_size: u32, - #[doc = "< index of next entry to fill"] + /// < index of next entry to fill pub last_idx: u32, - #[doc = "< fragments"] + /// < fragments pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -370,21 +370,21 @@ impl Default for ip_pkt_list { unsafe { ::std::mem::zeroed() } } } -#[doc = " fragmentation table statistics"] +/// fragmentation table statistics #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_tbl_stat { - #[doc = "< total # of find/insert attempts."] + /// < total # of find/insert attempts. pub find_num: u64, - #[doc = "< # of add ops."] + /// < # of add ops. pub add_num: u64, - #[doc = "< # of del ops."] + /// < # of del ops. pub del_num: u64, - #[doc = "< # of reuse (del/add) ops."] + /// < # of reuse (del/add) ops. pub reuse_num: u64, - #[doc = "< total # of add failures."] + /// < total # of add failures. pub fail_total: u64, - #[doc = "< # of \'no space\' add failures."] + /// < # of 'no space' add failures. pub fail_nospace: u64, pub __bindgen_padding_0: [u64; 2usize], } @@ -461,31 +461,31 @@ impl Default for ip_frag_tbl_stat { unsafe { ::std::mem::zeroed() } } } -#[doc = " fragmentation table"] +/// fragmentation table #[repr(C)] pub struct rte_ip_frag_tbl { - #[doc = "< ttl for table entries."] + /// < ttl for table entries. pub max_cycles: u64, - #[doc = "< hash value mask."] + /// < hash value mask. pub entry_mask: u32, - #[doc = "< max entries allowed."] + /// < max entries allowed. pub max_entries: u32, - #[doc = "< entries in use."] + /// < entries in use. pub use_entries: u32, - #[doc = "< hash assocaitivity."] + /// < hash assocaitivity. pub bucket_entries: u32, - #[doc = "< total size of the table."] + /// < total size of the table. pub nb_entries: u32, - #[doc = "< num of associativity lines."] + /// < num of associativity lines. pub nb_buckets: u32, - #[doc = "< last used entry."] + /// < last used entry. pub last: *mut ip_frag_pkt, - #[doc = "< LRU list for table entries."] + /// < LRU list for table entries. pub lru: ip_pkt_list, pub __bindgen_padding_0: u64, - #[doc = "< statistics counters."] + /// < statistics counters. pub stat: ip_frag_tbl_stat, - #[doc = "< hash table."] + /// < hash table. pub pkt: __IncompleteArrayField, } #[test] @@ -611,7 +611,7 @@ impl Default for rte_ip_frag_tbl { unsafe { ::std::mem::zeroed() } } } -#[doc = "< fragment mbuf"] +/// < fragment mbuf #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 78131f87..81ff60ed 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -95,11 +95,11 @@ pub type phys_addr_t = u64; pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; -#[doc = " The atomic counter structure."] +/// The atomic counter structure. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { - #[doc = "< An internal counter value."] + /// < An internal counter value. pub cnt: i16, } #[test] @@ -125,65 +125,65 @@ fn bindgen_test_layout_rte_atomic16_t() { ) ); } -#[doc = " The generic rte_mbuf, containing a packet mbuf."] +/// The generic rte_mbuf, containing a packet mbuf. #[repr(C)] pub struct rte_mbuf { pub cacheline0: MARKER, - #[doc = "< Virtual address of segment buffer."] + /// < Virtual address of segment buffer. pub buf_addr: *mut ::std::os::raw::c_void, - #[doc = "< Physical address of segment buffer."] + /// < Physical address of segment buffer. pub buf_physaddr: phys_addr_t, - #[doc = "< Length of segment buffer."] + /// < Length of segment buffer. pub buf_len: u16, pub rearm_data: MARKER8, pub data_off: u16, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - #[doc = "< Number of segments."] + /// < Number of segments. pub nb_segs: u8, - #[doc = "< Input port."] + /// < Input port. pub port: u8, - #[doc = "< Offload features."] + /// < Offload features. pub ol_flags: u64, pub rx_descriptor_fields1: MARKER, pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - #[doc = "< Total pkt len: sum of all segments."] + /// < Total pkt len: sum of all segments. pub pkt_len: u32, - #[doc = "< Amount of data in segment buffer."] + /// < Amount of data in segment buffer. pub data_len: u16, - #[doc = " VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set."] + /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. pub vlan_tci: u16, - #[doc = "< hash information"] + /// < hash information pub hash: rte_mbuf__bindgen_ty_3, - #[doc = "< Sequence number. See also rte_reorder_insert()"] + /// < Sequence number. See also rte_reorder_insert() pub seqn: u32, - #[doc = " Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set."] + /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. pub vlan_tci_outer: u16, pub cacheline1: MARKER, pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - #[doc = "< Pool from which mbuf was allocated."] + /// < Pool from which mbuf was allocated. pub pool: *mut rte_mempool, - #[doc = "< Next segment of scattered packet."] + /// < Next segment of scattered packet. pub next: *mut rte_mbuf, pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, - #[doc = " Size of the application private data. In case of an indirect"] - #[doc = " mbuf, it stores the direct mbuf private data size."] + /// Size of the application private data. In case of an indirect + /// mbuf, it stores the direct mbuf private data size. pub priv_size: u16, - #[doc = " Timesync flags for use with IEEE1588."] + /// Timesync flags for use with IEEE1588. pub timesync: u16, pub __bindgen_padding_0: [u32; 7usize], } -#[doc = " 16-bit Reference counter."] -#[doc = " It should only be accessed using the following functions:"] -#[doc = " rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and"] -#[doc = " rte_mbuf_refcnt_set(). The functionality of these functions (atomic,"] -#[doc = " or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC"] -#[doc = " config option."] +/// 16-bit Reference counter. +/// It should only be accessed using the following functions: +/// rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and +/// rte_mbuf_refcnt_set(). The functionality of these functions (atomic, +/// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC +/// config option. #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_1 { - #[doc = "< Atomically accessed refcnt"] + /// < Atomically accessed refcnt pub refcnt_atomic: rte_atomic16_t, - #[doc = "< Non-atomically accessed refcnt"] + /// < Non-atomically accessed refcnt pub refcnt: u16, _bindgen_union_align: u16, } @@ -230,7 +230,7 @@ impl Default for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_2 { - #[doc = "< L2/L3/L4 and tunnel information."] + /// < L2/L3/L4 and tunnel information. pub packet_type: u32, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_2__bindgen_ty_1, _bindgen_union_align: u32, @@ -414,13 +414,13 @@ impl Default for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3 { - #[doc = "< RSS hash result if RSS enabled"] + /// < RSS hash result if RSS enabled pub rss: u32, - #[doc = "< Filter identifier if FDIR enabled"] + /// < Filter identifier if FDIR enabled pub fdir: rte_mbuf__bindgen_ty_3__bindgen_ty_1, - #[doc = "< Hierarchical scheduler"] + /// < Hierarchical scheduler pub sched: rte_mbuf__bindgen_ty_3__bindgen_ty_2, - #[doc = "< User defined tags. See rte_distributor_process()"] + /// < User defined tags. See rte_distributor_process() pub usr: u32, _bindgen_union_align: [u32; 2usize], } @@ -669,9 +669,9 @@ impl Default for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_4 { - #[doc = "< Can be used for external metadata"] + /// < Can be used for external metadata pub userdata: *mut ::std::os::raw::c_void, - #[doc = "< Allow 8-byte userdata on 32-bit"] + /// < Allow 8-byte userdata on 32-bit pub udata64: u64, _bindgen_union_align: u64, } @@ -716,7 +716,7 @@ impl Default for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_5 { - #[doc = "< combined for easy fetch"] + /// < combined for easy fetch pub tx_offload: u64, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_5__bindgen_ty_1, _bindgen_union_align: u64, @@ -1104,7 +1104,7 @@ impl Default for rte_mbuf { unsafe { ::std::mem::zeroed() } } } -#[doc = "< Pool from which mbuf was allocated."] +/// < Pool from which mbuf was allocated. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mempool { diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs index ab5126cb..f6a9eaa0 100644 --- a/tests/expectations/tests/layout_mbuf_1_0.rs +++ b/tests/expectations/tests/layout_mbuf_1_0.rs @@ -138,11 +138,11 @@ pub type phys_addr_t = u64; pub type MARKER = [*mut ::std::os::raw::c_void; 0usize]; pub type MARKER8 = [u8; 0usize]; pub type MARKER64 = [u64; 0usize]; -#[doc = " The atomic counter structure."] +/// The atomic counter structure. #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { - #[doc = "< An internal counter value."] + /// < An internal counter value. pub cnt: i16, } #[test] @@ -173,65 +173,65 @@ impl Clone for rte_atomic16_t { *self } } -#[doc = " The generic rte_mbuf, containing a packet mbuf."] +/// The generic rte_mbuf, containing a packet mbuf. #[repr(C)] pub struct rte_mbuf { pub cacheline0: MARKER, - #[doc = "< Virtual address of segment buffer."] + /// < Virtual address of segment buffer. pub buf_addr: *mut ::std::os::raw::c_void, - #[doc = "< Physical address of segment buffer."] + /// < Physical address of segment buffer. pub buf_physaddr: phys_addr_t, - #[doc = "< Length of segment buffer."] + /// < Length of segment buffer. pub buf_len: u16, pub rearm_data: MARKER8, pub data_off: u16, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - #[doc = "< Number of segments."] + /// < Number of segments. pub nb_segs: u8, - #[doc = "< Input port."] + /// < Input port. pub port: u8, - #[doc = "< Offload features."] + /// < Offload features. pub ol_flags: u64, pub rx_descriptor_fields1: MARKER, pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - #[doc = "< Total pkt len: sum of all segments."] + /// < Total pkt len: sum of all segments. pub pkt_len: u32, - #[doc = "< Amount of data in segment buffer."] + /// < Amount of data in segment buffer. pub data_len: u16, - #[doc = " VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set."] + /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. pub vlan_tci: u16, - #[doc = "< hash information"] + /// < hash information pub hash: rte_mbuf__bindgen_ty_3, - #[doc = "< Sequence number. See also rte_reorder_insert()"] + /// < Sequence number. See also rte_reorder_insert() pub seqn: u32, - #[doc = " Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set."] + /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. pub vlan_tci_outer: u16, pub cacheline1: MARKER, pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - #[doc = "< Pool from which mbuf was allocated."] + /// < Pool from which mbuf was allocated. pub pool: *mut rte_mempool, - #[doc = "< Next segment of scattered packet."] + /// < Next segment of scattered packet. pub next: *mut rte_mbuf, pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, - #[doc = " Size of the application private data. In case of an indirect"] - #[doc = " mbuf, it stores the direct mbuf private data size."] + /// Size of the application private data. In case of an indirect + /// mbuf, it stores the direct mbuf private data size. pub priv_size: u16, - #[doc = " Timesync flags for use with IEEE1588."] + /// Timesync flags for use with IEEE1588. pub timesync: u16, pub __bindgen_padding_0: [u32; 7usize], } -#[doc = " 16-bit Reference counter."] -#[doc = " It should only be accessed using the following functions:"] -#[doc = " rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and"] -#[doc = " rte_mbuf_refcnt_set(). The functionality of these functions (atomic,"] -#[doc = " or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC"] -#[doc = " config option."] +/// 16-bit Reference counter. +/// It should only be accessed using the following functions: +/// rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and +/// rte_mbuf_refcnt_set(). The functionality of these functions (atomic, +/// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC +/// config option. #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_1 { - #[doc = "< Atomically accessed refcnt"] + /// < Atomically accessed refcnt pub refcnt_atomic: __BindgenUnionField, - #[doc = "< Non-atomically accessed refcnt"] + /// < Non-atomically accessed refcnt pub refcnt: __BindgenUnionField, pub bindgen_union_field: u16, } @@ -278,7 +278,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2 { - #[doc = "< L2/L3/L4 and tunnel information."] + /// < L2/L3/L4 and tunnel information. pub packet_type: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, @@ -467,13 +467,13 @@ impl Clone for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3 { - #[doc = "< RSS hash result if RSS enabled"] + /// < RSS hash result if RSS enabled pub rss: __BindgenUnionField, - #[doc = "< Filter identifier if FDIR enabled"] + /// < Filter identifier if FDIR enabled pub fdir: __BindgenUnionField, - #[doc = "< Hierarchical scheduler"] + /// < Hierarchical scheduler pub sched: __BindgenUnionField, - #[doc = "< User defined tags. See rte_distributor_process()"] + /// < User defined tags. See rte_distributor_process() pub usr: __BindgenUnionField, pub bindgen_union_field: [u32; 2usize], } @@ -733,9 +733,9 @@ impl Clone for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_4 { - #[doc = "< Can be used for external metadata"] + /// < Can be used for external metadata pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, - #[doc = "< Allow 8-byte userdata on 32-bit"] + /// < Allow 8-byte userdata on 32-bit pub udata64: __BindgenUnionField, pub bindgen_union_field: u64, } @@ -780,7 +780,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5 { - #[doc = "< combined for easy fetch"] + /// < combined for easy fetch pub tx_offload: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u64, @@ -1173,7 +1173,7 @@ impl Default for rte_mbuf { unsafe { ::std::mem::zeroed() } } } -#[doc = "< Pool from which mbuf was allocated."] +/// < Pool from which mbuf was allocated. #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mempool { diff --git a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs index 9c972a18..a0d9ade6 100644 --- a/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs @@ -32,5 +32,5 @@ fn bindgen_test_layout_Rooted() { ) ); } -#[doc = "
"] +///
pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs index 9c972a18..a0d9ade6 100644 --- a/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs @@ -32,5 +32,5 @@ fn bindgen_test_layout_Rooted() { ) ); } -#[doc = "
"] +///
pub type MaybeWrapped
= a; diff --git a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs index bd10e1b3..a09323a8 100644 --- a/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-4/type_alias_template_specialized.rs @@ -37,7 +37,7 @@ impl Default for Rooted { unsafe { ::std::mem::zeroed() } } } -#[doc = "
"] +///
pub type MaybeWrapped
= a; #[test] fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { diff --git a/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs b/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs index 851dc4e1..89e37fe8 100644 --- a/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs +++ b/tests/expectations/tests/libclang-5/type_alias_template_specialized.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -35,7 +40,7 @@ impl Default for Rooted { unsafe { ::std::mem::zeroed() } } } -#[doc = "
"] +///
pub type MaybeWrapped
= a; #[test] fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() { diff --git a/tests/expectations/tests/no-derive-debug.rs b/tests/expectations/tests/no-derive-debug.rs index e353fa5f..f5e724d0 100644 --- a/tests/expectations/tests/no-derive-debug.rs +++ b/tests/expectations/tests/no-derive-debug.rs @@ -13,9 +13,9 @@ pub struct foo { bar: ::std::os::raw::c_int, } -#[doc = " bar should compile. It will normally derive debug, but our blacklist of foo"] -#[doc = " and replacement for another type that doesn\'t implement it would prevent it"] -#[doc = " from building if --no-derive-debug didn\'t work."] +/// bar should compile. It will normally derive debug, but our blacklist of foo +/// and replacement for another type that doesn't implement it would prevent it +/// from building if --no-derive-debug didn't work. #[repr(C)] pub struct bar { pub foo: foo, diff --git a/tests/expectations/tests/no-derive-default.rs b/tests/expectations/tests/no-derive-default.rs index 9e14693f..cbf46c74 100644 --- a/tests/expectations/tests/no-derive-default.rs +++ b/tests/expectations/tests/no-derive-default.rs @@ -13,9 +13,9 @@ pub struct foo { bar: ::std::os::raw::c_int, } -#[doc = " bar should compile. It will normally derive default, but our blacklist of foo"] -#[doc = " and replacement for another type that doesn\'t implement it would prevent it"] -#[doc = " from building if --no-derive-default didn\'t work."] +/// bar should compile. It will normally derive default, but our blacklist of foo +/// and replacement for another type that doesn't implement it would prevent it +/// from building if --no-derive-default didn't work. #[repr(C)] pub struct bar { pub foo: foo, diff --git a/tests/expectations/tests/no_copy.rs b/tests/expectations/tests/no_copy.rs index 96fd542c..a61b457e 100644 --- a/tests/expectations/tests/no_copy.rs +++ b/tests/expectations/tests/no_copy.rs @@ -1,8 +1,13 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default)] pub struct CopiableButWait { diff --git a/tests/expectations/tests/opaque-template-inst-member-2.rs b/tests/expectations/tests/opaque-template-inst-member-2.rs index 0245a1ae..b5afc667 100644 --- a/tests/expectations/tests/opaque-template-inst-member-2.rs +++ b/tests/expectations/tests/opaque-template-inst-member-2.rs @@ -7,14 +7,14 @@ non_upper_case_globals )] -#[doc = " This is like `opaque-template-inst-member.hpp` except exercising the cases"] -#[doc = " where we are OK to derive Debug/Hash/PartialEq."] +/// This is like `opaque-template-inst-member.hpp` except exercising the cases +/// where we are OK to derive Debug/Hash/PartialEq. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OpaqueTemplate { pub _address: u8, } -#[doc = " Should derive Debug/Hash/PartialEq."] +/// Should derive Debug/Hash/PartialEq. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ContainsOpaqueTemplate { @@ -54,7 +54,7 @@ fn bindgen_test_layout_ContainsOpaqueTemplate() { ) ); } -#[doc = " Should also derive Debug/Hash/PartialEq."] +/// Should also derive Debug/Hash/PartialEq. #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct InheritsOpaqueTemplate { diff --git a/tests/expectations/tests/opaque-template-inst-member.rs b/tests/expectations/tests/opaque-template-inst-member.rs index 4c5af91f..87e98daf 100644 --- a/tests/expectations/tests/opaque-template-inst-member.rs +++ b/tests/expectations/tests/opaque-template-inst-member.rs @@ -12,8 +12,8 @@ pub struct OpaqueTemplate { pub _address: u8, } -#[doc = " This should not end up deriving Debug/Hash because its `mBlah` field cannot derive"] -#[doc = " Debug/Hash because the instantiation\'s definition cannot derive Debug/Hash."] +/// This should not end up deriving Debug/Hash because its `mBlah` field cannot derive +/// Debug/Hash because the instantiation's definition cannot derive Debug/Hash. #[repr(C)] pub struct ContainsOpaqueTemplate { pub mBlah: [u32; 101usize], @@ -62,8 +62,8 @@ impl ::std::cmp::PartialEq for ContainsOpaqueTemplate { &self.mBlah[..] == &other.mBlah[..] && self.mBaz == other.mBaz } } -#[doc = " This should not end up deriving Debug/Hash either, for similar reasons, although"] -#[doc = " we\'re exercising base member edges now."] +/// This should not end up deriving Debug/Hash either, for similar reasons, although +/// we're exercising base member edges now. #[repr(C)] pub struct InheritsOpaqueTemplate { pub _base: [u8; 401usize], diff --git a/tests/expectations/tests/opaque_in_struct.rs b/tests/expectations/tests/opaque_in_struct.rs index 650edf68..590c5fdc 100644 --- a/tests/expectations/tests/opaque_in_struct.rs +++ b/tests/expectations/tests/opaque_in_struct.rs @@ -1,8 +1,13 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct opaque { diff --git a/tests/expectations/tests/opaque_pointer.rs b/tests/expectations/tests/opaque_pointer.rs index 9dbce043..c44a2440 100644 --- a/tests/expectations/tests/opaque_pointer.rs +++ b/tests/expectations/tests/opaque_pointer.rs @@ -1,8 +1,13 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct OtherOpaque { @@ -21,7 +26,7 @@ fn bindgen_test_layout_OtherOpaque() { concat!("Alignment of ", stringify!(OtherOpaque)) ); } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { diff --git a/tests/expectations/tests/opaque_typedef.rs b/tests/expectations/tests/opaque_typedef.rs index 3f9defd3..75b79f20 100644 --- a/tests/expectations/tests/opaque_typedef.rs +++ b/tests/expectations/tests/opaque_typedef.rs @@ -1,12 +1,17 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct RandomTemplate { pub _address: u8, } -#[doc = "
"] +///
pub type ShouldBeOpaque = u8; pub type ShouldNotBeOpaque = RandomTemplate; diff --git a/tests/expectations/tests/private.rs b/tests/expectations/tests/private.rs index 3329067c..5088d9c9 100644 --- a/tests/expectations/tests/private.rs +++ b/tests/expectations/tests/private.rs @@ -1,12 +1,17 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct HasPrivate { pub mNotPrivate: ::std::os::raw::c_int, - #[doc = "
"] + ///
mIsPrivate: ::std::os::raw::c_int, } #[test] @@ -42,7 +47,7 @@ fn bindgen_test_layout_HasPrivate() { ) ); } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct VeryPrivate { @@ -82,11 +87,11 @@ fn bindgen_test_layout_VeryPrivate() { ) ); } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ContradictPrivate { - #[doc = "
"] + ///
pub mNotPrivate: ::std::os::raw::c_int, mIsPrivate: ::std::os::raw::c_int, } diff --git a/tests/expectations/tests/reparented_replacement.rs b/tests/expectations/tests/reparented_replacement.rs index 374f2d4b..8fc38cd7 100644 --- a/tests/expectations/tests/reparented_replacement.rs +++ b/tests/expectations/tests/reparented_replacement.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] pub mod root { @@ -9,7 +14,7 @@ pub mod root { pub mod foo { #[allow(unused_imports)] use self::super::super::root; - #[doc = "
"] + ///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct Bar { diff --git a/tests/expectations/tests/replace_template_alias.rs b/tests/expectations/tests/replace_template_alias.rs index c82e8b6d..853ec092 100644 --- a/tests/expectations/tests/replace_template_alias.rs +++ b/tests/expectations/tests/replace_template_alias.rs @@ -7,9 +7,9 @@ non_upper_case_globals )] -#[doc = " But the replacement type does use T!"] -#[doc = ""] -#[doc = "
"] +/// But the replacement type does use T! +/// +///
pub type JS_detail_MaybeWrapped = T; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/tests/expectations/tests/replace_use.rs b/tests/expectations/tests/replace_use.rs index c188c27e..d8223031 100644 --- a/tests/expectations/tests/replace_use.rs +++ b/tests/expectations/tests/replace_use.rs @@ -1,8 +1,13 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct nsTArray { diff --git a/tests/expectations/tests/replaces_double.rs b/tests/expectations/tests/replaces_double.rs index 381e17e7..dae55a13 100644 --- a/tests/expectations/tests/replaces_double.rs +++ b/tests/expectations/tests/replaces_double.rs @@ -1,6 +1,11 @@ /* automatically generated by rust-bindgen */ -#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20,7 +25,7 @@ pub struct Rooted { pub ptr: Rooted_MaybeWrapped, pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, } -#[doc = "
"] +///
pub type Rooted_MaybeWrapped = T; impl Default for Rooted { fn default() -> Self { diff --git a/tests/expectations/tests/template.rs b/tests/expectations/tests/template.rs index a3d7122c..c0152972 100644 --- a/tests/expectations/tests/template.rs +++ b/tests/expectations/tests/template.rs @@ -331,7 +331,7 @@ impl Default for PODButContainsDtor { unsafe { ::std::mem::zeroed() } } } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct Opaque { @@ -365,7 +365,7 @@ fn bindgen_test_layout_POD() { ) ); } -#[doc = "
"] +///
#[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct NestedReplaced { @@ -435,10 +435,10 @@ fn bindgen_test_layout_Untemplated() { pub struct Templated { pub m_untemplated: Untemplated, } -#[doc = " If the replacement doesn\'t happen at the parse level the container would be"] -#[doc = " copy and the replacement wouldn\'t, so this wouldn\'t compile."] -#[doc = ""] -#[doc = "
"] +/// If the replacement doesn't happen at the parse level the container would be +/// copy and the replacement wouldn't, so this wouldn't compile. +/// +///
#[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct ReplacedWithoutDestructor { @@ -472,10 +472,10 @@ impl Default for ShouldNotBeCopiableAsWell { unsafe { ::std::mem::zeroed() } } } -#[doc = " If the replacement doesn\'t happen at the parse level the container would be"] -#[doc = " copy and the replacement wouldn\'t, so this wouldn\'t compile."] -#[doc = ""] -#[doc = "
"] +/// If the replacement doesn't happen at the parse level the container would be +/// copy and the replacement wouldn't, so this wouldn't compile. +/// +///
#[repr(C)] #[derive(Debug, Hash, PartialEq, Eq)] pub struct ReplacedWithoutDestructorFwd { diff --git a/tests/expectations/tests/templatized-bitfield.rs b/tests/expectations/tests/templatized-bitfield.rs index 239cc9a0..15785116 100644 --- a/tests/expectations/tests/templatized-bitfield.rs +++ b/tests/expectations/tests/templatized-bitfield.rs @@ -7,9 +7,9 @@ non_upper_case_globals )] -#[doc = " We don\'t get a layout for this bitfield, since we don\'t know what `T` will"] -#[doc = " be, so we cannot allocate bitfield units. The best thing we can do is make"] -#[doc = " the struct opaque."] +/// We don't get a layout for this bitfield, since we don't know what `T` will +/// be, so we cannot allocate bitfield units. The best thing we can do is make +/// the struct opaque. #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct TemplatizedBitfield { diff --git a/tests/expectations/tests/zero-sized-array.rs b/tests/expectations/tests/zero-sized-array.rs index 04788c0b..4464bb4b 100644 --- a/tests/expectations/tests/zero-sized-array.rs +++ b/tests/expectations/tests/zero-sized-array.rs @@ -44,7 +44,7 @@ impl ::std::clone::Clone for __IncompleteArrayField { } } impl ::std::marker::Copy for __IncompleteArrayField {} -#[doc = " Bizarrely enough, this should *not* get an `_address` field."] +/// Bizarrely enough, this should *not* get an `_address` field. #[repr(C)] #[derive(Debug, Default)] pub struct ZeroSizedArray { @@ -73,7 +73,7 @@ fn bindgen_test_layout_ZeroSizedArray() { ) ); } -#[doc = " And nor should this get an `_address` field."] +/// And nor should this get an `_address` field. #[repr(C)] #[derive(Debug, Default)] pub struct ContainsZeroSizedArray { @@ -102,8 +102,8 @@ fn bindgen_test_layout_ContainsZeroSizedArray() { ) ); } -#[doc = " Inheriting from ZeroSizedArray shouldn\'t cause an `_address` to be inserted"] -#[doc = " either."] +/// Inheriting from ZeroSizedArray shouldn't cause an `_address` to be inserted +/// either. #[repr(C)] #[derive(Debug, Default)] pub struct InheritsZeroSizedArray { @@ -122,7 +122,7 @@ fn bindgen_test_layout_InheritsZeroSizedArray() { concat!("Alignment of ", stringify!(InheritsZeroSizedArray)) ); } -#[doc = " And this should not get an `_address` field either."] +/// And this should not get an `_address` field either. #[repr(C, packed)] #[derive(Debug, Default)] pub struct DynamicallySizedArray { @@ -141,7 +141,7 @@ fn bindgen_test_layout_DynamicallySizedArray() { concat!("Alignment of ", stringify!(DynamicallySizedArray)) ); } -#[doc = " No `_address` field here either."] +/// No `_address` field here either. #[repr(C)] #[derive(Debug, Default)] pub struct ContainsDynamicallySizedArray { diff --git a/tests/rustfmt.toml b/tests/rustfmt.toml index 80a6663b..e8bb3d9a 100644 --- a/tests/rustfmt.toml +++ b/tests/rustfmt.toml @@ -1 +1 @@ -# Intentionally left blank. +normalize_doc_attributes = true -- cgit v1.2.3 From 70298c2dd13bb207b195c72e1f0212592c7807ed Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Fri, 30 Nov 2018 06:33:10 +0100 Subject: Remove the hack now that rustfmt-nightly properly preserves the comments. --- src/ir/comment.rs | 25 +-- tests/expectations/tests/constify-enum.rs | 2 +- .../tests/convert-cpp-comment-to-rust.rs | 6 +- tests/expectations/tests/enum-doc-bitfield.rs | 4 +- tests/expectations/tests/enum-doc-mod.rs | 4 +- tests/expectations/tests/enum-doc-rusty.rs | 4 +- tests/expectations/tests/enum-doc.rs | 4 +- tests/expectations/tests/layout_align.rs | 12 +- tests/expectations/tests/layout_arp.rs | 10 +- tests/expectations/tests/layout_array.rs | 18 +-- tests/expectations/tests/layout_array_too_long.rs | 34 ++-- tests/expectations/tests/layout_eth_conf.rs | 174 ++++++++++----------- tests/expectations/tests/layout_eth_conf_1_0.rs | 174 ++++++++++----------- tests/expectations/tests/layout_kni_mbuf.rs | 10 +- .../expectations/tests/layout_large_align_field.rs | 68 ++++---- tests/expectations/tests/layout_mbuf.rs | 48 +++--- tests/expectations/tests/layout_mbuf_1_0.rs | 48 +++--- 17 files changed, 316 insertions(+), 329 deletions(-) diff --git a/src/ir/comment.rs b/src/ir/comment.rs index 446e10b4..1a76542c 100644 --- a/src/ir/comment.rs +++ b/src/ir/comment.rs @@ -38,19 +38,6 @@ fn make_indent(indent: usize) -> String { iter::repeat(' ').take(indent * RUST_INDENTATION).collect() } -/// For a comment like `/// foo`, proc_macro2 will turn it into -/// `#[doc = " foo"]`, and rustfmt into `/// foo`, so prevent this by removing -/// the first space of the comment if present. -/// -/// This is a bit hacky. -fn format_line(line: &str) -> &str { - if line.starts_with(" ") { - &line[1..] - } else { - line - } -} - /// Preprocesses multiple single line comments. /// /// Handles lines starting with both `//` and `///`. @@ -65,7 +52,7 @@ fn preprocess_single_lines(comment: &str, indent: usize) -> String { .map(|l| { let indent = if is_first { "" } else { &*indent }; is_first = false; - format!("{}///{}", indent, format_line(l)) + format!("{}///{}", indent, l) }) .collect(); lines.join("\n") @@ -86,7 +73,7 @@ fn preprocess_multi_line(comment: &str, indent: usize) -> String { .map(|line| { let indent = if is_first { "" } else { &*indent }; is_first = false; - format!("{}///{}", indent, format_line(line)) + format!("{}///{}", indent, line) }) .collect(); @@ -110,16 +97,16 @@ mod test { #[test] fn processes_single_lines_correctly() { - assert_eq!(preprocess("/// hello", 0), "///hello"); - assert_eq!(preprocess("// hello", 0), "///hello"); - assert_eq!(preprocess("// hello", 0), "/// hello"); + assert_eq!(preprocess("/// hello", 0), "/// hello"); + assert_eq!(preprocess("// hello", 0), "/// hello"); + assert_eq!(preprocess("// hello", 0), "/// hello"); } #[test] fn processes_multi_lines_correctly() { assert_eq!( preprocess("/** hello \n * world \n * foo \n */", 0), - "///hello\n///world\n///foo" + "/// hello\n/// world\n/// foo" ); assert_eq!( diff --git a/tests/expectations/tests/constify-enum.rs b/tests/expectations/tests/constify-enum.rs index a1744a2a..f1dc139c 100644 --- a/tests/expectations/tests/constify-enum.rs +++ b/tests/expectations/tests/constify-enum.rs @@ -19,6 +19,6 @@ pub enum nsCSSPropertyID { eCSSProperty_b = 1, eCSSPropertyAlias_aa = 2, eCSSPropertyAlias_bb = 3, - /// <
+ ///<
eCSSProperty_COUNT_unexistingVariantValue = 4, } diff --git a/tests/expectations/tests/convert-cpp-comment-to-rust.rs b/tests/expectations/tests/convert-cpp-comment-to-rust.rs index dfc3104b..8058af10 100644 --- a/tests/expectations/tests/convert-cpp-comment-to-rust.rs +++ b/tests/expectations/tests/convert-cpp-comment-to-rust.rs @@ -12,11 +12,11 @@ pub type mbedtls_mpi_uint = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct mbedtls_mpi { - /// < integer sign + ///< integer sign pub s: ::std::os::raw::c_int, - /// < total # of limbs + ///< total # of limbs pub n: ::std::os::raw::c_ulong, - /// < pointer to limbs + ///< pointer to limbs pub p: *mut mbedtls_mpi_uint, } #[test] diff --git a/tests/expectations/tests/enum-doc-bitfield.rs b/tests/expectations/tests/enum-doc-bitfield.rs index caa604e4..9ebfc10e 100644 --- a/tests/expectations/tests/enum-doc-bitfield.rs +++ b/tests/expectations/tests/enum-doc-bitfield.rs @@ -20,11 +20,11 @@ impl B { pub const VAR_C: B = B(2); } impl B { - /// < Document field with following star + ///< Document field with following star pub const VAR_D: B = B(3); } impl B { - /// < Document field with following exclamation + ///< Document field with following exclamation pub const VAR_E: B = B(4); } impl B { diff --git a/tests/expectations/tests/enum-doc-mod.rs b/tests/expectations/tests/enum-doc-mod.rs index 18b27c80..1da02f41 100644 --- a/tests/expectations/tests/enum-doc-mod.rs +++ b/tests/expectations/tests/enum-doc-mod.rs @@ -16,9 +16,9 @@ pub mod B { pub const VAR_B: Type = 1; /// Document field with preceeding exclamation pub const VAR_C: Type = 2; - /// < Document field with following star + ///< Document field with following star pub const VAR_D: Type = 3; - /// < Document field with following exclamation + ///< Document field with following exclamation pub const VAR_E: Type = 4; /// Document field with preceeding star, with a loong long multiline /// comment. diff --git a/tests/expectations/tests/enum-doc-rusty.rs b/tests/expectations/tests/enum-doc-rusty.rs index a154f103..e4209e3e 100644 --- a/tests/expectations/tests/enum-doc-rusty.rs +++ b/tests/expectations/tests/enum-doc-rusty.rs @@ -17,9 +17,9 @@ pub enum B { VAR_B = 1, /// Document field with preceeding exclamation VAR_C = 2, - /// < Document field with following star + ///< Document field with following star VAR_D = 3, - /// < Document field with following exclamation + ///< Document field with following exclamation VAR_E = 4, /// Document field with preceeding star, with a loong long multiline /// comment. diff --git a/tests/expectations/tests/enum-doc.rs b/tests/expectations/tests/enum-doc.rs index 9cde2974..0df3a5a5 100644 --- a/tests/expectations/tests/enum-doc.rs +++ b/tests/expectations/tests/enum-doc.rs @@ -13,9 +13,9 @@ pub const B_VAR_A: B = 0; pub const B_VAR_B: B = 1; /// Document field with preceeding exclamation pub const B_VAR_C: B = 2; -/// < Document field with following star +///< Document field with following star pub const B_VAR_D: B = 3; -/// < Document field with following exclamation +///< Document field with following exclamation pub const B_VAR_E: B = 4; /// Document field with preceeding star, with a loong long multiline /// comment. diff --git a/tests/expectations/tests/layout_align.rs b/tests/expectations/tests/layout_align.rs index b994080b..a1350b14 100644 --- a/tests/expectations/tests/layout_align.rs +++ b/tests/expectations/tests/layout_align.rs @@ -129,15 +129,15 @@ impl ::std::marker::Copy for __IncompleteArrayField {} #[repr(C)] #[derive(Debug)] pub struct rte_kni_fifo { - /// < Next position to be written + ///< Next position to be written pub write: ::std::os::raw::c_uint, - /// < Next position to be read + ///< Next position to be read pub read: ::std::os::raw::c_uint, - /// < Circular buffer length + ///< Circular buffer length pub len: ::std::os::raw::c_uint, - /// < Pointer size - for 32/64 bit OS + ///< Pointer size - for 32/64 bit OS pub elem_size: ::std::os::raw::c_uint, - /// < The buffer contains mbuf pointers + ///< The buffer contains mbuf pointers pub buffer: __IncompleteArrayField<*mut ::std::os::raw::c_void>, pub __bindgen_align: [u64; 0usize], } @@ -162,7 +162,7 @@ impl Default for rte_kni_fifo { #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct rte_eth_link { - /// < ETH_SPEED_NUM_ + ///< ETH_SPEED_NUM_ pub link_speed: u32, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, pub __bindgen_padding_0: [u8; 3usize], diff --git a/tests/expectations/tests/layout_arp.rs b/tests/expectations/tests/layout_arp.rs index ad1762c0..28dfd53c 100644 --- a/tests/expectations/tests/layout_arp.rs +++ b/tests/expectations/tests/layout_arp.rs @@ -27,7 +27,7 @@ pub const ARP_OP_INVREPLY: u32 = 9; #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct ether_addr { - /// < Addr bytes in tx order + ///< Addr bytes in tx order pub addr_bytes: [u8; 6usize], } #[test] @@ -57,13 +57,13 @@ fn bindgen_test_layout_ether_addr() { #[repr(C, packed)] #[derive(Debug, Default, Copy, Clone)] pub struct arp_ipv4 { - /// < sender hardware address + ///< sender hardware address pub arp_sha: ether_addr, - /// < sender IP address + ///< sender IP address pub arp_sip: u32, - /// < target hardware address + ///< target hardware address pub arp_tha: ether_addr, - /// < target IP address + ///< target IP address pub arp_tip: u32, } #[test] diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs index db57e420..2fd93c4a 100644 --- a/tests/expectations/tests/layout_array.rs +++ b/tests/expectations/tests/layout_array.rs @@ -51,17 +51,17 @@ pub type rte_mempool_get_count = #[repr(C)] #[derive(Copy, Clone)] pub struct rte_mempool_ops { - /// < Name of mempool ops struct. + ///< Name of mempool ops struct. pub name: [::std::os::raw::c_char; 32usize], - /// < Allocate private data. + ///< Allocate private data. pub alloc: rte_mempool_alloc_t, - /// < Free the external pool. + ///< Free the external pool. pub free: rte_mempool_free_t, - /// < Enqueue an object. + ///< Enqueue an object. pub enqueue: rte_mempool_enqueue_t, - /// < Dequeue an object. + ///< Dequeue an object. pub dequeue: rte_mempool_dequeue_t, - /// < Get qty of available objs. + ///< Get qty of available objs. pub get_count: rte_mempool_get_count, pub __bindgen_padding_0: [u64; 7usize], } @@ -152,7 +152,7 @@ impl ::std::cmp::PartialEq for rte_mempool_ops { #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_spinlock_t { - /// < lock status 0 = unlocked, 1 = locked + ///< lock status 0 = unlocked, 1 = locked pub locked: ::std::os::raw::c_int, } #[test] @@ -188,9 +188,9 @@ fn bindgen_test_layout_rte_spinlock_t() { #[repr(C)] #[derive(Copy, Clone)] pub struct rte_mempool_ops_table { - /// < Spinlock for add/delete. + ///< Spinlock for add/delete. pub sl: rte_spinlock_t, - /// < Number of used ops structs in the table. + ///< Number of used ops structs in the table. pub num_ops: u32, pub __bindgen_padding_0: [u64; 7usize], /// Storage for all possible ops structs. diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs index f6a497f2..91c74d4b 100644 --- a/tests/expectations/tests/layout_array_too_long.rs +++ b/tests/expectations/tests/layout_array_too_long.rs @@ -16,11 +16,11 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_1 { - /// < index of last fragment + ///< index of last fragment IP_LAST_FRAG_IDX = 0, - /// < index of first fragment + ///< index of first fragment IP_FIRST_FRAG_IDX = 1, - /// < minimum number of fragments + ///< minimum number of fragments IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } @@ -28,11 +28,11 @@ pub enum _bindgen_ty_1 { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag { - /// < offset into the packet + ///< offset into the packet pub ofs: u16, - /// < length of fragment + ///< length of fragment pub len: u16, - /// < fragment mbuf + ///< fragment mbuf pub mb: *mut rte_mbuf, } #[test] @@ -87,11 +87,11 @@ impl Default for ip_frag { #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct ip_frag_key { - /// < src address, first 8 bytes used for IPv4 + ///< src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], - /// < dst address + ///< dst address pub id: u32, - /// < src/dst key length + ///< src/dst key length pub key_len: u32, } #[test] @@ -142,19 +142,19 @@ fn bindgen_test_layout_ip_frag_key() { #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_pkt { - /// < LRU list + ///< LRU list pub lru: ip_frag_pkt__bindgen_ty_1, - /// < fragmentation key + ///< fragmentation key pub key: ip_frag_key, - /// < creation timestamp + ///< creation timestamp pub start: u64, - /// < expected reassembled size + ///< expected reassembled size pub total_size: u32, - /// < size of fragments received + ///< size of fragments received pub frag_size: u32, - /// < index of next entry to fill + ///< index of next entry to fill pub last_idx: u32, - /// < fragments + ///< fragments pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -300,7 +300,7 @@ impl ::std::cmp::PartialEq for ip_frag_pkt { && self.frags == other.frags } } -/// < fragment mbuf +///< fragment mbuf #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs index 7fde7a1a..5582c7de 100644 --- a/tests/expectations/tests/layout_eth_conf.rs +++ b/tests/expectations/tests/layout_eth_conf.rs @@ -149,9 +149,9 @@ pub enum rte_eth_rx_mq_mode { pub struct rte_eth_rxmode { /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, - /// < Only used if jumbo_frame enabled. + ///< Only used if jumbo_frame enabled. pub max_rx_pkt_len: u32, - /// < hdr buf size (header_split enabled). + ///< hdr buf size (header_split enabled). pub split_hdr_size: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, } @@ -361,20 +361,20 @@ impl rte_eth_rxmode { /// packets using multi-TCs. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_tx_mq_mode { - /// < It is in neither DCB nor VT mode. + ///< It is in neither DCB nor VT mode. ETH_MQ_TX_NONE = 0, - /// < For TX side,only DCB is on. + ///< For TX side,only DCB is on. ETH_MQ_TX_DCB = 1, - /// < For TX side,both DCB and VT is on. + ///< For TX side,both DCB and VT is on. ETH_MQ_TX_VMDQ_DCB = 2, - /// < Only VT on, no DCB + ///< Only VT on, no DCB ETH_MQ_TX_VMDQ_ONLY = 3, } /// A structure used to configure the TX features of an Ethernet port. #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { - /// < TX multi-queues mode. + ///< TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, pub pvid: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -494,11 +494,11 @@ impl rte_eth_txmode { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { - /// < If not NULL, 40-byte hash key. + ///< If not NULL, 40-byte hash key. pub rss_key: *mut u8, - /// < hash key length in bytes. + ///< hash key length in bytes. pub rss_key_len: u8, - /// < Hash functions to apply - see below. + ///< Hash functions to apply - see below. pub rss_hf: u64, } #[test] @@ -554,9 +554,9 @@ impl Default for rte_eth_rss_conf { /// in DCB configratioins #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { - /// < 4 TCs with DCB. + ///< 4 TCs with DCB. ETH_4_TCS = 4, - /// < 8 TCs with DCB. + ///< 8 TCs with DCB. ETH_8_TCS = 8, } #[repr(u32)] @@ -564,13 +564,13 @@ pub enum rte_eth_nb_tcs { /// in VMDQ configurations. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { - /// < 8 VMDq pools. + ///< 8 VMDq pools. ETH_8_POOLS = 8, - /// < 16 VMDq pools. + ///< 16 VMDq pools. ETH_16_POOLS = 16, - /// < 32 VMDq pools. + ///< 32 VMDq pools. ETH_32_POOLS = 32, - /// < 64 VMDq pools. + ///< 64 VMDq pools. ETH_64_POOLS = 64, } /// A structure used to configure the VMDQ+DCB feature @@ -585,24 +585,24 @@ pub enum rte_eth_nb_pools { #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_vmdq_dcb_conf { - /// < With DCB, 16 or 32 pools + ///< With DCB, 16 or 32 pools pub nb_queue_pools: rte_eth_nb_pools, - /// < If non-zero, use a default pool + ///< If non-zero, use a default pool pub enable_default_pool: u8, - /// < The default pool, if applicable + ///< The default pool, if applicable pub default_pool: u8, - /// < We can have up to 64 filters/mappings + ///< We can have up to 64 filters/mappings pub nb_pool_maps: u8, - /// < VMDq vlan pool maps. + ///< VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], pub dcb_tc: [u8; 8usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - /// < The vlan id of the received frame + ///< The vlan id of the received frame pub vlan_id: u16, - /// < Bitmask of pools for packet rx + ///< Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -737,7 +737,7 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { - /// < Possible DCB TCs, 4 or 8 TCs + ///< Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], @@ -783,7 +783,7 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { - /// < With DCB, 16 or 32 pools. + ///< With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], @@ -831,7 +831,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { - /// < Possible DCB TCs, 4 or 8 TCs. + ///< Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], @@ -877,7 +877,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { - /// < VMDq mode, 64 pools. + ///< VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -913,27 +913,27 @@ impl Default for rte_eth_vmdq_tx_conf { #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_vmdq_rx_conf { - /// < VMDq only mode, 8 or 64 pools + ///< VMDq only mode, 8 or 64 pools pub nb_queue_pools: rte_eth_nb_pools, - /// < If non-zero, use a default pool + ///< If non-zero, use a default pool pub enable_default_pool: u8, - /// < The default pool, if applicable + ///< The default pool, if applicable pub default_pool: u8, - /// < Enable VT loop back + ///< Enable VT loop back pub enable_loop_back: u8, - /// < We can have up to 64 filters/mappings + ///< We can have up to 64 filters/mappings pub nb_pool_maps: u8, - /// < Flags from ETH_VMDQ_ACCEPT_* + ///< Flags from ETH_VMDQ_ACCEPT_* pub rx_mode: u32, - /// < VMDq vlan pool maps. + ///< VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - /// < The vlan id of the received frame + ///< The vlan id of the received frame pub vlan_id: u16, - /// < Bitmask of pools for packet rx + ///< Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -1081,15 +1081,15 @@ impl Default for rte_eth_vmdq_rx_conf { /// Flow Director setting modes: none, signature or perfect. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { - /// < Disable FDIR support. + ///< Disable FDIR support. RTE_FDIR_MODE_NONE = 0, - /// < Enable FDIR signature filter mode. + ///< Enable FDIR signature filter mode. RTE_FDIR_MODE_SIGNATURE = 1, - /// < Enable FDIR perfect filter mode. + ///< Enable FDIR perfect filter mode. RTE_FDIR_MODE_PERFECT = 2, - /// < Enable FDIR filter mode - MAC VLAN. + ///< Enable FDIR filter mode - MAC VLAN. RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - /// < Enable FDIR filter mode - tunnel. + ///< Enable FDIR filter mode - tunnel. RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] @@ -1097,37 +1097,37 @@ pub enum rte_fdir_mode { /// in the board memory. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { - /// < 64k. + ///< 64k. RTE_FDIR_PBALLOC_64K = 0, - /// < 128k. + ///< 128k. RTE_FDIR_PBALLOC_128K = 1, - /// < 256k. + ///< 256k. RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] /// Select report mode of FDIR hash information in RX descriptors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { - /// < Never report FDIR hash. + ///< Never report FDIR hash. RTE_FDIR_NO_REPORT_STATUS = 0, - /// < Only report FDIR hash for matching pkts. + ///< Only report FDIR hash for matching pkts. RTE_FDIR_REPORT_STATUS = 1, - /// < Always report FDIR hash. + ///< Always report FDIR hash. RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } /// A structure used to define the input for IPV4 flow #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { - /// < IPv4 source address in big endian. + ///< IPv4 source address in big endian. pub src_ip: u32, - /// < IPv4 destination address in big endian. + ///< IPv4 destination address in big endian. pub dst_ip: u32, - /// < Type of service to match. + ///< Type of service to match. pub tos: u8, - /// < Time to live to match. + ///< Time to live to match. pub ttl: u8, - /// < Protocol, next header in big endian. + ///< Protocol, next header in big endian. pub proto: u8, } #[test] @@ -1197,15 +1197,15 @@ fn bindgen_test_layout_rte_eth_ipv4_flow() { #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { - /// < IPv6 source address in big endian. + ///< IPv6 source address in big endian. pub src_ip: [u32; 4usize], - /// < IPv6 destination address in big endian. + ///< IPv6 destination address in big endian. pub dst_ip: [u32; 4usize], - /// < Traffic class to match. + ///< Traffic class to match. pub tc: u8, - /// < Protocol, next header to match. + ///< Protocol, next header to match. pub proto: u8, - /// < Hop limits to match. + ///< Hop limits to match. pub hop_limits: u8, } #[test] @@ -1276,7 +1276,7 @@ fn bindgen_test_layout_rte_eth_ipv6_flow() { #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { - /// < Bit mask for vlan_tci in big endian + ///< Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, /// Bit mask for ipv4 flow in big endian. pub ipv4_mask: rte_eth_ipv4_flow, @@ -1287,12 +1287,12 @@ pub struct rte_eth_fdir_masks { /// Bit mask for L4 destination port in big endian. pub dst_port_mask: u16, /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the - /// first byte on the wire + ///first byte on the wire pub mac_addr_byte_mask: u8, /// Bit mask for tunnel ID in big endian. pub tunnel_id_mask: u32, - /// < 1 - Match tunnel type, - /// 0 - Ignore tunnel type. + ///< 1 - Match tunnel type, + ///0 - Ignore tunnel type. pub tunnel_type_mask: u8, } #[test] @@ -1416,7 +1416,7 @@ pub enum rte_eth_payload_type { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { - /// < Payload type + ///< Payload type pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1508,9 +1508,9 @@ fn bindgen_test_layout_rte_eth_fdir_flex_mask() { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { - /// < The number of following payload cfg + ///< The number of following payload cfg pub nb_payloads: u16, - /// < The number of following mask + ///< The number of following mask pub nb_flexmasks: u16, pub flex_set: [rte_eth_flex_payload_cfg; 8usize], pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], @@ -1586,11 +1586,11 @@ impl Default for rte_eth_fdir_flex_conf { #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { - /// < Flow Director mode. + ///< Flow Director mode. pub mode: rte_fdir_mode, - /// < Space for FDIR filters. + ///< Space for FDIR filters. pub pballoc: rte_fdir_pballoc_type, - /// < How to report FDIR hash. + ///< How to report FDIR hash. pub status: rte_fdir_status_mode, /// RX queue of packets matching a "drop" filter in perfect mode. pub drop_queue: u8, @@ -1723,40 +1723,40 @@ fn bindgen_test_layout_rte_intr_conf() { #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_conf { - /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be - /// used. ETH_LINK_SPEED_FIXED disables link - /// autonegotiation, and a unique speed shall be - /// set. Otherwise, the bitmap defines the set of - /// speeds to be advertised. If the special value - /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - /// supported are advertised. + ///< bitmap of ETH_LINK_SPEED_XXX of speeds to be + ///used. ETH_LINK_SPEED_FIXED disables link + ///autonegotiation, and a unique speed shall be + ///set. Otherwise, the bitmap defines the set of + ///speeds to be advertised. If the special value + ///ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + ///supported are advertised. pub link_speeds: u32, - /// < Port RX configuration. + ///< Port RX configuration. pub rxmode: rte_eth_rxmode, - /// < Port TX configuration. + ///< Port TX configuration. pub txmode: rte_eth_txmode, - /// < Loopback operation mode. By default the value - /// is 0, meaning the loopback mode is disabled. - /// Read the datasheet of given ethernet controller - /// for details. The possible values of this field - /// are defined in implementation of each driver. + ///< Loopback operation mode. By default the value + ///is 0, meaning the loopback mode is disabled. + ///Read the datasheet of given ethernet controller + ///for details. The possible values of this field + ///are defined in implementation of each driver. pub lpbk_mode: u32, - /// < Port RX filtering configuration (union). + ///< Port RX filtering configuration (union). pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - /// < Port TX DCB configuration (union). + ///< Port TX DCB configuration (union). pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC - /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. + ///is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. pub dcb_capability_en: u32, - /// < FDIR configuration. + ///< FDIR configuration. pub fdir_conf: rte_fdir_conf, - /// < Interrupt mode configuration. + ///< Interrupt mode configuration. pub intr_conf: rte_intr_conf, } #[repr(C)] #[derive(Copy, Clone)] pub struct rte_eth_conf__bindgen_ty_1 { - /// < Port RSS configuration + ///< Port RSS configuration pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, pub dcb_rx_conf: rte_eth_dcb_rx_conf, diff --git a/tests/expectations/tests/layout_eth_conf_1_0.rs b/tests/expectations/tests/layout_eth_conf_1_0.rs index 220a4f7c..b8c20f3d 100644 --- a/tests/expectations/tests/layout_eth_conf_1_0.rs +++ b/tests/expectations/tests/layout_eth_conf_1_0.rs @@ -192,9 +192,9 @@ pub enum rte_eth_rx_mq_mode { pub struct rte_eth_rxmode { /// The multi-queue packet distribution mode to be used, e.g. RSS. pub mq_mode: rte_eth_rx_mq_mode, - /// < Only used if jumbo_frame enabled. + ///< Only used if jumbo_frame enabled. pub max_rx_pkt_len: u32, - /// < hdr buf size (header_split enabled). + ///< hdr buf size (header_split enabled). pub split_hdr_size: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>, } @@ -409,20 +409,20 @@ impl rte_eth_rxmode { /// packets using multi-TCs. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_tx_mq_mode { - /// < It is in neither DCB nor VT mode. + ///< It is in neither DCB nor VT mode. ETH_MQ_TX_NONE = 0, - /// < For TX side,only DCB is on. + ///< For TX side,only DCB is on. ETH_MQ_TX_DCB = 1, - /// < For TX side,both DCB and VT is on. + ///< For TX side,both DCB and VT is on. ETH_MQ_TX_VMDQ_DCB = 2, - /// < Only VT on, no DCB + ///< Only VT on, no DCB ETH_MQ_TX_VMDQ_ONLY = 3, } /// A structure used to configure the TX features of an Ethernet port. #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_txmode { - /// < TX multi-queues mode. + ///< TX multi-queues mode. pub mq_mode: rte_eth_tx_mq_mode, pub pvid: u16, pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>, @@ -547,11 +547,11 @@ impl rte_eth_txmode { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_rss_conf { - /// < If not NULL, 40-byte hash key. + ///< If not NULL, 40-byte hash key. pub rss_key: *mut u8, - /// < hash key length in bytes. + ///< hash key length in bytes. pub rss_key_len: u8, - /// < Hash functions to apply - see below. + ///< Hash functions to apply - see below. pub rss_hf: u64, } #[test] @@ -612,9 +612,9 @@ impl Default for rte_eth_rss_conf { /// in DCB configratioins #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_tcs { - /// < 4 TCs with DCB. + ///< 4 TCs with DCB. ETH_4_TCS = 4, - /// < 8 TCs with DCB. + ///< 8 TCs with DCB. ETH_8_TCS = 8, } #[repr(u32)] @@ -622,13 +622,13 @@ pub enum rte_eth_nb_tcs { /// in VMDQ configurations. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_eth_nb_pools { - /// < 8 VMDq pools. + ///< 8 VMDq pools. ETH_8_POOLS = 8, - /// < 16 VMDq pools. + ///< 16 VMDq pools. ETH_16_POOLS = 16, - /// < 32 VMDq pools. + ///< 32 VMDq pools. ETH_32_POOLS = 32, - /// < 64 VMDq pools. + ///< 64 VMDq pools. ETH_64_POOLS = 64, } /// A structure used to configure the VMDQ+DCB feature @@ -643,24 +643,24 @@ pub enum rte_eth_nb_pools { #[repr(C)] #[derive(Copy)] pub struct rte_eth_vmdq_dcb_conf { - /// < With DCB, 16 or 32 pools + ///< With DCB, 16 or 32 pools pub nb_queue_pools: rte_eth_nb_pools, - /// < If non-zero, use a default pool + ///< If non-zero, use a default pool pub enable_default_pool: u8, - /// < The default pool, if applicable + ///< The default pool, if applicable pub default_pool: u8, - /// < We can have up to 64 filters/mappings + ///< We can have up to 64 filters/mappings pub nb_pool_maps: u8, - /// < VMDq vlan pool maps. + ///< VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_dcb_conf__bindgen_ty_1; 64usize], pub dcb_tc: [u8; 8usize], } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 { - /// < The vlan id of the received frame + ///< The vlan id of the received frame pub vlan_id: u16, - /// < Bitmask of pools for packet rx + ///< Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -805,7 +805,7 @@ impl Default for rte_eth_vmdq_dcb_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_rx_conf { - /// < Possible DCB TCs, 4 or 8 TCs + ///< Possible DCB TCs, 4 or 8 TCs pub nb_tcs: rte_eth_nb_tcs, /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], @@ -856,7 +856,7 @@ impl Default for rte_eth_dcb_rx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_dcb_tx_conf { - /// < With DCB, 16 or 32 pools. + ///< With DCB, 16 or 32 pools. pub nb_queue_pools: rte_eth_nb_pools, /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], @@ -909,7 +909,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_dcb_tx_conf { - /// < Possible DCB TCs, 4 or 8 TCs. + ///< Possible DCB TCs, 4 or 8 TCs. pub nb_tcs: rte_eth_nb_tcs, /// Traffic class each UP mapped to. pub dcb_tc: [u8; 8usize], @@ -960,7 +960,7 @@ impl Default for rte_eth_dcb_tx_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_tx_conf { - /// < VMDq mode, 64 pools. + ///< VMDq mode, 64 pools. pub nb_queue_pools: rte_eth_nb_pools, } #[test] @@ -1001,27 +1001,27 @@ impl Default for rte_eth_vmdq_tx_conf { #[repr(C)] #[derive(Copy)] pub struct rte_eth_vmdq_rx_conf { - /// < VMDq only mode, 8 or 64 pools + ///< VMDq only mode, 8 or 64 pools pub nb_queue_pools: rte_eth_nb_pools, - /// < If non-zero, use a default pool + ///< If non-zero, use a default pool pub enable_default_pool: u8, - /// < The default pool, if applicable + ///< The default pool, if applicable pub default_pool: u8, - /// < Enable VT loop back + ///< Enable VT loop back pub enable_loop_back: u8, - /// < We can have up to 64 filters/mappings + ///< We can have up to 64 filters/mappings pub nb_pool_maps: u8, - /// < Flags from ETH_VMDQ_ACCEPT_* + ///< Flags from ETH_VMDQ_ACCEPT_* pub rx_mode: u32, - /// < VMDq vlan pool maps. + ///< VMDq vlan pool maps. pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize], } #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 { - /// < The vlan id of the received frame + ///< The vlan id of the received frame pub vlan_id: u16, - /// < Bitmask of pools for packet rx + ///< Bitmask of pools for packet rx pub pools: u64, } #[test] @@ -1179,15 +1179,15 @@ impl Default for rte_eth_vmdq_rx_conf { /// Flow Director setting modes: none, signature or perfect. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_mode { - /// < Disable FDIR support. + ///< Disable FDIR support. RTE_FDIR_MODE_NONE = 0, - /// < Enable FDIR signature filter mode. + ///< Enable FDIR signature filter mode. RTE_FDIR_MODE_SIGNATURE = 1, - /// < Enable FDIR perfect filter mode. + ///< Enable FDIR perfect filter mode. RTE_FDIR_MODE_PERFECT = 2, - /// < Enable FDIR filter mode - MAC VLAN. + ///< Enable FDIR filter mode - MAC VLAN. RTE_FDIR_MODE_PERFECT_MAC_VLAN = 3, - /// < Enable FDIR filter mode - tunnel. + ///< Enable FDIR filter mode - tunnel. RTE_FDIR_MODE_PERFECT_TUNNEL = 4, } #[repr(u32)] @@ -1195,37 +1195,37 @@ pub enum rte_fdir_mode { /// in the board memory. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_pballoc_type { - /// < 64k. + ///< 64k. RTE_FDIR_PBALLOC_64K = 0, - /// < 128k. + ///< 128k. RTE_FDIR_PBALLOC_128K = 1, - /// < 256k. + ///< 256k. RTE_FDIR_PBALLOC_256K = 2, } #[repr(u32)] /// Select report mode of FDIR hash information in RX descriptors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum rte_fdir_status_mode { - /// < Never report FDIR hash. + ///< Never report FDIR hash. RTE_FDIR_NO_REPORT_STATUS = 0, - /// < Only report FDIR hash for matching pkts. + ///< Only report FDIR hash for matching pkts. RTE_FDIR_REPORT_STATUS = 1, - /// < Always report FDIR hash. + ///< Always report FDIR hash. RTE_FDIR_REPORT_STATUS_ALWAYS = 2, } /// A structure used to define the input for IPV4 flow #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv4_flow { - /// < IPv4 source address in big endian. + ///< IPv4 source address in big endian. pub src_ip: u32, - /// < IPv4 destination address in big endian. + ///< IPv4 destination address in big endian. pub dst_ip: u32, - /// < Type of service to match. + ///< Type of service to match. pub tos: u8, - /// < Time to live to match. + ///< Time to live to match. pub ttl: u8, - /// < Protocol, next header in big endian. + ///< Protocol, next header in big endian. pub proto: u8, } #[test] @@ -1300,15 +1300,15 @@ impl Clone for rte_eth_ipv4_flow { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_ipv6_flow { - /// < IPv6 source address in big endian. + ///< IPv6 source address in big endian. pub src_ip: [u32; 4usize], - /// < IPv6 destination address in big endian. + ///< IPv6 destination address in big endian. pub dst_ip: [u32; 4usize], - /// < Traffic class to match. + ///< Traffic class to match. pub tc: u8, - /// < Protocol, next header to match. + ///< Protocol, next header to match. pub proto: u8, - /// < Hop limits to match. + ///< Hop limits to match. pub hop_limits: u8, } #[test] @@ -1384,7 +1384,7 @@ impl Clone for rte_eth_ipv6_flow { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_masks { - /// < Bit mask for vlan_tci in big endian + ///< Bit mask for vlan_tci in big endian pub vlan_tci_mask: u16, /// Bit mask for ipv4 flow in big endian. pub ipv4_mask: rte_eth_ipv4_flow, @@ -1395,12 +1395,12 @@ pub struct rte_eth_fdir_masks { /// Bit mask for L4 destination port in big endian. pub dst_port_mask: u16, /// 6 bit mask for proper 6 bytes of Mac address, bit 0 matches the - /// first byte on the wire + ///first byte on the wire pub mac_addr_byte_mask: u8, /// Bit mask for tunnel ID in big endian. pub tunnel_id_mask: u32, - /// < 1 - Match tunnel type, - /// 0 - Ignore tunnel type. + ///< 1 - Match tunnel type, + ///0 - Ignore tunnel type. pub tunnel_type_mask: u8, } #[test] @@ -1529,7 +1529,7 @@ pub enum rte_eth_payload_type { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_flex_payload_cfg { - /// < Payload type + ///< Payload type pub type_: rte_eth_payload_type, pub src_offset: [u16; 16usize], } @@ -1631,9 +1631,9 @@ impl Clone for rte_eth_fdir_flex_mask { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_eth_fdir_flex_conf { - /// < The number of following payload cfg + ///< The number of following payload cfg pub nb_payloads: u16, - /// < The number of following mask + ///< The number of following mask pub nb_flexmasks: u16, pub flex_set: [rte_eth_flex_payload_cfg; 8usize], pub flex_mask: [rte_eth_fdir_flex_mask; 22usize], @@ -1714,11 +1714,11 @@ impl Default for rte_eth_fdir_flex_conf { #[repr(C)] #[derive(Debug, Copy, Hash, PartialEq, Eq)] pub struct rte_fdir_conf { - /// < Flow Director mode. + ///< Flow Director mode. pub mode: rte_fdir_mode, - /// < Space for FDIR filters. + ///< Space for FDIR filters. pub pballoc: rte_fdir_pballoc_type, - /// < How to report FDIR hash. + ///< How to report FDIR hash. pub status: rte_fdir_status_mode, /// RX queue of packets matching a "drop" filter in perfect mode. pub drop_queue: u8, @@ -1861,40 +1861,40 @@ impl Clone for rte_intr_conf { #[repr(C)] #[derive(Copy)] pub struct rte_eth_conf { - /// < bitmap of ETH_LINK_SPEED_XXX of speeds to be - /// used. ETH_LINK_SPEED_FIXED disables link - /// autonegotiation, and a unique speed shall be - /// set. Otherwise, the bitmap defines the set of - /// speeds to be advertised. If the special value - /// ETH_LINK_SPEED_AUTONEG (0) is used, all speeds - /// supported are advertised. + ///< bitmap of ETH_LINK_SPEED_XXX of speeds to be + ///used. ETH_LINK_SPEED_FIXED disables link + ///autonegotiation, and a unique speed shall be + ///set. Otherwise, the bitmap defines the set of + ///speeds to be advertised. If the special value + ///ETH_LINK_SPEED_AUTONEG (0) is used, all speeds + ///supported are advertised. pub link_speeds: u32, - /// < Port RX configuration. + ///< Port RX configuration. pub rxmode: rte_eth_rxmode, - /// < Port TX configuration. + ///< Port TX configuration. pub txmode: rte_eth_txmode, - /// < Loopback operation mode. By default the value - /// is 0, meaning the loopback mode is disabled. - /// Read the datasheet of given ethernet controller - /// for details. The possible values of this field - /// are defined in implementation of each driver. + ///< Loopback operation mode. By default the value + ///is 0, meaning the loopback mode is disabled. + ///Read the datasheet of given ethernet controller + ///for details. The possible values of this field + ///are defined in implementation of each driver. pub lpbk_mode: u32, - /// < Port RX filtering configuration (union). + ///< Port RX filtering configuration (union). pub rx_adv_conf: rte_eth_conf__bindgen_ty_1, - /// < Port TX DCB configuration (union). + ///< Port TX DCB configuration (union). pub tx_adv_conf: rte_eth_conf__bindgen_ty_2, /// Currently,Priority Flow Control(PFC) are supported,if DCB with PFC - /// is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. + ///is needed,and the variable must be set ETH_DCB_PFC_SUPPORT. pub dcb_capability_en: u32, - /// < FDIR configuration. + ///< FDIR configuration. pub fdir_conf: rte_fdir_conf, - /// < Interrupt mode configuration. + ///< Interrupt mode configuration. pub intr_conf: rte_intr_conf, } #[repr(C)] #[derive(Copy)] pub struct rte_eth_conf__bindgen_ty_1 { - /// < Port RSS configuration + ///< Port RSS configuration pub rss_conf: rte_eth_rss_conf, pub vmdq_dcb_conf: rte_eth_vmdq_dcb_conf, pub dcb_rx_conf: rte_eth_dcb_rx_conf, diff --git a/tests/expectations/tests/layout_kni_mbuf.rs b/tests/expectations/tests/layout_kni_mbuf.rs index 409dad17..cd456881 100644 --- a/tests/expectations/tests/layout_kni_mbuf.rs +++ b/tests/expectations/tests/layout_kni_mbuf.rs @@ -15,18 +15,18 @@ pub struct rte_kni_mbuf { pub buf_addr: *mut ::std::os::raw::c_void, pub buf_physaddr: u64, pub pad0: [::std::os::raw::c_char; 2usize], - /// < Start address of data in segment buffer. + ///< Start address of data in segment buffer. pub data_off: u16, pub pad1: [::std::os::raw::c_char; 2usize], - /// < Number of segments. + ///< Number of segments. pub nb_segs: u8, pub pad4: [::std::os::raw::c_char; 1usize], - /// < Offload features. + ///< Offload features. pub ol_flags: u64, pub pad2: [::std::os::raw::c_char; 4usize], - /// < Total pkt len: sum of all segment data_len. + ///< Total pkt len: sum of all segment data_len. pub pkt_len: u32, - /// < Amount of data in segment buffer. + ///< Amount of data in segment buffer. pub data_len: u16, pub __bindgen_padding_0: [u8; 22usize], pub pad3: [::std::os::raw::c_char; 8usize], diff --git a/tests/expectations/tests/layout_large_align_field.rs b/tests/expectations/tests/layout_large_align_field.rs index 599d813d..5a865189 100644 --- a/tests/expectations/tests/layout_large_align_field.rs +++ b/tests/expectations/tests/layout_large_align_field.rs @@ -53,11 +53,11 @@ pub const IP_MAX_FRAG_NUM: _bindgen_ty_1 = _bindgen_ty_1::IP_MAX_FRAG_NUM; #[repr(u32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum _bindgen_ty_1 { - /// < index of last fragment + ///< index of last fragment IP_LAST_FRAG_IDX = 0, - /// < index of first fragment + ///< index of first fragment IP_FIRST_FRAG_IDX = 1, - /// < minimum number of fragments + ///< minimum number of fragments IP_MIN_FRAG_NUM = 2, IP_MAX_FRAG_NUM = 4, } @@ -65,11 +65,11 @@ pub enum _bindgen_ty_1 { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct ip_frag { - /// < offset into the packet + ///< offset into the packet pub ofs: u16, - /// < length of fragment + ///< length of fragment pub len: u16, - /// < fragment mbuf + ///< fragment mbuf pub mb: *mut rte_mbuf, } #[test] @@ -124,11 +124,11 @@ impl Default for ip_frag { #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct ip_frag_key { - /// < src address, first 8 bytes used for IPv4 + ///< src address, first 8 bytes used for IPv4 pub src_dst: [u64; 4usize], - /// < dst address + ///< dst address pub id: u32, - /// < src/dst key length + ///< src/dst key length pub key_len: u32, } #[test] @@ -179,19 +179,19 @@ fn bindgen_test_layout_ip_frag_key() { #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_pkt { - /// < LRU list + ///< LRU list pub lru: ip_frag_pkt__bindgen_ty_1, - /// < fragmentation key + ///< fragmentation key pub key: ip_frag_key, - /// < creation timestamp + ///< creation timestamp pub start: u64, - /// < expected reassembled size + ///< expected reassembled size pub total_size: u32, - /// < size of fragments received + ///< size of fragments received pub frag_size: u32, - /// < index of next entry to fill + ///< index of next entry to fill pub last_idx: u32, - /// < fragments + ///< fragments pub frags: [ip_frag; 4usize], pub __bindgen_padding_0: [u64; 6usize], } @@ -374,17 +374,17 @@ impl Default for ip_pkt_list { #[repr(C)] #[derive(Copy, Clone)] pub struct ip_frag_tbl_stat { - /// < total # of find/insert attempts. + ///< total # of find/insert attempts. pub find_num: u64, - /// < # of add ops. + ///< # of add ops. pub add_num: u64, - /// < # of del ops. + ///< # of del ops. pub del_num: u64, - /// < # of reuse (del/add) ops. + ///< # of reuse (del/add) ops. pub reuse_num: u64, - /// < total # of add failures. + ///< total # of add failures. pub fail_total: u64, - /// < # of 'no space' add failures. + ///< # of 'no space' add failures. pub fail_nospace: u64, pub __bindgen_padding_0: [u64; 2usize], } @@ -464,28 +464,28 @@ impl Default for ip_frag_tbl_stat { /// fragmentation table #[repr(C)] pub struct rte_ip_frag_tbl { - /// < ttl for table entries. + ///< ttl for table entries. pub max_cycles: u64, - /// < hash value mask. + ///< hash value mask. pub entry_mask: u32, - /// < max entries allowed. + ///< max entries allowed. pub max_entries: u32, - /// < entries in use. + ///< entries in use. pub use_entries: u32, - /// < hash assocaitivity. + ///< hash assocaitivity. pub bucket_entries: u32, - /// < total size of the table. + ///< total size of the table. pub nb_entries: u32, - /// < num of associativity lines. + ///< num of associativity lines. pub nb_buckets: u32, - /// < last used entry. + ///< last used entry. pub last: *mut ip_frag_pkt, - /// < LRU list for table entries. + ///< LRU list for table entries. pub lru: ip_pkt_list, pub __bindgen_padding_0: u64, - /// < statistics counters. + ///< statistics counters. pub stat: ip_frag_tbl_stat, - /// < hash table. + ///< hash table. pub pkt: __IncompleteArrayField, } #[test] @@ -611,7 +611,7 @@ impl Default for rte_ip_frag_tbl { unsafe { ::std::mem::zeroed() } } } -/// < fragment mbuf +///< fragment mbuf #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct rte_mbuf { diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs index 81ff60ed..83dfb946 100644 --- a/tests/expectations/tests/layout_mbuf.rs +++ b/tests/expectations/tests/layout_mbuf.rs @@ -99,7 +99,7 @@ pub type MARKER64 = [u64; 0usize]; #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { - /// < An internal counter value. + ///< An internal counter value. pub cnt: i16, } #[test] @@ -129,40 +129,40 @@ fn bindgen_test_layout_rte_atomic16_t() { #[repr(C)] pub struct rte_mbuf { pub cacheline0: MARKER, - /// < Virtual address of segment buffer. + ///< Virtual address of segment buffer. pub buf_addr: *mut ::std::os::raw::c_void, - /// < Physical address of segment buffer. + ///< Physical address of segment buffer. pub buf_physaddr: phys_addr_t, - /// < Length of segment buffer. + ///< Length of segment buffer. pub buf_len: u16, pub rearm_data: MARKER8, pub data_off: u16, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - /// < Number of segments. + ///< Number of segments. pub nb_segs: u8, - /// < Input port. + ///< Input port. pub port: u8, - /// < Offload features. + ///< Offload features. pub ol_flags: u64, pub rx_descriptor_fields1: MARKER, pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - /// < Total pkt len: sum of all segments. + ///< Total pkt len: sum of all segments. pub pkt_len: u32, - /// < Amount of data in segment buffer. + ///< Amount of data in segment buffer. pub data_len: u16, /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. pub vlan_tci: u16, - /// < hash information + ///< hash information pub hash: rte_mbuf__bindgen_ty_3, - /// < Sequence number. See also rte_reorder_insert() + ///< Sequence number. See also rte_reorder_insert() pub seqn: u32, /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. pub vlan_tci_outer: u16, pub cacheline1: MARKER, pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - /// < Pool from which mbuf was allocated. + ///< Pool from which mbuf was allocated. pub pool: *mut rte_mempool, - /// < Next segment of scattered packet. + ///< Next segment of scattered packet. pub next: *mut rte_mbuf, pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, /// Size of the application private data. In case of an indirect @@ -181,9 +181,9 @@ pub struct rte_mbuf { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_1 { - /// < Atomically accessed refcnt + ///< Atomically accessed refcnt pub refcnt_atomic: rte_atomic16_t, - /// < Non-atomically accessed refcnt + ///< Non-atomically accessed refcnt pub refcnt: u16, _bindgen_union_align: u16, } @@ -230,7 +230,7 @@ impl Default for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_2 { - /// < L2/L3/L4 and tunnel information. + ///< L2/L3/L4 and tunnel information. pub packet_type: u32, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_2__bindgen_ty_1, _bindgen_union_align: u32, @@ -414,13 +414,13 @@ impl Default for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_3 { - /// < RSS hash result if RSS enabled + ///< RSS hash result if RSS enabled pub rss: u32, - /// < Filter identifier if FDIR enabled + ///< Filter identifier if FDIR enabled pub fdir: rte_mbuf__bindgen_ty_3__bindgen_ty_1, - /// < Hierarchical scheduler + ///< Hierarchical scheduler pub sched: rte_mbuf__bindgen_ty_3__bindgen_ty_2, - /// < User defined tags. See rte_distributor_process() + ///< User defined tags. See rte_distributor_process() pub usr: u32, _bindgen_union_align: [u32; 2usize], } @@ -669,9 +669,9 @@ impl Default for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_4 { - /// < Can be used for external metadata + ///< Can be used for external metadata pub userdata: *mut ::std::os::raw::c_void, - /// < Allow 8-byte userdata on 32-bit + ///< Allow 8-byte userdata on 32-bit pub udata64: u64, _bindgen_union_align: u64, } @@ -716,7 +716,7 @@ impl Default for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Copy, Clone)] pub union rte_mbuf__bindgen_ty_5 { - /// < combined for easy fetch + ///< combined for easy fetch pub tx_offload: u64, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_5__bindgen_ty_1, _bindgen_union_align: u64, @@ -1104,7 +1104,7 @@ impl Default for rte_mbuf { unsafe { ::std::mem::zeroed() } } } -/// < Pool from which mbuf was allocated. +///< Pool from which mbuf was allocated. #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct rte_mempool { diff --git a/tests/expectations/tests/layout_mbuf_1_0.rs b/tests/expectations/tests/layout_mbuf_1_0.rs index f6a9eaa0..a1ec285e 100644 --- a/tests/expectations/tests/layout_mbuf_1_0.rs +++ b/tests/expectations/tests/layout_mbuf_1_0.rs @@ -142,7 +142,7 @@ pub type MARKER64 = [u64; 0usize]; #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_atomic16_t { - /// < An internal counter value. + ///< An internal counter value. pub cnt: i16, } #[test] @@ -177,40 +177,40 @@ impl Clone for rte_atomic16_t { #[repr(C)] pub struct rte_mbuf { pub cacheline0: MARKER, - /// < Virtual address of segment buffer. + ///< Virtual address of segment buffer. pub buf_addr: *mut ::std::os::raw::c_void, - /// < Physical address of segment buffer. + ///< Physical address of segment buffer. pub buf_physaddr: phys_addr_t, - /// < Length of segment buffer. + ///< Length of segment buffer. pub buf_len: u16, pub rearm_data: MARKER8, pub data_off: u16, pub __bindgen_anon_1: rte_mbuf__bindgen_ty_1, - /// < Number of segments. + ///< Number of segments. pub nb_segs: u8, - /// < Input port. + ///< Input port. pub port: u8, - /// < Offload features. + ///< Offload features. pub ol_flags: u64, pub rx_descriptor_fields1: MARKER, pub __bindgen_anon_2: rte_mbuf__bindgen_ty_2, - /// < Total pkt len: sum of all segments. + ///< Total pkt len: sum of all segments. pub pkt_len: u32, - /// < Amount of data in segment buffer. + ///< Amount of data in segment buffer. pub data_len: u16, /// VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. pub vlan_tci: u16, - /// < hash information + ///< hash information pub hash: rte_mbuf__bindgen_ty_3, - /// < Sequence number. See also rte_reorder_insert() + ///< Sequence number. See also rte_reorder_insert() pub seqn: u32, /// Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. pub vlan_tci_outer: u16, pub cacheline1: MARKER, pub __bindgen_anon_3: rte_mbuf__bindgen_ty_4, - /// < Pool from which mbuf was allocated. + ///< Pool from which mbuf was allocated. pub pool: *mut rte_mempool, - /// < Next segment of scattered packet. + ///< Next segment of scattered packet. pub next: *mut rte_mbuf, pub __bindgen_anon_4: rte_mbuf__bindgen_ty_5, /// Size of the application private data. In case of an indirect @@ -229,9 +229,9 @@ pub struct rte_mbuf { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_1 { - /// < Atomically accessed refcnt + ///< Atomically accessed refcnt pub refcnt_atomic: __BindgenUnionField, - /// < Non-atomically accessed refcnt + ///< Non-atomically accessed refcnt pub refcnt: __BindgenUnionField, pub bindgen_union_field: u16, } @@ -278,7 +278,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_2 { - /// < L2/L3/L4 and tunnel information. + ///< L2/L3/L4 and tunnel information. pub packet_type: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u32, @@ -467,13 +467,13 @@ impl Clone for rte_mbuf__bindgen_ty_2 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_3 { - /// < RSS hash result if RSS enabled + ///< RSS hash result if RSS enabled pub rss: __BindgenUnionField, - /// < Filter identifier if FDIR enabled + ///< Filter identifier if FDIR enabled pub fdir: __BindgenUnionField, - /// < Hierarchical scheduler + ///< Hierarchical scheduler pub sched: __BindgenUnionField, - /// < User defined tags. See rte_distributor_process() + ///< User defined tags. See rte_distributor_process() pub usr: __BindgenUnionField, pub bindgen_union_field: [u32; 2usize], } @@ -733,9 +733,9 @@ impl Clone for rte_mbuf__bindgen_ty_3 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_4 { - /// < Can be used for external metadata + ///< Can be used for external metadata pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>, - /// < Allow 8-byte userdata on 32-bit + ///< Allow 8-byte userdata on 32-bit pub udata64: __BindgenUnionField, pub bindgen_union_field: u64, } @@ -780,7 +780,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 { #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mbuf__bindgen_ty_5 { - /// < combined for easy fetch + ///< combined for easy fetch pub tx_offload: __BindgenUnionField, pub __bindgen_anon_1: __BindgenUnionField, pub bindgen_union_field: u64, @@ -1173,7 +1173,7 @@ impl Default for rte_mbuf { unsafe { ::std::mem::zeroed() } } } -/// < Pool from which mbuf was allocated. +///< Pool from which mbuf was allocated. #[repr(C)] #[derive(Debug, Default, Copy, Hash, PartialEq, Eq)] pub struct rte_mempool { -- cgit v1.2.3 From 8e6354a5c117783739a18bb931d34b630b909060 Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Fri, 30 Nov 2018 06:38:50 +0100 Subject: Update which as well. --- Cargo.lock | 45 ++++++++++++++++++++++++++++++++++++++++++--- Cargo.toml | 2 +- src/lib.rs | 2 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c520fcbe..834a760d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,6 +24,27 @@ dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "backtrace" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bindgen" version = "0.43.2" @@ -42,7 +63,7 @@ dependencies = [ "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -109,6 +130,14 @@ dependencies = [ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "failure" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "glob" version = "0.2.11" @@ -229,6 +258,11 @@ dependencies = [ "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc-demangle" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "shlex" version = "0.1.1" @@ -305,9 +339,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "which" -version = "1.0.5" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -351,6 +386,8 @@ dependencies = [ "checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" +"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8fc0086be9ca82f7fc89fc873435531cb898b86e850005850de1f820e2db6e9b" @@ -359,6 +396,7 @@ dependencies = [ "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" "checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" +"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" @@ -375,6 +413,7 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" +"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" @@ -387,7 +426,7 @@ dependencies = [ "checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" -"checksum which 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e84a603e7e0b1ce1aa1ee2b109c7be00155ce52df5081590d1ffb93f4f515cb2" +"checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" diff --git a/Cargo.toml b/Cargo.toml index 4e4f81cf..dcb224e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ lazy_static = "1" peeking_take_while = "0.1.2" quote = { version = "0.6", default-features = false } regex = "1.0" -which = "1.0.2" +which = "2.0" # New validation in 0.3.6 breaks bindgen-integration: # https://github.com/alexcrichton/proc-macro2/commit/489c642. proc-macro2 = { version = "0.4", default-features = false } diff --git a/src/lib.rs b/src/lib.rs index 66ba2e82..a0202d18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1863,7 +1863,7 @@ impl Bindings { None => { let path = which::which("rustfmt") .map_err(|e| { - io::Error::new(io::ErrorKind::Other, e.to_owned()) + io::Error::new(io::ErrorKind::Other, format!("{}", e)) })?; Cow::Owned(path) -- cgit v1.2.3 From 370a2219895e2c590c4e44977945dde0c0727b81 Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Fri, 30 Nov 2018 06:39:17 +0100 Subject: Version bump. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 834a760d..ded2f0b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.43.2" +version = "0.44.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index dcb224e3..f1bafdbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" repository = "https://github.com/rust-lang/rust-bindgen" documentation = "https://docs.rs/bindgen" homepage = "https://rust-lang.github.io/rust-bindgen/" -version = "0.43.2" +version = "0.44.0" build = "build.rs" include = [ -- cgit v1.2.3 From 7b1406dc90f67fafca61dba915ac57b9d2d7d2d4 Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Fri, 30 Nov 2018 06:41:27 +0100 Subject: While at it, gcc -> cc in the integration tests. --- bindgen-integration/Cargo.toml | 2 +- bindgen-integration/build.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bindgen-integration/Cargo.toml b/bindgen-integration/Cargo.toml index 126cb363..1cd69b9f 100644 --- a/bindgen-integration/Cargo.toml +++ b/bindgen-integration/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" [build-dependencies] bindgen = { path = ".." } -gcc = "0.3" +cc = "1.0" [features] testing_only_libclang_5 = ["bindgen/testing_only_libclang_5"] diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs index 61580175..d9be232b 100644 --- a/bindgen-integration/build.rs +++ b/bindgen-integration/build.rs @@ -1,5 +1,5 @@ extern crate bindgen; -extern crate gcc; +extern crate cc; use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks}; use bindgen::Builder; @@ -72,7 +72,7 @@ impl Drop for MacroCallback { } fn main() { - gcc::Build::new() + cc::Build::new() .cpp(true) .file("cpp/Test.cc") .compile("libtest.a"); -- cgit v1.2.3