summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Orivel <eijebong@bananium.fr>2018-05-29 12:33:02 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-11-30 06:25:53 +0100
commit631871c553e16e020ea4161530b76d03b0c9bc3f (patch)
treebc724aba974a6abf0befb5f36643d649a2bc0330
parent33912cfcdc34bda21599de29cd7b4241eb7c341a (diff)
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.
-rw-r--r--Cargo.lock14
-rw-r--r--Cargo.toml4
-rw-r--r--src/codegen/helpers.rs67
-rw-r--r--src/codegen/impl_debug.rs16
-rw-r--r--src/codegen/impl_partialeq.rs9
-rw-r--r--src/codegen/mod.rs202
-rw-r--r--src/codegen/struct_layout.rs11
-rw-r--r--src/ir/context.rs10
-rw-r--r--src/ir/function.rs4
-rw-r--r--src/ir/objc.rs9
-rw-r--r--src/lib.rs2
-rw-r--r--tests/expectations/tests/accessors.rs31
-rw-r--r--tests/expectations/tests/annotation_hide.rs12
-rw-r--r--tests/expectations/tests/array-of-zero-sized-types.rs16
-rw-r--r--tests/expectations/tests/bitfield-32bit-overflow.rs23
-rw-r--r--tests/expectations/tests/bitfield-large.rs23
-rw-r--r--tests/expectations/tests/bitfield-method-same-name.rs23
-rw-r--r--tests/expectations/tests/bitfield_align.rs23
-rw-r--r--tests/expectations/tests/bitfield_align_2.rs23
-rw-r--r--tests/expectations/tests/bitfield_method_mangling.rs23
-rw-r--r--tests/expectations/tests/blacklist-and-impl-debug.rs11
-rw-r--r--tests/expectations/tests/class_use_as.rs12
-rw-r--r--tests/expectations/tests/comment-indent.rs44
-rw-r--r--tests/expectations/tests/constify-enum.rs2
-rw-r--r--tests/expectations/tests/contains-vs-inherits-zero-sized.rs20
-rw-r--r--tests/expectations/tests/convert-cpp-comment-to-rust.rs8
-rw-r--r--tests/expectations/tests/derive-bitfield-method-same-name.rs30
-rw-r--r--tests/expectations/tests/derive-clone.rs12
-rw-r--r--tests/expectations/tests/derive-clone_1_0.rs14
-rw-r--r--tests/expectations/tests/derive-debug-bitfield-core.rs16
-rw-r--r--tests/expectations/tests/derive-debug-bitfield.rs23
-rw-r--r--tests/expectations/tests/derive-default-and-blacklist.rs13
-rw-r--r--tests/expectations/tests/derive-hash-and-blacklist.rs11
-rw-r--r--tests/expectations/tests/derive-hash-blacklisting.rs15
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-anon-struct-float.rs12
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-float-array.rs12
-rw-r--r--tests/expectations/tests/derive-hash-struct-with-pointer.rs9
-rw-r--r--tests/expectations/tests/derive-hash-template-def-float.rs12
-rw-r--r--tests/expectations/tests/derive-hash-template-inst-float.rs16
-rw-r--r--tests/expectations/tests/derive-partialeq-and-blacklist.rs13
-rw-r--r--tests/expectations/tests/derive-partialeq-bitfield.rs26
-rw-r--r--tests/expectations/tests/derive-partialeq-union.rs12
-rw-r--r--tests/expectations/tests/derive-partialeq-union_1_0.rs11
-rw-r--r--tests/expectations/tests/divide-by-zero-in-struct-layout.rs23
-rw-r--r--tests/expectations/tests/doggo-or-null.rs21
-rw-r--r--tests/expectations/tests/enum-doc-bitfield.rs20
-rw-r--r--tests/expectations/tests/enum-doc-mod.rs20
-rw-r--r--tests/expectations/tests/enum-doc-rusty.rs20
-rw-r--r--tests/expectations/tests/enum-doc.rs20
-rw-r--r--tests/expectations/tests/enum-variant-replaces.rs21
-rw-r--r--tests/expectations/tests/inherit-from-template-instantiation-with-vtable.rs21
-rw-r--r--tests/expectations/tests/issue-1034.rs23
-rw-r--r--tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs23
-rw-r--r--tests/expectations/tests/issue-537.rs30
-rw-r--r--tests/expectations/tests/issue-648-derive-debug-with-padding.rs26
-rw-r--r--tests/expectations/tests/issue-739-pointer-wide-bitfield.rs23
-rw-r--r--tests/expectations/tests/issue-816.rs23
-rw-r--r--tests/expectations/tests/issue-848-replacement-system-include.rs22
-rw-r--r--tests/expectations/tests/issue-944-derive-copy-and-blacklisting.rs4
-rw-r--r--tests/expectations/tests/issue_315.rs14
-rw-r--r--tests/expectations/tests/jsval_layout_opaque.rs61
-rw-r--r--tests/expectations/tests/jsval_layout_opaque_1_0.rs61
-rw-r--r--tests/expectations/tests/layout_align.rs28
-rw-r--r--tests/expectations/tests/layout_arp.rs32
-rw-r--r--tests/expectations/tests/layout_array.rs64
-rw-r--r--tests/expectations/tests/layout_array_too_long.rs42
-rw-r--r--tests/expectations/tests/layout_cmdline_token.rs53
-rw-r--r--tests/expectations/tests/layout_eth_conf.rs348
-rw-r--r--tests/expectations/tests/layout_eth_conf_1_0.rs348
-rw-r--r--tests/expectations/tests/layout_kni_mbuf.rs10
-rw-r--r--tests/expectations/tests/layout_large_align_field.rs80
-rw-r--r--tests/expectations/tests/layout_mbuf.rs90
-rw-r--r--tests/expectations/tests/layout_mbuf_1_0.rs90
-rw-r--r--tests/expectations/tests/libclang-3.8/type_alias_template_specialized.rs2
-rw-r--r--tests/expectations/tests/libclang-3.9/type_alias_template_specialized.rs2
-rw-r--r--tests/expectations/tests/libclang-4/type_alias_template_specialized.rs2
-rw-r--r--tests/expectations/tests/libclang-5/type_alias_template_specialized.rs4
-rw-r--r--tests/expectations/tests/no-derive-debug.rs15
-rw-r--r--tests/expectations/tests/no-derive-default.rs15
-rw-r--r--tests/expectations/tests/no_copy.rs5
-rw-r--r--tests/expectations/tests/only_bitfields.rs23
-rw-r--r--tests/expectations/tests/opaque-template-inst-member-2.rs18
-rw-r--r--tests/expectations/tests/opaque-template-inst-member.rs17
-rw-r--r--tests/expectations/tests/opaque_in_struct.rs5
-rw-r--r--tests/expectations/tests/opaque_pointer.rs7
-rw-r--r--tests/expectations/tests/opaque_typedef.rs4
-rw-r--r--tests/expectations/tests/private.rs10
-rw-r--r--tests/expectations/tests/reparented_replacement.rs4
-rw-r--r--tests/expectations/tests/replace_template_alias.rs16
-rw-r--r--tests/expectations/tests/replace_use.rs5
-rw-r--r--tests/expectations/tests/replaces_double.rs4
-rw-r--r--tests/expectations/tests/struct_with_bitfields.rs23
-rw-r--r--tests/expectations/tests/template.rs27
-rw-r--r--tests/expectations/tests/templatized-bitfield.rs16
-rw-r--r--tests/expectations/tests/union_bitfield.rs23
-rw-r--r--tests/expectations/tests/union_bitfield_1_0.rs16
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield.rs23
-rw-r--r--tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs23
-rw-r--r--tests/expectations/tests/weird_bitfields.rs23
-rw-r--r--tests/expectations/tests/zero-sized-array.rs21
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<quote::Tokens> {
+pub fn integer_type(ctx: &BindgenContext, layout: Layout) -> Option<proc_macro2::TokenStream> {
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<Layout>,
- ) -> 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<quote::Tokens, ()> {
+ ) -> Result<proc_macro2::TokenStream, ()> {
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<quote::Tokens> {
+ ) -> Vec<proc_macro2::TokenStream> {
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<quote::Tokens>)>;
+ ) -> Option<(String, Vec<proc_macro2::TokenStream>)>;
}
impl<'a> ImplDebug<'a> for FieldData {
@@ -73,7 +73,7 @@ impl<'a> ImplDebug<'a> for FieldData {
&self,
ctx: &BindgenContext,
_: Self::Extra,
- ) -> Option<(String, Vec<quote::Tokens>)> {
+ ) -> Option<(String, Vec<proc_macro2::TokenStream>)> {
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<quote::Tokens>)> {
+ ) -> Option<(String, Vec<proc_macro2::TokenStream>)> {
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<quote::Tokens>)> {
+ ) -> Option<(String, Vec<proc_macro2::TokenStream>)> {
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<quote::Tokens>)> {
+ name_ident: proc_macro2::TokenStream,
+ ) -> Option<(String, Vec<proc_macro2::TokenStream>)> {
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: &quote::Tokens,
-) -> Option<quote::Tokens> {
+ ty_for_impl: &proc_macro2::TokenStream,
+) -> Option<proc_macro2::TokenStream> {
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<quote::Tokens> {
+fn top_level_path(ctx: &BindgenContext, item: &Item) -> Vec<proc_macro2::TokenStream> {
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<quote::Tokens> {
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<quote::Tokens>,
+ items: Vec<proc_macro2::TokenStream>,
/// 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<F>(&mut self, cb: F) -> Vec<quote::Tokens>
+ fn inner<F>(&mut self, cb: F) -> Vec<proc_macro2::TokenStream>
where
F: FnOnce(&mut Self),
{
@@ -231,7 +232,7 @@ impl<'a> CodegenResult<'a> {
}
impl<'a> ops::Deref for CodegenResult<'a> {
- type Target = Vec<quote::Tokens>;
+ type Target = Vec<proc_macro2::TokenStream>;
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<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
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<quote::Tokens>,
- M: Extend<quote::Tokens>;
+ F: Extend<proc_macro2::TokenStream>,
+ M: Extend<proc_macro2::TokenStream>;
}
impl<'a> FieldCodegen<'a> for Field {
@@ -983,8 +981,8 @@ impl<'a> FieldCodegen<'a> for Field {
methods: &mut M,
_: (),
) where
- F: Extend<quote::Tokens>,
- M: Extend<quote::Tokens>,
+ F: Extend<proc_macro2::TokenStream>,
+ M: Extend<proc_macro2::TokenStream>,
{
match *self {
Field::DataMember(ref data) => {
@@ -1035,8 +1033,8 @@ impl<'a> FieldCodegen<'a> for FieldData {
methods: &mut M,
_: (),
) where
- F: Extend<quote::Tokens>,
- M: Extend<quote::Tokens>,
+ F: Extend<proc_macro2::TokenStream>,
+ M: Extend<proc_macro2::TokenStream>,
{
// 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<quote::Tokens>,
- M: Extend<quote::Tokens>,
+ F: Extend<proc_macro2::TokenStream>,
+ M: Extend<proc_macro2::TokenStream>,
{
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<quote::Tokens>,
- M: Extend<quote::Tokens>,
+ F: Extend<proc_macro2::TokenStream>,
+ M: Extend<proc_macro2::TokenStream>,
{
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::<Vec<quote::Tokens>>();
+ .collect::<Vec<proc_macro2::TokenStream>>();
asserts
};
@@ -2021,7 +2019,7 @@ trait MethodCodegen {
fn codegen_method<'a>(
&self,
ctx: &BindgenContext,
- methods: &mut Vec<quote::Tokens>,
+ methods: &mut Vec<proc_macro2::TokenStream>,
method_names: &mut HashMap<String, usize>,
result: &mut CodegenResult<'a>,
parent: &CompInfo,
@@ -2032,7 +2030,7 @@ impl MethodCodegen for Method {
fn codegen_method<'a>(
&self,
ctx: &BindgenContext,
- methods: &mut Vec<quote::Tokens>,
+ methods: &mut Vec<proc_macro2::TokenStream>,
method_names: &mut HashMap<String, usize>,
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<quote::Tokens>,
- ident: Term,
- tokens: quote::Tokens,
+ attrs: Vec<proc_macro2::TokenStream>,
+ 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<quote::Tokens>,
+ variants: Vec<proc_macro2::TokenStream>,
codegen_depth: usize,
},
ModuleConsts {
codegen_depth: usize,
module_name: &'a str,
- module_items: Vec<quote::Tokens>,
+ module_items: Vec<proc_macro2::TokenStream>,
},
}
@@ -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<quote::Tokens>,
- repr: quote::Tokens,
+ attrs: Vec<proc_macro2::TokenStream>,
+ 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<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
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<quote::Tokens>;
+ ) -> error::Result<proc_macro2::TokenStream>;
}
/// 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: &<Self as TryToRustTyOrOpaque>::Extra,
- ) -> error::Result<quote::Tokens>;
+ ) -> error::Result<proc_macro2::TokenStream>;
}
impl<E, T> TryToRustTyOrOpaque for T
@@ -2898,7 +2896,7 @@ where
&self,
ctx: &BindgenContext,
extra: &E,
- ) -> error::Result<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
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: &<Self as ToRustTyOrOpaque>::Extra,
- ) -> quote::Tokens;
+ ) -> proc_macro2::TokenStream;
}
impl<E, T> 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<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
ctx.resolve_item((*self).into()).try_to_rust_ty(ctx, &())
}
}
@@ -3004,7 +3002,7 @@ impl TryToRustTy for Item {
&self,
ctx: &BindgenContext,
_: &(),
- ) -> error::Result<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
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<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
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<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
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<quote::Tokens> {
+ ) -> error::Result<proc_macro2::TokenStream> {
// 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<quote::Tokens>, BindgenOptions) {
+pub(crate) fn codegen(context: BindgenContext) -> (Vec<proc_macro2::TokenStream>, 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<quote::Tokens>) {
- let bitfield_unit_type = Term::new(include_str!("./bitfield_unit.rs"), Span::call_site());
+ pub fn prepend_bitfield_unit_type(result: &mut Vec<proc_macro2::TokenStream>) {
+ 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<quote::Tokens>,
+ result: &mut Vec<proc_macro2::TokenStream>,
) {
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<quote::Tokens>,
+ result: &mut Vec<proc_macro2::TokenStream>,
) {
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<quote::Tokens>,
+ result: &mut Vec<proc_macro2::TokenStream>,
) {
let prefix = ctx.trait_prefix();
@@ -3746,7 +3744,7 @@ mod utils {
pub fn prepend_incomplete_array_types(
ctx: &BindgenContext,
- result: &mut Vec<quote::Tokens>,
+ result: &mut Vec<proc_macro2::TokenStream>,
) {
let prefix = ctx.trait_prefix();
@@ -3819,7 +3817,7 @@ mod utils {
}
pub fn prepend_complex_type(
- result: &mut Vec<quote::Tokens>,
+ result: &mut Vec<proc_macro2::TokenStream>,
) {
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<quote::Tokens> {
- use proc_macro2::{Term, Span};
-
+ ) -> error::Result<proc_macro2::TokenStream> {
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<quote::Tokens> {
+ ) -> Option<proc_macro2::TokenStream> {
// 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<quote::Tokens> {
+ ) -> Vec<proc_macro2::TokenStream> {
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<usize>,
- ) -> Option<quote::Tokens> {
+ ) -> Option<proc_macro2::TokenStream> {
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<quote::Tokens> {
+ pub fn pad_struct(&mut self, layout: Layout) -> Option<proc_macro2::TokenStream> {
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<S>(&self, name: S) -> Term
+ pub fn rust_ident<S>(&self, name: S) -> Ident
where
S: AsRef<str>
{
@@ -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<T>(&self, name: T) -> Term
+ pub fn rust_ident_raw<T>(&self, name: T) -> Ident
where
T: AsRef<str>
{
- 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,
- /// <div rustbindgen accessor></div>
+ #[doc = " <div rustbindgen accessor></div>"]
pub mBothAccessors: ::std::os::raw::c_int,
- /// <div rustbindgen accessor="unsafe"></div>
+ #[doc = " <div rustbindgen accessor=\"unsafe\"></div>"]
pub mUnsafeAccessors: ::std::os::raw::c_int,
- /// <div rustbindgen accessor="immutable"></div>
+ #[doc = " <div rustbindgen accessor=\"immutable\"></div>"]
pub mImmutableAccessor: ::std::os::raw::c_int,
}
#[test]
@@ -92,7 +95,7 @@ impl SomeAccessors {
&self.mImmutableAccessor
}
}
-/// <div rustbindgen accessor></div>
+#[doc = " <div rustbindgen accessor></div>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct AllAccessors {
@@ -150,7 +153,7 @@ impl AllAccessors {
&mut self.mAlsoBothAccessors
}
}
-/// <div rustbindgen accessor="unsafe"></div>
+#[doc = " <div rustbindgen accessor=\"unsafe\"></div>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct AllUnsafeAccessors {
@@ -212,16 +215,16 @@ impl AllUnsafeAccessors {
&mut self.mAlsoBothAccessors
}
}
-/// <div rustbindgen accessor></div>
+#[doc = " <div rustbindgen accessor></div>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ContradictAccessors {
pub mBothAccessors: ::std::os::raw::c_int,
- /// <div rustbindgen accessor="false"></div>
+ #[doc = " <div rustbindgen accessor=\"false\"></div>"]
pub mNoAccessors: ::std::os::raw::c_int,
- /// <div rustbindgen accessor="unsafe"></div>
+ #[doc = " <div rustbindgen accessor=\"unsafe\"></div>"]
pub mUnsafeAccessors: ::std::os::raw::c_int,
- /// <div rustbindgen accessor="immutable"></div>
+ #[doc = " <div rustbindgen accessor=\"immutable\"></div>"]
pub mImmutableAccessor: ::std::os::raw::c_int,
}
#[test]
@@ -307,7 +310,7 @@ impl ContradictAccessors {
&self.mImmutableAccessor
}
}
-/// <div rustbindgen accessor replaces="Replaced"></div>
+#[doc = " <div rustbindgen accessor replaces=\"Replaced\"></div>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct Replaced {
@@ -346,7 +349,7 @@ impl Replaced {
&mut self.mAccessor
}
}
-/// <div rustbindgen accessor></div>
+#[doc = " <div rustbindgen accessor></div>"]
#[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)]
-
-
-
-/// <div rustbindgen opaque></div>
+#[doc = " <div rustbindgen opaque></div>"]
#[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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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)]
-
-
-
-/// <div rustbindgen="true" replaces="whatever"></div>
+#[doc = " <div rustbindgen=\"true\" replaces=\"whatever\"></div>"]
#[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,
- ///< <div rustbindgen constant></div>
+ #[doc = "< <div rustbindgen constant></div>"]
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<T> {
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-
-/// 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<f32>,
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<T> {
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<T> {
@@ -17,7 +19,7 @@ impl<T> Default for foo<T> {
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<T>(::std::marker::PhantomData<T>);
@@ -47,7 +50,7 @@ impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
}
}
impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {}
-/// 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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<B> 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
+)]
-/// <div rustbindgen replaces="PASS"></div>
-///
-/// Should see PASS below.
+#[doc = " <div rustbindgen replaces=\"PASS\"></div>"]
+#[doc = ""]
+#[doc = " Should see PASS below."]
pub const OGRErr_PASS: OGRErr = 0;
-/// <div rustbindgen replaces="OGRERR_NONE"></div>
-///
-/// Should see OGRERR_NONE instead of CUSTOM_OGRERR_NONE below.
+#[doc = " <div rustbindgen replaces=\"OGRERR_NONE\"></div>"]
+#[doc = ""]
+#[doc = " Should see OGRERR_NONE instead of CUSTOM_OGRERR_NONE below."]
pub const OGRErr_OGRERR_NONE: OGRErr = 1;
-/// <div rustbindgen replaces="OGRErr"></div>
+#[doc = " <div rustbindgen replaces=\"OGRErr\"></div>"]
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<T> {
@@ -19,7 +22,7 @@ impl<T> Default for BaseWithVtable<T> {
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<U> {
@@ -81,7 +84,7 @@ impl<U> Default for BaseWithoutVtable<U> {
}
#[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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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.
-///
-/// <div rustbindgen replaces="nsTArray"></div>
+#[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 = " <div rustbindgen replaces=\"nsTArray\"></div>"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct nsTArray<T> {
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)]
-
-
-
-/// <div rustbindgen replaces="c"></div>
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+#[doc = " <div rustbindgen replaces=\"c\"></div>"]
pub type c<a> = 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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
#[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<unsafe extern "C" fn(mp: *mut rte_mempool) -> ::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<unsafe extern "C" fn(mp: *mut rte_mempool)>;
-/// 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<unsafe extern "C" fn(mp: *const rte_mempool) -> ::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 <src addr, dst_addr, id> to uniquely indetify fragmented datagram.
+#[doc = " @internal <src addr, dst_addr, id> 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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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 <src addr, dst_addr, id> to uniquely indetify fragmented datagram.
+#[doc = " @internal <src addr, dst_addr, id> 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<ip_frag_pkt>,
}
#[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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<rte_atomic16_t>,
- ///< Non-atomically accessed refcnt
+ #[doc = "< Non-atomically accessed refcnt"]
pub refcnt: __BindgenUnionField<u16>,
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<u32>,
pub __bindgen_anon_1: __BindgenUnionField<rte_mbuf__bindgen_ty_2__bindgen_ty_1>,
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<u32>,
- ///< Filter identifier if FDIR enabled
+ #[doc = "< Filter identifier if FDIR enabled"]
pub fdir: __BindgenUnionField<rte_mbuf__bindgen_ty_3__bindgen_ty_1>,
- ///< Hierarchical scheduler
+ #[doc = "< Hierarchical scheduler"]
pub sched: __BindgenUnionField<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: __BindgenUnionField<u32>,
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<u64>,
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<u64>,
pub __bindgen_anon_1: __BindgenUnionField<rte_mbuf__bindgen_ty_5__bindgen_ty_1>,
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() {
)
);
}
-/// <div rustbindgen replaces="MaybeWrapped"></div>
+#[doc = " <div rustbindgen replaces=\"MaybeWrapped\"></div>"]
pub type MaybeWrapped<a> = 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() {
)
);
}
-/// <div rustbindgen replaces="MaybeWrapped"></div>
+#[doc = " <div rustbindgen replaces=\"MaybeWrapped\"></div>"]
pub type MaybeWrapped<a> = 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() }
}
}
-/// <div rustbindgen replaces="MaybeWrapped"></div>
+#[doc = " <div rustbindgen replaces=\"MaybeWrapped\"></div>"]
pub type MaybeWrapped<a> = 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() }
}
}
-/// <div rustbindgen replaces="MaybeWrapped"></div>
+#[doc = " <div rustbindgen replaces=\"MaybeWrapped\"></div>"]
pub type MaybeWrapped<a> = 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)]
-
-
-/// <div rustbindgen nocopy></div>
+#[doc = " <div rustbindgen nocopy></div>"]
#[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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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)]
-
-
-/// <div rustbindgen opaque>
+#[doc = " <div rustbindgen opaque>"]
#[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)]
-
-
-/// <div rustbindgen opaque></div>
+#[doc = " <div rustbindgen opaque></div>"]
#[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))
);
}
-/// <div rustbindgen opaque></div>
+#[doc = " <div rustbindgen opaque></div>"]
#[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,
}
-/// <div rustbindgen opaque></div>
+#[doc = " <div rustbindgen opaque></div>"]
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,
- /// <div rustbindgen private></div>
+ #[doc = " <div rustbindgen private></div>"]
mIsPrivate: ::std::os::raw::c_int,
}
#[test]
@@ -44,7 +42,7 @@ fn bindgen_test_layout_HasPrivate() {
)
);
}
-/// <div rustbindgen private></div>
+#[doc = " <div rustbindgen private></div>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct VeryPrivate {
@@ -84,11 +82,11 @@ fn bindgen_test_layout_VeryPrivate() {
)
);
}
-/// <div rustbindgen private></div>
+#[doc = " <div rustbindgen private></div>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct ContradictPrivate {
- /// <div rustbindgen private="false"></div>
+ #[doc = " <div rustbindgen private=\"false\"></div>"]
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;
- /// <div rustbindgen replaces="foo::Bar"></div>
+ #[doc = " <div rustbindgen replaces=\"foo::Bar\"></div>"]
#[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!
-///
-/// <div rustbindgen replaces="JS::detail::MaybeWrapped" />
+#[doc = " But the replacement type does use T!"]
+#[doc = ""]
+#[doc = " <div rustbindgen replaces=\"JS::detail::MaybeWrapped\" />"]
pub type JS_detail_MaybeWrapped<T> = 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)]
-
-
-/// <div rustbindgen replaces="nsTArray"></div>
+#[doc = " <div rustbindgen replaces=\"nsTArray\"></div>"]
#[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<T> {
@@ -22,7 +20,7 @@ pub struct Rooted<T> {
pub ptr: Rooted_MaybeWrapped<T>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
}
-/// <div rustbindgen replaces="Rooted_MaybeWrapped"></div>
+#[doc = " <div rustbindgen replaces=\"Rooted_MaybeWrapped\"></div>"]
pub type Rooted_MaybeWrapped<T> = T;
impl<T> Default for Rooted<T> {
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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() }
}
}
-/// <div rustbindgen opaque>
+#[doc = " <div rustbindgen opaque>"]
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Opaque {
@@ -360,7 +365,7 @@ fn bindgen_test_layout_POD() {
)
);
}
-/// <div rustbindgen replaces="NestedReplaced"></div>
+#[doc = " <div rustbindgen replaces=\"NestedReplaced\"></div>"]
#[repr(C)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct NestedReplaced<T> {
@@ -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.
-///
-/// <div rustbindgen replaces="ReplacedWithoutDestructor"></div>
+#[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 = " <div rustbindgen replaces=\"ReplacedWithoutDestructor\"></div>"]
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct ReplacedWithoutDestructor<T> {
@@ -467,10 +472,10 @@ impl<U> Default for ShouldNotBeCopiableAsWell<U> {
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.
-///
-/// <div rustbindgen replaces="ReplacedWithoutDestructorFwd"></div>
+#[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 = " <div rustbindgen replaces=\"ReplacedWithoutDestructorFwd\"></div>"]
#[repr(C)]
#[derive(Debug, Hash, PartialEq, Eq)]
pub struct ReplacedWithoutDestructorFwd<T> {
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
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<T> ::std::clone::Clone for __IncompleteArrayField<T> {
}
}
impl<T> ::std::marker::Copy for __IncompleteArrayField<T> {}
-/// 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 {