Repository: rust-lang/rust-bindgen
Pull request #2952 (2024-10-16 00:31:26)

Fix libtinfo dependency in CI
I noticed CI failures in #2951 because libtinfo5 is no longer available in ubuntu-latest since https://github.com/actions/runner-images/issues/10636.

```console
Run sudo apt-get update
  sudo apt-get update
  sudo apt-get install libtinfo5
  shell: /usr/bin/bash -e {0}
  env:
    CARGO_HOME: /home/runner/.cargo
    CARGO_INCREMENTAL: 0
    CARGO_TERM_COLOR: always
Hit:1 http://azure.archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://azure.archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Hit:5 https://packages.microsoft.com/repos/azure-cli noble InRelease
Get:6 https://packages.microsoft.com/ubuntu/24.04/prod noble InRelease [3600 B]
Get:7 http://azure.archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [595 kB]
Get:8 http://azure.archive.ubuntu.com/ubuntu noble-updates/main Translation-en [145 kB]
Get:9 http://azure.archive.ubuntu.com/ubuntu noble-updates/main amd64 c-n-f Metadata [10.2 kB]
Get:10 http://azure.archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [706 kB]
Get:11 http://azure.archive.ubuntu.com/ubuntu noble-updates/universe Translation-en [209 kB]
Get:12 http://azure.archive.ubuntu.com/ubuntu noble-updates/universe amd64 c-n-f Metadata [19.6 kB]
Get:13 http://azure.archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [385 kB]
Get:14 http://azure.archive.ubuntu.com/ubuntu noble-updates/restricted Translation-en [74.4 kB]
Get:15 http://azure.archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Packages [14.8 kB]
Get:16 http://azure.archive.ubuntu.com/ubuntu noble-updates/multiverse Translation-en [3820 B]
Get:17 http://azure.archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 c-n-f Metadata [552 B]
Get:18 http://azure.archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [10.6 kB]
Get:19 http://azure.archive.ubuntu.com/ubuntu noble-backports/universe Translation-en [10.8 kB]
Get:20 http://azure.archive.ubuntu.com/ubuntu noble-backports/universe amd64 c-n-f Metadata [1104 B]
Get:21 http://azure.archive.ubuntu.com/ubuntu noble-security/main amd64 Packages [410 kB]
Get:22 http://azure.archive.ubuntu.com/ubuntu noble-security/main Translation-en [90.4 kB]
Get:23 http://azure.archive.ubuntu.com/ubuntu noble-security/main amd64 c-n-f Metadata [5788 B]
Get:24 http://azure.archive.ubuntu.com/ubuntu noble-security/universe amd64 Packages [553 kB]
Get:25 http://azure.archive.ubuntu.com/ubuntu noble-security/universe Translation-en [147 kB]
Get:26 http://azure.archive.ubuntu.com/ubuntu noble-security/universe amd64 c-n-f Metadata [13.5 kB]
Get:27 https://packages.microsoft.com/ubuntu/24.04/prod noble/main amd64 Packages [12.2 kB]
Get:28 https://packages.microsoft.com/ubuntu/24.04/prod noble/main arm64 Packages [8451 B]
Get:29 https://packages.microsoft.com/ubuntu/24.04/prod noble/main armhf Packages [5057 B]
Fetched 3814 kB in 1s (7402 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libtinfo5
Error: Process completed with exit code 100.
```


Patch:
diff --git a/.github/workflows/bindgen.yml b/.github/workflows/bindgen.yml
index b54d6fdc..d1a11712 100644
--- a/.github/workflows/bindgen.yml
+++ b/.github/workflows/bindgen.yml
@@ -196,8 +196,8 @@ jobs:
       - name: Install libtinfo
         if: matrix.os == 'ubuntu-latest'
         run: |
-          sudo apt-get update
-          sudo apt-get install libtinfo5
+          wget https://mirrors.kernel.org/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
+          sudo dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb
       - name: Run all the tests
         env:
           GITHUB_ACTIONS_OS: ${{matrix.os}}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5df0c7b1..61098dea 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -39,7 +39,6 @@ permissions:
 # If there's a prerelease-style suffix to the version, then the release(s)
 # will be marked as a prerelease.
 on:
-  pull_request:
   push:
     tags:
       - '**[0-9]+.[0-9]+.[0-9]+*'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cfecc5ce..9a57f07e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -215,6 +215,7 @@
 --------------------------------------------------------------------------------
 # Unreleased
 ## Added
+- Add support for custom attributes (--with-attribute-custom, #2866)
 ## Changed
 - The `--wrap-static-fns` related options no longer require the experimental feature or flag.
 ## Removed
@@ -237,7 +238,6 @@
 - Add option to use DST structs for flexible arrays (--flexarray-dst, #2772).
 - Add option to dynamically load variables (#2812).
 - Add option in CLI to use rustified non-exhaustive enums (--rustified-non-exhaustive-enum, #2847).
-- Add support for custom attributes (--with-attribute-custom, #2866)
 ## Changed
 - Remove which and lazy-static dependencies (#2809, #2817).
 - Generate compile-time layout tests (#2787).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ff48cf1d..9c28e198 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -54,18 +54,18 @@ We abide by the [Rust Code of Conduct][coc] and ask that you do as well.
 Think you've found a bug? File an issue! To help us understand and reproduce the
 issue, provide us with:
 
-* A (preferably reduced) C/C++ header file that reproduces the issue
-* The `bindgen` flags used to reproduce the issue with the header file
-* The expected `bindgen` output
-* The actual `bindgen` output
-* The [debugging logs](#debug-logging) generated when running `bindgen` on this testcase
+- A (preferably reduced) C/C++ header file that reproduces the issue
+- The `bindgen` flags used to reproduce the issue with the header file
+- The expected `bindgen` output
+- The actual `bindgen` output
+- The [debugging logs](#debug-logging) generated when running `bindgen` on this testcase
 
 ## Looking to Start Contributing to `bindgen`?
 
-* [Issues labeled "easy"](https://github.com/rust-lang/rust-bindgen/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy)
-* [Issues labeled "less easy"](https://github.com/rust-lang/rust-bindgen/issues?q=is%3Aopen+is%3Aissue+label%3AE-less-easy)
-* [Issues labeled "help wanted"](https://github.com/rust-lang/rust-bindgen/labels/help%20wanted)
-* Still can't find something to work on? [Drop a comment here](https://github.com/rust-lang/rust-bindgen/issues/747)
+- [Issues labeled "easy"](https://github.com/rust-lang/rust-bindgen/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy)
+- [Issues labeled "less easy"](https://github.com/rust-lang/rust-bindgen/issues?q=is%3Aopen+is%3Aissue+label%3AE-less-easy)
+- [Issues labeled "help wanted"](https://github.com/rust-lang/rust-bindgen/labels/help%20wanted)
+- Still can't find something to work on? [Drop a comment here](https://github.com/rust-lang/rust-bindgen/issues/747)
 
 ## Prerequisites
 
@@ -82,16 +82,16 @@ To check via command line, you can run `cargo +nightly fmt --check`.
 
 To build the `bindgen` library and the `bindgen` executable:
 
-```
-$ cargo build
+```sh
+cargo build
 ```
 
 If you installed multiple versions of llvm, it may not be able to locate the
-latest version of libclang. In that case, you may want to either uninstall other
-versions of llvm, or specify the path of the desired libclang explicitly:
+latest version of `libclang`. In that case, you may want to either uninstall other
+versions of llvm, or specify the path of the desired `libclang` explicitly:
 
-```
-$ export LIBCLANG_PATH=path/to/clang-9.0/lib
+```sh
+export LIBCLANG_PATH=path/to/clang-9.0/lib
 ```
 
 ## Testing
@@ -107,7 +107,7 @@ There are also some integration tests in the `./bindgen-integration` crate, whic
 generate bindings to some C++ code, and then uses the bindings, asserting that
 values are what we expect them to be, both on the Rust and C++ side.
 
-The generated and expected bindings are formatted with [prettyplease] before they are
+The generated and expected bindings are formatted with [`prettyplease`] before they are
 compared. It is a default (but optional) dependency of `bindgen`,
 so be sure to keep that in mind
 (if you built `bindgen` with the `--no-default-features` option of Cargo).
@@ -118,14 +118,13 @@ Note: running `cargo test` from the root directory of `bindgen`'s repository doe
 automatically test the generated bindings or run the integration tests.
 These steps must be performed manually when needed.
 
-
 ### Testing Bindings Generation
 
 To regenerate bindings from the corpus of test headers in `bindgen-tests/tests/headers` and
 compare them against the expected bindings in `bindgen-tests/tests/expectations/tests`, run:
 
-```
-$ cargo test
+```sh
+cargo test
 ```
 
 As long as you aren't making any changes to `bindgen`'s output, running this
@@ -134,12 +133,12 @@ should be sufficient to test your local modifications.
 You may set the `BINDGEN_OVERWRITE_EXPECTED` environment variable to overwrite
 the expected bindings with `bindgen`'s current output:
 
-```
-$ BINDGEN_OVERWRITE_EXPECTED=1 cargo test
+```sh
+BINDGEN_OVERWRITE_EXPECTED=1 cargo test
 ```
 
-If you set the BINDGEN_TESTS_DIFFTOOL environment variable, `cargo test` will
-execute $BINDGEN_TESTS_DIFFTOOL /path/of/expected/output /path/of/actual/output
+If you set the `BINDGEN_TESTS_DIFFTOOL` environment variable, `cargo test` will
+execute `BINDGEN_TESTS_DIFFTOOL /path/of/expected/output /path/of/actual/output`
 when the expected output differs from the actual output. You can use this to
 hand check differences by setting it to e.g. "meld" (assuming you have meld
 installed).
@@ -157,14 +156,14 @@ pass. Also, run the integration tests (see below).
 
 You can do this with these commands:
 
-```
-$ cd bindgen-tests/tests/expectations
-$ cargo test
+```sh
+cd bindgen-tests/tests/expectations
+cargo test
 ```
 
 ### Testing a Single Header's Bindings Generation and Compiling its Bindings
 
-Note: You will need to install [Graphviz](https://graphviz.org/) since that
+Note: You will need to install [graphviz](https://graphviz.org/) since that
 is a dependency for running `test-one.sh`.
 
 Sometimes it's useful to work with one test header from start (generating
@@ -173,8 +172,8 @@ tests). This can be done with the `bindgen-tests/tests/test-one.sh` script. It s
 searching for test headers. For example, to test
 `tests/headers/what_is_going_on.hpp`, execute this command:
 
-```
-$ ./bindgen-tests/tests/test-one.sh going
+```sh
+./bindgen-tests/tests/test-one.sh going
 ```
 
 Note that `test-one.sh` does not recompile `bindgen`, so if you change the code,
@@ -197,9 +196,9 @@ specify them at the top of the test header, with a comment like this:
 
 Then verify the new Rust bindings compile and pass their layout tests:
 
-```
-$ cd bindgen-tests/tests/expectations
-$ cargo test new_test_header
+```sh
+cd bindgen-tests/tests/expectations
+cargo test new_test_header
 ```
 
 ### Test Expectations and `libclang` Versions
@@ -210,8 +209,8 @@ can add multiple test expectations, one for each supported `libclang`
 version. Instead of having a single `bindgen-tests/tests/expectations/tests/my_test.rs` file,
 add each of:
 
-* `bindgen-tests/tests/expectations/tests/libclang-16/my_test.rs`
-* `bindgen-tests/tests/expectations/tests/libclang-9/my_test.rs`
+- `bindgen-tests/tests/expectations/tests/libclang-16/my_test.rs`
+- `bindgen-tests/tests/expectations/tests/libclang-9/my_test.rs`
 
 If you need to update the test expectations for a test file that generates
 different bindings for different `libclang` versions, you *don't* need to have
@@ -224,8 +223,8 @@ Usually, `bindgen`'s test runner can infer which version of `libclang` you
 have. If for some reason it can't, you can force a specific `libclang` version
 to check the bindings against with a cargo feature:
 
-```
-$ cargo test --features __testing_only_libclang_$VERSION
+```sh
+cargo test --features __testing_only_libclang_$VERSION
 ```
 
 depending on which version of `libclang` you have installed.
@@ -238,9 +237,9 @@ values are what we expect them to be, both on the Rust and C++ side.
 
 To run the integration tests, issue the following:
 
-```
-$ cd bindgen-integration
-$ cargo test
+```sh
+cd bindgen-integration
+cargo test
 ```
 
 ### Fuzzing `bindgen` with `csmith`
@@ -257,7 +256,7 @@ The `tests/quickchecking` crate generates property tests for `bindgen`.
 From the crate's directory you can run the tests with `cargo run`. For details
 on additional configuration including how to preserve / inspect the generated
 property tests, see
-[./tests/quickchecking/README.md](./tests/quickchecking/README.md).
+[`./tests/quickchecking/README.md`](./tests/quickchecking/README.md).
 
 ## Code Overview
 
@@ -274,39 +273,39 @@ The umbrella IR type is the `Item`. It contains various nested `enum`s that let
 us drill down and get more specific about the kind of construct that we're
 looking at. Here is a summary of the IR types and their relationships:
 
-* `Item` contains:
-    * An `ItemId` to uniquely identify it.
-    * An `ItemKind`, which is one of:
-        * A `Module`, which is originally a C++ namespace and becomes a Rust
+- `Item` contains:
+  - An `ItemId` to uniquely identify it.
+  - An `ItemKind`, which is one of:
+    - A `Module`, which is originally a C++ namespace and becomes a Rust
           module. It contains the set of `ItemId`s of `Item`s that are defined
           within it.
-        * A `Type`, which contains:
-            * A `Layout`, describing the type's size and alignment.
-            * A `TypeKind`, which is one of:
-                * Some integer type.
-                * Some float type.
-                * A `Pointer` to another type.
-                * A function pointer type, with `ItemId`s of its parameter types
+    - A `Type`, which contains:
+      - A `Layout`, describing the type's size and alignment.
+      - A `TypeKind`, which is one of:
+        - Some integer type.
+        - Some float type.
+        - A `Pointer` to another type.
+        - A function pointer type, with `ItemId`s of its parameter types
                   and return type.
-                * An `Alias` to another type (`typedef` or `using X = ...`).
-                * A fixed size `Array` of `n` elements of another type.
-                * A `Comp` compound type, which is either a `struct`, `class`,
+        - An `Alias` to another type (`typedef` or `using X = ...`).
+        - A fixed size `Array` of `n` elements of another type.
+        - A `Comp` compound type, which is either a `struct`, `class`,
                   or `union`. This is potentially a template definition.
-                * A `TemplateInstantiation` referencing some template definition
+        - A `TemplateInstantiation` referencing some template definition
                   and a set of template argument types.
-                * Etc...
-        * A `Function`, which contains:
-            * An ABI
-            * A mangled name
-            * a `FunctionKind`, which describes whether this function is a plain
+        - Etc...
+    - A `Function`, which contains:
+      - An ABI
+      - A mangled name
+      - a `FunctionKind`, which describes whether this function is a plain
               function, method, static method, constructor, destructor, etc.
-            * The `ItemId` of its function pointer type.
-        * A `Var` representing a static variable or `#define` constant, which
+      - The `ItemId` of its function pointer type.
+    - A `Var` representing a static variable or `#define` constant, which
           contains:
-            * Its type's `ItemId`
-            * Optionally, a mangled name
-            * Optionally, a value
-    * An optional `clang::SourceLocation` that holds the first source code
+      - Its type's `ItemId`
+      - Optionally, a mangled name
+      - Optionally, a value
+  - An optional `clang::SourceLocation` that holds the first source code
       location where the `Item` was encountered.
 
 The IR forms a graph of interconnected and inter-referencing types and
@@ -323,8 +322,8 @@ parameters a given type uses. The analyses are defined in
 `ir::analysis::MonotoneFramework` trait.
 
 The final phase is generating Rust source text from the analyzed IR, and it is
-defined in `src/codegen/*`. We use the `quote` crate, which provides the `quote!
-{ ... }` macro for quasi-quoting Rust forms. Some options that affect the
+defined in `src/codegen/*`. We use the `quote` crate, which provides the `quote!{ ... }`
+macro for quasi-quoting Rust forms. Some options that affect the
 generated Rust code are implemented using the [`syn`](https://docs.rs/syn) crate.
 
 ### Implementing new options using `syn`
@@ -351,13 +350,13 @@ changes should be squashed into the original commit.
 
 Unsure who to ask for review? Ask any of:
 
-* `@emilio`
-* `@pvdrz`
+- `@emilio`
+- `@pvdrz`
 
 More resources:
 
-* [Servo's GitHub Workflow](https://github.com/servo/servo/wiki/Github-workflow)
-* [Beginner's Guide to Rebasing and Squashing](https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing)
+- [Servo's GitHub Workflow](https://github.com/servo/servo/wiki/Github-workflow)
+- [Beginner's Guide to Rebasing and Squashing](https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing)
 
 ## Generating Graphviz Dot Files
 
@@ -368,22 +367,22 @@ debugging bindgen!
 
 First, make sure you have Graphviz and `dot` installed:
 
-```
-$ brew install graphviz         # OS X
-$ sudo dnf install graphviz     # Fedora
-$ # Etc...
+```sh
+brew install graphviz         # OS X
+sudo dnf install graphviz     # Fedora
+# Etc...
 ```
 
 Then, use the `--emit-ir-graphviz` flag to generate a `dot` file from our IR:
 
-```
-$ cargo run -- example.hpp --emit-ir-graphviz output.dot
+```sh
+cargo run -- example.hpp --emit-ir-graphviz output.dot
 ```
 
 Finally, convert the `dot` file to an image:
 
-```
-$ dot -Tpng output.dot -o output.png
+```sh
+dot -Tpng output.dot -o output.png
 ```
 
 The final result will look something like this:
@@ -395,14 +394,14 @@ The final result will look something like this:
 To help debug what `bindgen` is doing, you can define the environment variable
 `RUST_LOG=bindgen` to get a bunch of debugging log spew.
 
-```
-$ RUST_LOG=bindgen ./target/debug/bindgen [flags...] ~/path/to/some/header.h
+```sh
+RUST_LOG=bindgen ./target/debug/bindgen [flags...] ~/path/to/some/header.h
 ```
 
 This logging can also be used when debugging failing tests:
 
-```
-$ RUST_LOG=bindgen cargo test
+```sh
+RUST_LOG=bindgen cargo test
 ```
 
 ## Using `creduce` to Minimize Test Cases
@@ -419,10 +418,10 @@ that same bad behavior.
 
 Often, you can install `creduce` from your OS's package manager:
 
-```
-$ sudo apt install creduce
-$ brew install creduce
-$ # Etc...
+```sh
+sudo apt install creduce
+brew install creduce
+# Etc...
 ```
 
 Otherwise, follow [these instructions](https://github.com/csmith-project/creduce/blob/master/INSTALL.md) for building and/or installing `creduce`.
@@ -436,7 +435,9 @@ Running `creduce` requires two things:
 
 With those two things in hand, running `creduce` looks like this:
 
-    $ creduce ./predicate.sh ./isolated-test-case.h
+```sh
+creduce ./predicate.sh ./isolated-test-case.h
+```
 
 ### Isolating Your Test Case
 
@@ -511,8 +512,8 @@ path/to/rust-bindgen/csmith-fuzzing/predicate.py \
 
 For details on all the flags that you can pass to `predicate.py`, run:
 
-```
-$ path/to/rust-bindgen/csmith-fuzzing/predicate.py --help
+```sh
+path/to/rust-bindgen/csmith-fuzzing/predicate.py --help
 ```
 
 And you can always write your own, arbitrary predicate script if you prefer.
@@ -535,9 +536,9 @@ To cut a release, the following needs to happen:
 Update the CHANGELOG.md file with the changes from the last release. Something
 like the following is a useful way to check what has landed:
 
- ```
- $ git log --oneline v0.62.0..HEAD
- ```
+```sh
+git log --oneline v0.62.0..HEAD
+```
 
 Also worth checking the [next-release
 tag](https://github.com/rust-lang/rust-bindgen/pulls?q=is%3Apr+label%3Anext-release).
@@ -554,12 +555,14 @@ important fix) you can skip this.
 ### Tag and publish
 
 Once you're in `main`. Remember to install `doctoc` by running:
-```
+
+```sh
 npm install doctoc
 ```
 
 And then run:
-```
+
+```sh
 cargo release [patch|minor] --no-publish --execute
 ```
 
@@ -573,8 +576,8 @@ This does the following:
 
 The `patch` and `minor` refer to semver concepts:
 
-- `patch` would bump __v0.68.1__ to __v0.68.2__
-- `minor` would bump __v0.68.2__ to __v0.69.0__
+- `patch` would bump **v0.68.1** to **v0.68.2**
+- `minor` would bump **v0.68.2** to **v0.69.0**
 
 > NOTE:
 > We use the `--no-publish` so that the crates are only published after the release is complete.
@@ -595,12 +598,12 @@ to avoid notifying watchers of the repo should a CI step fail.
 If everything succeeds,
 tarballs containing bindgen cli executables for Linux and MacOS
 (both for x86 and Arm) will be created.
-See `[workspace.metadata.dist]` section in Cargo.toml for the configuration.
+See `[workspace.metadata.dist]` section in `Cargo.toml` for the configuration.
 
 To update the release configuration,
-when a new cargo-dist is available:
+when a new `cargo-dist` is available:
 
-```
+```sh
 cargo dist init # from "cargo install cargo-dist"
 ```
 
@@ -620,4 +623,4 @@ and run a new workflow using the "Run Workflow" button.
 
 Remember that crates.io releases cannot be deleted!
 
-[prettyplease]: https://github.com/dtolnay/prettyplease
+[`prettyplease`]: https://github.com/dtolnay/prettyplease
diff --git a/Cargo.lock b/Cargo.lock
index 0ea94748..25124418 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -35,6 +35,8 @@ dependencies = [
  "bitflags 2.2.1",
  "cexpr",
  "clang-sys",
+ "clap",
+ "clap_complete",
  "itertools",
  "log",
  "prettyplease",
@@ -51,8 +53,6 @@ name = "bindgen-cli"
 version = "0.70.1"
 dependencies = [
  "bindgen",
- "clap",
- "clap_complete",
  "env_logger 0.10.0",
  "log",
  "proc-macro2",
@@ -72,8 +72,6 @@ name = "bindgen-tests"
 version = "0.1.0"
 dependencies = [
  "bindgen",
- "clap",
- "clap_complete",
  "owo-colors",
  "prettyplease",
  "proc-macro2",
diff --git a/Cargo.toml b/Cargo.toml
index 9170e18f..e0535a1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,6 +14,12 @@ default-members = [
     "bindgen-tests",
 ]
 
+# Dependencies shared between crates
+[workspace.dependencies]
+shlex = "1"
+syn = "2.0" 
+proc-macro2 = { version = "1", default-features = false }
+
 # Config for 'cargo dist'
 [workspace.metadata.dist]
 # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
diff --git a/bindgen-cli/Cargo.toml b/bindgen-cli/Cargo.toml
index d75867b7..2e5bf1b4 100644
--- a/bindgen-cli/Cargo.toml
+++ b/bindgen-cli/Cargo.toml
@@ -21,12 +21,11 @@ name = "bindgen"
 
 [dependencies]
 bindgen = { path = "../bindgen", version = "=0.70.1",  default-features = false, features = ["__cli", "experimental", "prettyplease"] }
-clap = { version = "4", features = ["derive"] }
-clap_complete = "4"
 env_logger = { version = "0.10.0", optional = true }
 log = { version = "0.4", optional = true }
-proc-macro2 = { version = "1", default-features = false }
-shlex = "1"
+
+proc-macro2.workspace = true
+shlex.workspace = true
 
 [features]
 default = ["logging", "runtime"]
diff --git a/bindgen-cli/main.rs b/bindgen-cli/main.rs
index caa47c62..c15aa00f 100644
--- a/bindgen-cli/main.rs
+++ b/bindgen-cli/main.rs
@@ -1,7 +1,6 @@
 use std::env;
 
-mod options;
-use crate::options::builder_from_flags;
+use bindgen::builder_from_flags;
 
 #[cfg(feature = "logging")]
 fn clang_version_check() {
diff --git a/bindgen-integration/Cargo.toml b/bindgen-integration/Cargo.toml
index ccdd1467..cf89e2d9 100644
--- a/bindgen-integration/Cargo.toml
+++ b/bindgen-integration/Cargo.toml
@@ -4,6 +4,7 @@ description = "A package to test various bindgen features"
 version = "0.1.0"
 authors = ["Emilio Cobos Álvarez <emilio@crisal.io>"]
 publish = false
+edition = "2018"
 build = "build.rs"
 
 [build-dependencies]
diff --git a/bindgen/Cargo.toml b/bindgen/Cargo.toml
index cad94d0c..d8b872b7 100644
--- a/bindgen/Cargo.toml
+++ b/bindgen/Cargo.toml
@@ -29,15 +29,18 @@ annotate-snippets = { version = "0.11.4", optional = true }
 bitflags = "2.2.1"
 cexpr = "0.6"
 clang-sys = { version = "1", features = ["clang_11_0"] }
+clap = { version = "4", features = ["derive"], optional = true }
+clap_complete = { version = "4", optional = true}
 itertools = { version = ">=0.10,<0.14", default-features = false }
 log = { version = "0.4", optional = true }
 prettyplease = { version = "0.2.7", optional = true, features = ["verbatim"] }
-proc-macro2 = { version = "1", default-features = false }
 quote = { version = "1", default-features = false }
 regex = { version = "1.5.3", default-features = false, features = ["std", "unicode-perl"] }
 rustc-hash = "1.0.1"
-shlex = "1"
-syn = { version = "2.0", features = ["full", "extra-traits", "visit-mut"] }
+
+proc-macro2.workspace = true
+shlex.workspace = true
+syn = { workspace = true, features = ["full", "extra-traits", "visit-mut"] }
 
 [features]
 default = ["logging", "prettyplease", "runtime"]
@@ -51,7 +54,7 @@ experimental = ["dep:annotate-snippets"]
 ## The following features are for internal use and they shouldn't be used if
 ## you're not hacking on bindgen
 # Features used by `bindgen-cli`
-__cli = []
+__cli = ["dep:clap", "dep:clap_complete"]
 # Features used for CI testing
 __testing_only_extra_assertions = []
 __testing_only_libclang_9 = []
diff --git a/bindgen/codegen/bitfield_unit.rs b/bindgen/codegen/bitfield_unit.rs
index 3411c22e..59c66f8c 100644
--- a/bindgen/codegen/bitfield_unit.rs
+++ b/bindgen/codegen/bitfield_unit.rs
@@ -38,17 +38,6 @@ where
         Self::extract_bit(byte, index)
     }
 
-    #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-
-        Self::extract_bit(byte, index)
-    }
-
     #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
@@ -75,17 +64,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
 
-    #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-
-        *byte = Self::change_bit(*byte, index, val);
-    }
-
     #[inline]
     pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
         debug_assert!(bit_width <= 64);
@@ -111,35 +89,6 @@ where
         val
     }
 
-    #[inline]
-    pub unsafe fn raw_get(
-        this: *const Self,
-        bit_offset: usize,
-        bit_width: u8,
-    ) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <=
-                core::mem::size_of::<Storage>()
-        );
-
-        let mut val = 0;
-
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                val |= 1 << index;
-            }
-        }
-
-        val
-    }
-
     #[inline]
     pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
         debug_assert!(bit_width <= 64);
@@ -160,30 +109,4 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-
-    #[inline]
-    pub unsafe fn raw_set(
-        this: *mut Self,
-        bit_offset: usize,
-        bit_width: u8,
-        val: u64,
-    ) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <=
-                core::mem::size_of::<Storage>()
-        );
-
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
diff --git a/bindgen/codegen/bitfield_unit_raw_ref_macros.rs b/bindgen/codegen/bitfield_unit_raw_ref_macros.rs
new file mode 100644
index 00000000..3411c22e
--- /dev/null
+++ b/bindgen/codegen/bitfield_unit_raw_ref_macros.rs
@@ -0,0 +1,189 @@
+#[repr(C)]
+#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub struct __BindgenBitfieldUnit<Storage> {
+    storage: Storage,
+}
+
+impl<Storage> __BindgenBitfieldUnit<Storage> {
+    #[inline]
+    pub const fn new(storage: Storage) -> Self {
+        Self { storage }
+    }
+}
+
+impl<Storage> __BindgenBitfieldUnit<Storage>
+where
+    Storage: AsRef<[u8]> + AsMut<[u8]>,
+{
+    #[inline]
+    fn extract_bit(byte: u8, index: usize) -> bool {
+        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 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];
+
+        Self::extract_bit(byte, index)
+    }
+
+    #[inline]
+    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
+        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
+
+        let byte_index = index / 8;
+        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
+            .offset(byte_index as isize);
+
+        Self::extract_bit(byte, index)
+    }
+
+    #[inline]
+    fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
+        let bit_index = if cfg!(target_endian = "big") {
+            7 - (index % 8)
+        } else {
+            index % 8
+        };
+
+        let mask = 1 << bit_index;
+        if val {
+            byte | mask
+        } else {
+            byte & !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];
+
+        *byte = Self::change_bit(*byte, index, val);
+    }
+
+    #[inline]
+    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
+        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
+
+        let byte_index = index / 8;
+        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
+            .offset(byte_index as isize);
+
+        *byte = Self::change_bit(*byte, index, val);
+    }
+
+    #[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") {
+                    bit_width as usize - 1 - i
+                } else {
+                    i
+                };
+                val |= 1 << index;
+            }
+        }
+
+        val
+    }
+
+    #[inline]
+    pub unsafe fn raw_get(
+        this: *const Self,
+        bit_offset: usize,
+        bit_width: u8,
+    ) -> u64 {
+        debug_assert!(bit_width <= 64);
+        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
+        debug_assert!(
+            (bit_offset + (bit_width as usize)) / 8 <=
+                core::mem::size_of::<Storage>()
+        );
+
+        let mut val = 0;
+
+        for i in 0..(bit_width as usize) {
+            if Self::raw_get_bit(this, i + bit_offset) {
+                let index = if cfg!(target_endian = "big") {
+                    bit_width as usize - 1 - i
+                } else {
+                    i
+                };
+                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;
+            let index = if cfg!(target_endian = "big") {
+                bit_width as usize - 1 - i
+            } else {
+                i
+            };
+            self.set_bit(index + bit_offset, val_bit_is_set);
+        }
+    }
+
+    #[inline]
+    pub unsafe fn raw_set(
+        this: *mut Self,
+        bit_offset: usize,
+        bit_width: u8,
+        val: u64,
+    ) {
+        debug_assert!(bit_width <= 64);
+        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
+        debug_assert!(
+            (bit_offset + (bit_width as usize)) / 8 <=
+                core::mem::size_of::<Storage>()
+        );
+
+        for i in 0..(bit_width as usize) {
+            let mask = 1 << i;
+            let val_bit_is_set = val & mask == mask;
+            let index = if cfg!(target_endian = "big") {
+                bit_width as usize - 1 - i
+            } else {
+                i
+            };
+            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+        }
+    }
+}
diff --git a/bindgen/codegen/dyngen.rs b/bindgen/codegen/dyngen.rs
index 4b2749ec..e75e11a2 100644
--- a/bindgen/codegen/dyngen.rs
+++ b/bindgen/codegen/dyngen.rs
@@ -83,6 +83,12 @@ impl DynamicItems {
         let init_fields = &self.init_fields;
         let struct_implementation = &self.struct_implementation;
 
+        let library_new = if ctx.options().wrap_unsafe_ops {
+            quote!(unsafe { ::libloading::Library::new(path) })
+        } else {
+            quote!(::libloading::Library::new(path))
+        };
+
         let from_library = if ctx.options().wrap_unsafe_ops {
             quote!(unsafe { Self::from_library(library) })
         } else {
@@ -100,7 +106,7 @@ impl DynamicItems {
                     path: P
                 ) -> Result<Self, ::libloading::Error>
                 where P: AsRef<::std::ffi::OsStr> {
-                    let library = ::libloading::Library::new(path)?;
+                    let library = #library_new?;
                     #from_library
                 }
 
@@ -202,6 +208,7 @@ impl DynamicItems {
         ident: Ident,
         ty: TokenStream,
         is_required: bool,
+        wrap_unsafe_ops: bool,
     ) {
         let member = if is_required {
             quote! { *mut #ty }
@@ -225,15 +232,20 @@ impl DynamicItems {
         });
 
         let ident_str = codegen::helpers::ast_ty::cstr_expr(ident.to_string());
-        self.constructor_inits.push(if is_required {
-            quote! {
-                let #ident = __library.get::<*mut #ty>(#ident_str).map(|sym| *sym)?;
-            }
+
+        let library_get = if wrap_unsafe_ops {
+            quote!(unsafe { __library.get::<*mut #ty>(#ident_str) })
         } else {
-            quote! {
-                let #ident = __library.get::<*mut #ty>(#ident_str).map(|sym| *sym);
-            }
-        });
+            quote!(__library.get::<*mut #ty>(#ident_str))
+        };
+
+        let qmark = if is_required { quote!(?) } else { quote!() };
+
+        let var_get = quote! {
+            let #ident = #library_get.map(|sym| *sym)#qmark;
+        };
+
+        self.constructor_inits.push(var_get);
 
         self.init_fields.push(quote! {
             #ident
diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs
index c6e33642..ccc5758a 100644
--- a/bindgen/codegen/mod.rs
+++ b/bindgen/codegen/mod.rs
@@ -808,6 +808,7 @@ impl CodeGenerator for Var {
                         .to_rust_ty_or_opaque(ctx, &())
                         .into_token_stream(),
                     ctx.options().dynamic_link_require_all,
+                    ctx.options().wrap_unsafe_ops,
                 );
             } else {
                 result.push(tokens);
@@ -1099,13 +1100,21 @@ impl CodeGenerator for Type {
                     });
                 }
 
-                let access_spec =
-                    access_specifier(ctx.options().default_visibility);
                 tokens.append_all(match alias_style {
                     AliasVariation::TypeAlias => quote! {
                         = #inner_rust_type ;
                     },
                     AliasVariation::NewType | AliasVariation::NewTypeDeref => {
+                        let visibility = ctx
+                            .options()
+                            .last_callback(|cb| {
+                                cb.field_visibility(FieldInfo {
+                                    type_name: &item.canonical_name(ctx),
+                                    field_name: "0",
+                                })
+                            })
+                            .unwrap_or(ctx.options().default_visibility);
+                        let access_spec = access_specifier(visibility);
                         quote! {
                             (#access_spec #inner_rust_type) ;
                         }
@@ -1999,31 +2008,35 @@ impl<'a> FieldCodegen<'a> for Bitfield {
                         )
                     }
                 }
+            }));
 
-                #[inline]
-                #access_spec unsafe fn #raw_getter_name(this: *const Self) -> #bitfield_ty {
-                    unsafe {
-                        ::#prefix::mem::transmute(<#unit_field_ty>::raw_get(
-                            (*::#prefix::ptr::addr_of!((*this).#unit_field_ident)).as_ref() as *const _,
-                            #offset,
-                            #width,
-                        ) as #bitfield_int_ty)
+            if ctx.options().rust_features.raw_ref_macros {
+                methods.extend(Some(quote! {
+                    #[inline]
+                    #access_spec unsafe fn #raw_getter_name(this: *const Self) -> #bitfield_ty {
+                        unsafe {
+                            ::#prefix::mem::transmute(<#unit_field_ty>::raw_get(
+                                (*::#prefix::ptr::addr_of!((*this).#unit_field_ident)).as_ref() as *const _,
+                                #offset,
+                                #width,
+                            ) as #bitfield_int_ty)
+                        }
                     }
-                }
 
-                #[inline]
-                #access_spec unsafe fn #raw_setter_name(this: *mut Self, val: #bitfield_ty) {
-                    unsafe {
-                        let val: #bitfield_int_ty = ::#prefix::mem::transmute(val);
-                        <#unit_field_ty>::raw_set(
-                            (*::#prefix::ptr::addr_of_mut!((*this).#unit_field_ident)).as_mut() as *mut _,
-                            #offset,
-                            #width,
-                            val as u64,
-                        )
+                    #[inline]
+                    #access_spec unsafe fn #raw_setter_name(this: *mut Self, val: #bitfield_ty) {
+                        unsafe {
+                            let val: #bitfield_int_ty = ::#prefix::mem::transmute(val);
+                            <#unit_field_ty>::raw_set(
+                                (*::#prefix::ptr::addr_of_mut!((*this).#unit_field_ident)).as_mut() as *mut _,
+                                #offset,
+                                #width,
+                                val as u64,
+                            )
+                        }
                     }
-                }
-            }));
+                }));
+            }
         } else {
             methods.extend(Some(quote! {
                 #[inline]
@@ -2047,7 +2060,10 @@ impl<'a> FieldCodegen<'a> for Bitfield {
                         )
                     }
                 }
+            }));
 
+            if ctx.options().rust_features.raw_ref_macros {
+                methods.extend(Some(quote! {
                 #[inline]
                 #access_spec unsafe fn #raw_getter_name(this: *const Self) -> #bitfield_ty {
                     unsafe {
@@ -2072,6 +2088,7 @@ impl<'a> FieldCodegen<'a> for Bitfield {
                     }
                 }
             }));
+            }
         }
     }
 }
@@ -4130,7 +4147,7 @@ where
 /// ### Fallible vs. Infallible Conversions to Rust Types
 ///
 /// When should one use this infallible `ToRustTyOrOpaque` trait versus the
-/// fallible `TryTo{RustTy, Opaque, RustTyOrOpaque}` triats? All fallible trait
+/// fallible `TryTo{RustTy, Opaque, RustTyOrOpaque}` traits? All fallible trait
 /// implementations that need to convert another thing into a Rust type or
 /// opaque blob in a nested manner should also use fallible trait methods and
 /// propagate failure up the stack. Only infallible functions and methods like
@@ -5293,7 +5310,12 @@ pub(crate) mod utils {
             return;
         }
 
-        let bitfield_unit_src = include_str!("./bitfield_unit.rs");
+        let bitfield_unit_src = if ctx.options().rust_features().raw_ref_macros
+        {
+            include_str!("./bitfield_unit_raw_ref_macros.rs")
+        } else {
+            include_str!("./bitfield_unit.rs")
+        };
         let bitfield_unit_src = if ctx.options().rust_features().min_const_fn {
             Cow::Borrowed(bitfield_unit_src)
         } else {
diff --git a/bindgen/features.rs b/bindgen/features.rs
index 990e4513..e67b00f0 100644
--- a/bindgen/features.rs
+++ b/bindgen/features.rs
@@ -104,6 +104,7 @@ define_rust_targets! {
     Stable_1_71(71) => { c_unwind_abi: #106075 },
     Stable_1_68(68) => { abi_efiapi: #105795 },
     Stable_1_64(64) => { core_ffi_c: #94503 },
+    Stable_1_51(51) => { raw_ref_macros: #80886 },
     Stable_1_59(59) => { const_cstr: #54745 },
     Stable_1_47(47) => { larger_arrays: #74060 },
     Stable_1_43(43) => { associated_constants: #68952 },
diff --git a/bindgen/lib.rs b/bindgen/lib.rs
index 1a9932b5..134e3d6d 100644
--- a/bindgen/lib.rs
+++ b/bindgen/lib.rs
@@ -50,12 +50,11 @@ mod regex_set;
 pub use codegen::{
     AliasVariation, EnumVariation, MacroTypeVariation, NonCopyUnionStyle,
 };
-#[cfg(feature = "__cli")]
-pub use features::RUST_TARGET_STRINGS;
 pub use features::{RustTarget, LATEST_STABLE_RUST};
 pub use ir::annotations::FieldVisibilityKind;
 pub use ir::function::Abi;
-pub use regex_set::RegexSet;
+#[cfg(feature = "__cli")]
+pub use options::cli::builder_from_flags;
 
 use codegen::CodegenError;
 use features::RustFeatures;
diff --git a/bindgen/options/as_args.rs b/bindgen/options/as_args.rs
index 6918ad9f..83103fda 100644
--- a/bindgen/options/as_args.rs
+++ b/bindgen/options/as_args.rs
@@ -1,6 +1,6 @@
 use std::path::PathBuf;
 
-use crate::RegexSet;
+use crate::regex_set::RegexSet;
 
 /// Trait used to turn [`crate::BindgenOptions`] fields into CLI args.
 pub(super) trait AsArgs {
diff --git a/bindgen-cli/options.rs b/bindgen/options/cli.rs
similarity index 71%
rename from bindgen-cli/options.rs
rename to bindgen/options/cli.rs
index ad96664b..747ff2d5 100644
--- a/bindgen-cli/options.rs
+++ b/bindgen/options/cli.rs
@@ -1,17 +1,23 @@
-use bindgen::callbacks::TypeKind;
-use bindgen::{
-    builder, Abi, AliasVariation, Builder, CodegenConfig, EnumVariation,
+use crate::{
+    builder,
+    callbacks::{
+        AttributeInfo, DeriveInfo, ItemInfo, ParseCallbacks, TypeKind,
+    },
+    features::RUST_TARGET_STRINGS,
+    regex_set::RegexSet,
+    Abi, AliasVariation, Builder, CodegenConfig, EnumVariation,
     FieldVisibilityKind, Formatter, MacroTypeVariation, NonCopyUnionStyle,
-    RegexSet, RustTarget, DEFAULT_ANON_FIELDS_PREFIX, RUST_TARGET_STRINGS,
+    RustTarget,
+};
+use clap::{
+    error::{Error, ErrorKind},
+    CommandFactory, Parser,
 };
-use clap::error::{Error, ErrorKind};
-use clap::{CommandFactory, Parser};
 use proc_macro2::TokenStream;
-use std::fs::File;
 use std::io;
 use std::path::{Path, PathBuf};
-use std::process::exit;
 use std::str::FromStr;
+use std::{fs::File, process::exit};
 
 fn rust_target_help() -> String {
     format!(
@@ -134,7 +140,7 @@ fn parse_custom_attribute(
 )]
 struct BindgenCommand {
     /// C or C++ header file.
-    header: Option<String>,
+    header: String,
     /// Path to write depfile to.
     #[arg(long)]
     depfile: Option<String>,
@@ -265,8 +271,8 @@ struct BindgenCommand {
     #[arg(long, value_name = "PREFIX")]
     ctypes_prefix: Option<String>,
     /// Use the given PREFIX for anonymous fields.
-    #[arg(long, default_value = DEFAULT_ANON_FIELDS_PREFIX, value_name = "PREFIX")]
-    anon_fields_prefix: String,
+    #[arg(long, value_name = "PREFIX")]
+    anon_fields_prefix: Option<String>,
     /// Time the different bindgen phases and print to stderr
     #[arg(long)]
     time_phases: bool,
@@ -491,6 +497,7 @@ struct BindgenCommand {
     #[arg(long, value_name = "VISIBILITY")]
     default_visibility: Option<FieldVisibilityKind>,
     /// Whether to emit diagnostics or not.
+    #[cfg(feature = "experimental")]
     #[arg(long, requires = "experimental")]
     emit_diagnostics: bool,
     /// Generates completions for the specified SHELL, sends them to `stdout` and exits.
@@ -633,6 +640,7 @@ where
         wrap_static_fns_path,
         wrap_static_fns_suffix,
         default_visibility,
+        #[cfg(feature = "experimental")]
         emit_diagnostics,
         generate_shell_completions,
         experimental: _,
@@ -640,290 +648,284 @@ where
         clang_args,
     } = command;
 
-    if let Some(shell) = generate_shell_completions {
-        clap_complete::generate(
-            shell,
-            &mut BindgenCommand::command(),
-            "bindgen",
-            &mut std::io::stdout(),
-        );
-
-        exit(0);
-    }
-
-    if version {
-        println!(
-            "bindgen {}",
-            option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
-        );
-        if verbose {
-            println!("Clang: {}", bindgen::clang_version().full);
-        }
-        std::process::exit(0);
-    }
-
     let mut builder = builder();
 
-    if let Some(header) = header {
-        builder = builder.header(header);
-    } else {
-        return Err(io::Error::new(io::ErrorKind::Other, "Header not found"));
-    }
-
-    if let Some(rust_target) = rust_target {
-        builder = builder.rust_target(rust_target);
-    }
-
-    if let Some(variant) = default_enum_style {
-        builder = builder.default_enum_style(variant);
-    }
-
-    for regex in bitfield_enum {
-        builder = builder.bitfield_enum(regex);
-    }
-
-    for regex in newtype_enum {
-        builder = builder.newtype_enum(regex);
-    }
-
-    for regex in newtype_global_enum {
-        builder = builder.newtype_global_enum(regex);
-    }
-
-    for regex in rustified_enum {
-        builder = builder.rustified_enum(regex);
-    }
-
-    for regex in rustified_non_exhaustive_enum {
-        builder = builder.rustified_non_exhaustive_enum(regex);
-    }
-
-    for regex in constified_enum {
-        builder = builder.constified_enum(regex);
-    }
-
-    for regex in constified_enum_module {
-        builder = builder.constified_enum_module(regex);
-    }
-
-    if let Some(default_macro_constant_type) = default_macro_constant_type {
-        builder =
-            builder.default_macro_constant_type(default_macro_constant_type)
-    }
-
-    if let Some(variant) = default_alias_style {
-        builder = builder.default_alias_style(variant);
-    }
-
-    for regex in normal_alias {
-        builder = builder.type_alias(regex);
-    }
-
-    for regex in new_type_alias {
-        builder = builder.new_type_alias(regex);
-    }
-
-    for regex in new_type_alias_deref {
-        builder = builder.new_type_alias_deref(regex);
-    }
-
-    if let Some(variant) = default_non_copy_union_style {
-        builder = builder.default_non_copy_union_style(variant);
-    }
-
-    for regex in bindgen_wrapper_union {
-        builder = builder.bindgen_wrapper_union(regex);
-    }
-
-    for regex in manually_drop_union {
-        builder = builder.manually_drop_union(regex);
-    }
-
-    for ty in blocklist_type {
-        builder = builder.blocklist_type(ty);
-    }
-
-    for fun in blocklist_function {
-        builder = builder.blocklist_function(fun);
-    }
-
-    for id in blocklist_item {
-        builder = builder.blocklist_item(id);
-    }
-
-    for file in blocklist_file {
-        builder = builder.blocklist_file(file);
-    }
-
-    for var in blocklist_var {
-        builder = builder.blocklist_var(var);
-    }
-
-    if builtins {
-        builder = builder.emit_builtins();
-    }
-
-    if no_layout_tests {
-        builder = builder.layout_tests(false);
-    }
-
-    if no_derive_copy {
-        builder = builder.derive_copy(false);
-    }
-
-    if no_derive_debug {
-        builder = builder.derive_debug(false);
-    }
-
-    if impl_debug {
-        builder = builder.impl_debug(true);
-    }
-
-    if impl_partialeq {
-        builder = builder.impl_partialeq(true);
-    }
-
-    if with_derive_default {
-        builder = builder.derive_default(true);
-    }
-
-    if with_derive_hash {
-        builder = builder.derive_hash(true);
-    }
-
-    if with_derive_partialeq {
-        builder = builder.derive_partialeq(true);
-    }
-
-    if with_derive_partialord {
-        builder = builder.derive_partialord(true);
-    }
-
-    if with_derive_eq {
-        builder = builder.derive_eq(true);
-    }
-
-    if with_derive_ord {
-        builder = builder.derive_ord(true);
-    }
-
-    if no_derive_default {
-        builder = builder.derive_default(false);
-    }
-
-    if no_prepend_enum_name {
-        builder = builder.prepend_enum_name(false);
-    }
-
-    if no_include_path_detection {
-        builder = builder.detect_include_paths(false);
-    }
-
-    if fit_macro_constant_types {
-        builder = builder.fit_macro_constants(true);
-    }
-
-    if time_phases {
-        builder = builder.time_phases(true);
-    }
-
-    if use_array_pointers_in_arguments {
-        builder = builder.array_pointers_in_arguments(true);
-    }
-
-    if let Some(wasm_import_name) = wasm_import_module_name {
-        builder = builder.wasm_import_module_name(wasm_import_name);
-    }
-
-    if let Some(prefix) = ctypes_prefix {
-        builder = builder.ctypes_prefix(prefix);
-    }
-
-    builder = builder.anon_fields_prefix(anon_fields_prefix);
-
-    if let Some(config) = generate {
-        builder = builder.with_codegen_config(config);
-    }
-
-    if emit_clang_ast {
-        builder = builder.emit_clang_ast();
-    }
-
-    if emit_ir {
-        builder = builder.emit_ir();
-    }
-
-    if let Some(path) = emit_ir_graphviz {
-        builder = builder.emit_ir_graphviz(path);
+    #[derive(Debug)]
+    struct PrefixLinkNameCallback {
+        prefix: String,
     }
 
-    if enable_cxx_namespaces {
-        builder = builder.enable_cxx_namespaces();
+    impl ParseCallbacks for PrefixLinkNameCallback {
+        fn generated_link_name_override(
+            &self,
+            item_info: ItemInfo<'_>,
+        ) -> Option<String> {
+            let mut prefix = self.prefix.clone();
+            prefix.push_str(item_info.name);
+            Some(prefix)
+        }
     }
 
-    if enable_function_attribute_detection {
-        builder = builder.enable_function_attribute_detection();
+    #[derive(Debug)]
+    struct CustomDeriveCallback {
+        derives: Vec<String>,
+        kind: Option<TypeKind>,
+        regex_set: RegexSet,
     }
 
-    if disable_name_namespacing {
-        builder = builder.disable_name_namespacing();
-    }
+    impl ParseCallbacks for CustomDeriveCallback {
+        fn cli_args(&self) -> Vec<String> {
+            let mut args = vec![];
 
-    if disable_nested_struct_naming {
-        builder = builder.disable_nested_struct_naming();
-    }
+            let flag = match &self.kind {
+                None => "--with-derive-custom",
+                Some(TypeKind::Struct) => "--with-derive-custom-struct",
+                Some(TypeKind::Enum) => "--with-derive-custom-enum",
+                Some(TypeKind::Union) => "--with-derive-custom-union",
+            };
 
-    if disable_untagged_union {
-        builder = builder.disable_untagged_union();
-    }
+            let derives = self.derives.join(",");
 
-    if disable_header_comment {
-        builder = builder.disable_header_comment();
-    }
+            for item in self.regex_set.get_items() {
+                args.extend_from_slice(&[
+                    flag.to_owned(),
+                    format!("{}={}", item, derives),
+                ]);
+            }
 
-    if ignore_functions {
-        builder = builder.ignore_functions();
-    }
+            args
+        }
 
-    if ignore_methods {
-        builder = builder.ignore_methods();
+        fn add_derives(&self, info: &DeriveInfo<'_>) -> Vec<String> {
+            if self.kind.map(|kind| kind == info.kind).unwrap_or(true) &&
+                self.regex_set.matches(info.name)
+            {
+                return self.derives.clone();
+            }
+            vec![]
+        }
     }
 
-    if no_convert_floats {
-        builder = builder.no_convert_floats();
+    #[derive(Debug)]
+    struct CustomAttributeCallback {
+        attributes: Vec<String>,
+        kind: Option<TypeKind>,
+        regex_set: RegexSet,
     }
 
-    if no_doc_comments {
-        builder = builder.generate_comments(false);
-    }
+    impl ParseCallbacks for CustomAttributeCallback {
+        fn cli_args(&self) -> Vec<String> {
+            let mut args = vec![];
 
-    if no_recursive_allowlist {
-        builder = builder.allowlist_recursively(false);
-    }
+            let flag = match &self.kind {
+                None => "--with-attribute-custom",
+                Some(TypeKind::Struct) => "--with-attribute-custom-struct",
+                Some(TypeKind::Enum) => "--with-attribute-custom-enum",
+                Some(TypeKind::Union) => "--with-attribute-custom-union",
+            };
 
-    if objc_extern_crate {
-        builder = builder.objc_extern_crate(true);
-    }
+            let attributes = self.attributes.join(",");
 
-    if generate_block {
-        builder = builder.generate_block(true);
-    }
+            for item in self.regex_set.get_items() {
+                args.extend_from_slice(&[
+                    flag.to_owned(),
+                    format!("{}={}", item, attributes),
+                ]);
+            }
 
-    if generate_cstr {
-        builder = builder.generate_cstr(true);
-    }
+            args
+        }
 
-    if block_extern_crate {
-        builder = builder.block_extern_crate(true);
+        fn add_attributes(&self, info: &AttributeInfo<'_>) -> Vec<String> {
+            if self.kind.map(|kind| kind == info.kind).unwrap_or(true) &&
+                self.regex_set.matches(info.name)
+            {
+                return self.attributes.clone();
+            }
+            vec![]
+        }
     }
 
-    for ty in opaque_type {
-        builder = builder.opaque_type(ty);
+    /// Macro used to apply CLI arguments to a builder.
+    ///
+    /// This is done by passing an identifier for each argument and a function to be applied over
+    /// the builder. For example:
+    /// ```rust,ignore
+    /// fn apply_arg(builder: Builder, arg_value: Value) -> Builder {
+    ///     todo!()
+    /// }
+    ///
+    /// apply_args!(
+    ///     builder {
+    ///         arg => apply_arg,
+    ///     }
+    /// );
+    /// ```
+    ///
+    /// If the identifier of the argument is the same as an already existing builder method then
+    /// you can omit the second part:
+    /// ```rust,ignore
+    /// apply_args!(
+    ///     builder {
+    ///         arg
+    ///     }
+    /// );
+    /// ```
+    /// Which expands to the same code as:
+    /// ```rust,ignore
+    /// apply_args!(
+    ///     builder {
+    ///         arg => Builder::arg,
+    ///     }
+    /// );
+    /// ```
+    macro_rules! apply_args {
+        ($builder:ident {}) => { $builder };
+        ($builder:ident {$arg:ident => $function:expr, $($token:tt)*}) => {
+            {
+                $builder = CliArg::apply($arg, $builder, $function);
+                apply_args!($builder {$($token)*})
+            }
+        };
+        ($builder:ident {$arg:ident, $($token:tt)*}) => {
+            {
+                $builder = CliArg::apply($arg, $builder, Builder::$arg);
+                apply_args!($builder {$($token)*})
+            }
+        }
     }
 
-    for line in raw_line {
-        builder = builder.raw_line(line);
-    }
+    let header = Some(header);
+
+    builder = apply_args!(
+        builder {
+            generate_shell_completions => |_, shell| {
+                clap_complete::generate(
+                    shell,
+                    &mut BindgenCommand::command(),
+                    "bindgen",
+                    &mut std::io::stdout(),
+                );
+
+                exit(0)
+            },
+            version => |_, _| {
+                println!(
+                    "bindgen {}",
+                    option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
+                );
+                if verbose {
+                    println!("Clang: {}", crate::clang_version().full);
+                }
+
+                exit(0)
+            },
+            header,
+            rust_target,
+            default_enum_style,
+            bitfield_enum,
+            newtype_enum,
+            newtype_global_enum,
+            rustified_enum,
+            rustified_non_exhaustive_enum,
+            constified_enum,
+            constified_enum_module,
+            default_macro_constant_type,
+            default_alias_style,
+            normal_alias => Builder::type_alias,
+            new_type_alias,
+            new_type_alias_deref,
+            default_non_copy_union_style,
+            bindgen_wrapper_union,
+            manually_drop_union,
+            blocklist_type,
+            blocklist_function,
+            blocklist_item,
+            blocklist_file,
+            blocklist_var,
+            builtins => |b, _| b.emit_builtins(),
+            no_layout_tests => |b, _| b.layout_tests(false),
+            no_derive_copy => |b, _| b.derive_copy(false),
+            no_derive_debug => |b, _| b.derive_debug(false),
+            impl_debug,
+            impl_partialeq,
+            with_derive_default => Builder::derive_default,
+            with_derive_hash => Builder::derive_hash,
+            with_derive_partialeq => Builder::derive_partialeq,
+            with_derive_partialord => Builder::derive_partialord,
+            with_derive_eq => Builder::derive_eq,
+            with_derive_ord => Builder::derive_ord,
+            no_derive_default => |b, _| b.derive_default(false),
+            no_prepend_enum_name => |b, _| b.prepend_enum_name(false),
+            no_include_path_detection => |b, _| b.detect_include_paths(false),
+            fit_macro_constant_types => Builder::fit_macro_constants,
+            time_phases,
+            use_array_pointers_in_arguments => Builder::array_pointers_in_arguments,
+            wasm_import_module_name,
+            ctypes_prefix,
+            anon_fields_prefix,
+            generate => Builder::with_codegen_config,
+            emit_clang_ast => |b, _| b.emit_clang_ast(),
+            emit_ir => |b, _| b.emit_ir(),
+            emit_ir_graphviz,
+            enable_cxx_namespaces => |b, _| b.enable_cxx_namespaces(),
+            enable_function_attribute_detection => |b, _| b.enable_function_attribute_detection(),
+            disable_name_namespacing => |b, _| b.disable_name_namespacing(),
+            disable_nested_struct_naming => |b, _| b.disable_nested_struct_naming(),
+            disable_untagged_union => |b, _| b.disable_untagged_union(),
+            disable_header_comment => |b, _| b.disable_header_comment(),
+            ignore_functions => |b, _| b.ignore_functions(),
+            ignore_methods => |b, _| b.ignore_methods(),
+            no_convert_floats => |b, _| b.no_convert_floats(),
+            no_doc_comments => |b, _| b.generate_comments(false),
+            no_recursive_allowlist => |b, _| b.allowlist_recursively(false),
+            objc_extern_crate,
+            generate_block,
+            generate_cstr,
+            block_extern_crate,
+            opaque_type,
+            raw_line,
+            use_core => |b, _| b.use_core(),
+            distrust_clang_mangling => |b, _| b.trust_clang_mangling(false),
+            conservative_inline_namespaces => |b, _| b.conservative_inline_namespaces(),
+            generate_inline_functions,
+            allowlist_function,
+            allowlist_type,
+            allowlist_var,
+            allowlist_file,
+            allowlist_item,
+            clang_args => Builder::clang_arg,
+            no_record_matches => |b, _| b.record_matches(false),
+            no_size_t_is_usize => |b, _| b.size_t_is_usize(false),
+            no_rustfmt_bindings => |b, _| b.formatter(Formatter::None),
+            formatter,
+            no_partialeq,
+            no_copy,
+            no_debug,
+            no_default,
+            no_hash,
+            must_use_type,
+            dynamic_loading => Builder::dynamic_library_name,
+            dynamic_link_require_all,
+            prefix_link_name => |b, prefix| b.parse_callbacks(Box::new(PrefixLinkNameCallback { prefix })),
+            respect_cxx_access_specs,
+            translate_enum_integer_types,
+            c_naming,
+            explicit_padding,
+            vtable_generation,
+            sort_semantically,
+            merge_extern_blocks,
+            override_abi => |b, (abi, regex)| b.override_abi(abi, regex),
+            wrap_unsafe_ops,
+            clang_macro_fallback => |b, _| b.clang_macro_fallback(),
+            clang_macro_fallback_build_dir,
+            flexarray_dst,
+            wrap_static_fns,
+            wrap_static_fns_path,
+            wrap_static_fns_suffix,
+            default_visibility,
+        }
+    );
 
     let mut values = module_raw_line.into_iter();
     while let Some(module) = values.next() {
@@ -931,46 +933,6 @@ where
         builder = builder.module_raw_line(module, line);
     }
 
-    if use_core {
-        builder = builder.use_core();
-    }
-
-    if distrust_clang_mangling {
-        builder = builder.trust_clang_mangling(false);
-    }
-
-    if conservative_inline_namespaces {
-        builder = builder.conservative_inline_namespaces();
-    }
-
-    if generate_inline_functions {
-        builder = builder.generate_inline_functions(true);
-    }
-
-    for regex in allowlist_function {
-        builder = builder.allowlist_function(regex);
-    }
-
-    for regex in allowlist_type {
-        builder = builder.allowlist_type(regex);
-    }
-
-    for regex in allowlist_var {
-        builder = builder.allowlist_var(regex);
-    }
-
-    for file in allowlist_file {
-        builder = builder.allowlist_file(file);
-    }
-
-    for item in allowlist_item {
-        builder = builder.allowlist_item(item);
-    }
-
-    for arg in clang_args {
-        builder = builder.clang_arg(arg);
-    }
-
     let output = if let Some(path) = &output {
         let file = File::create(path)?;
         if let Some(depfile) = depfile {
@@ -988,172 +950,11 @@ where
         builder.dump_preprocessed_input()?;
     }
 
-    if no_record_matches {
-        builder = builder.record_matches(false);
-    }
-
-    if no_size_t_is_usize {
-        builder = builder.size_t_is_usize(false);
-    }
-
-    if no_rustfmt_bindings {
-        builder = builder.formatter(Formatter::None);
-    }
-
-    if let Some(formatter) = formatter {
-        builder = builder.formatter(formatter);
-    }
-
     if let Some(path) = rustfmt_configuration_file {
         builder = builder.rustfmt_configuration_file(Some(path));
     }
 
-    for regex in no_partialeq {
-        builder = builder.no_partialeq(regex);
-    }
-
-    for regex in no_copy {
-        builder = builder.no_copy(regex);
-    }
-
-    for regex in no_debug {
-        builder = builder.no_debug(regex);
-    }
-
-    for regex in no_default {
-        builder = builder.no_default(regex);
-    }
-
-    for regex in no_hash {
-        builder = builder.no_hash(regex);
-    }
-
-    for regex in must_use_type {
-        builder = builder.must_use_type(regex);
-    }
-
-    if let Some(dynamic_library_name) = dynamic_loading {
-        builder = builder.dynamic_library_name(dynamic_library_name);
-    }
-
-    if dynamic_link_require_all {
-        builder = builder.dynamic_link_require_all(true);
-    }
-
-    if let Some(prefix_link_name) = prefix_link_name {
-        #[derive(Debug)]
-        struct PrefixLinkNameCallback {
-            prefix: String,
-        }
-
-        impl bindgen::callbacks::ParseCallbacks for PrefixLinkNameCallback {
-            fn generated_link_name_override(
-                &self,
-                item_info: bindgen::callbacks::ItemInfo<'_>,
-            ) -> Option<String> {
-                let mut prefix = self.prefix.clone();
-                prefix.push_str(item_info.name);
-                Some(prefix)
-            }
-        }
-
-        builder = builder.parse_callbacks(Box::new(PrefixLinkNameCallback {
-            prefix: prefix_link_name,
-        }))
-    }
-
-    if respect_cxx_access_specs {
-        builder = builder.respect_cxx_access_specs(true);
-    }
-
-    if translate_enum_integer_types {
-        builder = builder.translate_enum_integer_types(true);
-    }
-
-    if c_naming {
-        builder = builder.c_naming(true);
-    }
-
-    if explicit_padding {
-        builder = builder.explicit_padding(true);
-    }
-
-    if vtable_generation {
-        builder = builder.vtable_generation(true);
-    }
-
-    if sort_semantically {
-        builder = builder.sort_semantically(true);
-    }
-
-    if merge_extern_blocks {
-        builder = builder.merge_extern_blocks(true);
-    }
-
-    for (abi, regex) in override_abi {
-        builder = builder.override_abi(abi, regex);
-    }
-
-    if wrap_unsafe_ops {
-        builder = builder.wrap_unsafe_ops(true);
-    }
-
-    if clang_macro_fallback {
-        builder = builder.clang_macro_fallback();
-    }
-
-    if let Some(path) = clang_macro_fallback_build_dir {
-        builder = builder.clang_macro_fallback_build_dir(path);
-    }
-
-    if flexarray_dst {
-        builder = builder.flexarray_dst(true);
-    }
-
-    #[derive(Debug)]
-    struct CustomDeriveCallback {
-        derives: Vec<String>,
-        kind: Option<TypeKind>,
-        regex_set: bindgen::RegexSet,
-    }
-
-    impl bindgen::callbacks::ParseCallbacks for CustomDeriveCallback {
-        fn cli_args(&self) -> Vec<String> {
-            let mut args = vec![];
-
-            let flag = match &self.kind {
-                None => "--with-derive-custom",
-                Some(TypeKind::Struct) => "--with-derive-custom-struct",
-                Some(TypeKind::Enum) => "--with-derive-custom-enum",
-                Some(TypeKind::Union) => "--with-derive-custom-union",
-            };
-
-            let derives = self.derives.join(",");
-
-            for item in self.regex_set.get_items() {
-                args.extend_from_slice(&[
-                    flag.to_owned(),
-                    format!("{}={}", item, derives),
-                ]);
-            }
-
-            args
-        }
-
-        fn add_derives(
-            &self,
-            info: &bindgen::callbacks::DeriveInfo<'_>,
-        ) -> Vec<String> {
-            if self.kind.map(|kind| kind == info.kind).unwrap_or(true) &&
-                self.regex_set.matches(info.name)
-            {
-                return self.derives.clone();
-            }
-            vec![]
-        }
-    }
-
-    for (custom_derives, kind, name) in [
+    for (custom_derives, kind, _name) in [
         (with_derive_custom, None, "--with-derive-custom"),
         (
             with_derive_custom_struct,
@@ -1171,11 +972,17 @@ where
             "--with-derive-custom-union",
         ),
     ] {
-        let name = emit_diagnostics.then_some(name);
+        #[cfg(feature = "experimental")]
+        let name = emit_diagnostics.then_some(_name);
+
         for (derives, regex) in custom_derives {
-            let mut regex_set = RegexSet::new();
+            let mut regex_set = RegexSet::default();
             regex_set.insert(regex);
+
+            #[cfg(feature = "experimental")]
             regex_set.build_with_diagnostics(false, name);
+            #[cfg(not(feature = "experimental"))]
+            regex_set.build(false);
 
             builder = builder.parse_callbacks(Box::new(CustomDeriveCallback {
                 derives,
@@ -1185,50 +992,7 @@ where
         }
     }
 
-    #[derive(Debug)]
-    struct CustomAttributeCallback {
-        attributes: Vec<String>,
-        kind: Option<TypeKind>,
-        regex_set: bindgen::RegexSet,
-    }
-
-    impl bindgen::callbacks::ParseCallbacks for CustomAttributeCallback {
-        fn cli_args(&self) -> Vec<String> {
-            let mut args = vec![];
-
-            let flag = match &self.kind {
-                None => "--with-attribute-custom",
-                Some(TypeKind::Struct) => "--with-attribute-custom-struct",
-                Some(TypeKind::Enum) => "--with-attribute-custom-enum",
-                Some(TypeKind::Union) => "--with-attribute-custom-union",
-            };
-
-            let attributes = self.attributes.join(",");
-
-            for item in self.regex_set.get_items() {
-                args.extend_from_slice(&[
-                    flag.to_owned(),
-                    format!("{}={}", item, attributes),
-                ]);
-            }
-
-            args
-        }
-
-        fn add_attributes(
-            &self,
-            info: &bindgen::callbacks::AttributeInfo<'_>,
-        ) -> Vec<String> {
-            if self.kind.map(|kind| kind == info.kind).unwrap_or(true) &&
-                self.regex_set.matches(info.name)
-            {
-                return self.attributes.clone();
-            }
-            vec![]
-        }
-    }
-
-    for (custom_attributes, kind, name) in [
+    for (custom_attributes, kind, _name) in [
         (with_attribute_custom, None, "--with-attribute-custom"),
         (
             with_attribute_custom_struct,
@@ -1246,11 +1010,17 @@ where
             "--with-attribute-custom-union",
         ),
     ] {
-        let name = emit_diagnostics.then_some(name);
+        #[cfg(feature = "experimental")]
+        let name = emit_diagnostics.then_some(_name);
+
         for (attributes, regex) in custom_attributes {
-            let mut regex_set = RegexSet::new();
+            let mut regex_set = RegexSet::default();
             regex_set.insert(regex);
+
+            #[cfg(feature = "experimental")]
             regex_set.build_with_diagnostics(false, name);
+            #[cfg(not(feature = "experimental"))]
+            regex_set.build(false);
 
             builder =
                 builder.parse_callbacks(Box::new(CustomAttributeCallback {
@@ -1261,25 +1031,74 @@ where
         }
     }
 
-    if wrap_static_fns {
-        builder = builder.wrap_static_fns(true);
+    #[cfg(feature = "experimental")]
+    if emit_diagnostics {
+        builder = builder.emit_diagnostics();
     }
 
-    if let Some(path) = wrap_static_fns_path {
-        builder = builder.wrap_static_fns_path(path);
-    }
+    Ok((builder, output, verbose))
+}
 
-    if let Some(suffix) = wrap_static_fns_suffix {
-        builder = builder.wrap_static_fns_suffix(suffix);
-    }
+/// Trait for CLI arguments that can be applied to a [`Builder`].
+trait CliArg {
+    /// The value of this argument.
+    type Value;
+
+    /// Apply the current argument to the passed [`Builder`].
+    fn apply(
+        self,
+        builder: Builder,
+        f: impl Fn(Builder, Self::Value) -> Builder,
+    ) -> Builder;
+}
+
+/// Boolean arguments are applied when they evaluate to `true`.
+impl CliArg for bool {
+    type Value = bool;
+
+    fn apply(
+        self,
+        mut builder: Builder,
+        f: impl Fn(Builder, Self::Value) -> Builder,
+    ) -> Builder {
+        if self {
+            builder = f(builder, self)
+        }
 
-    if let Some(visibility) = default_visibility {
-        builder = builder.default_visibility(visibility);
+        builder
     }
+}
 
-    if emit_diagnostics {
-        builder = builder.emit_diagnostics();
+/// Optional arguments are applied when they are `Some`.
+impl<T> CliArg for Option<T> {
+    type Value = T;
+
+    fn apply(
+        self,
+        mut builder: Builder,
+        f: impl Fn(Builder, Self::Value) -> Builder,
+    ) -> Builder {
+        if let Some(value) = self {
+            builder = f(builder, value);
+        }
+
+        builder
     }
+}
 
-    Ok((builder, output, verbose))
+/// Multiple valued arguments are applied once for each value.
+impl<T> CliArg for Vec<T> {
+    type Value = T;
+
+    fn apply(
+        self,
+        mut builder: Builder,
+        f: impl Fn(Builder, Self::Value) -> Builder,
+    ) -> Builder {
+        for value in self {
+            builder = f(builder, value);
+        }
+
+        builder
+    }
 }
diff --git a/bindgen/options/mod.rs b/bindgen/options/mod.rs
index e9f4fb81..57988e79 100644
--- a/bindgen/options/mod.rs
+++ b/bindgen/options/mod.rs
@@ -4,6 +4,8 @@
 #[macro_use]
 mod helpers;
 mod as_args;
+#[cfg(feature = "__cli")]
+pub(crate) mod cli;
 
 use crate::callbacks::ParseCallbacks;
 use crate::codegen::{
diff --git a/bindgen/regex_set.rs b/bindgen/regex_set.rs
index 7f40af3c..33756327 100644
--- a/bindgen/regex_set.rs
+++ b/bindgen/regex_set.rs
@@ -6,7 +6,7 @@ use std::cell::Cell;
 
 /// A dynamic set of regular expressions.
 #[derive(Clone, Debug, Default)]
-pub struct RegexSet {
+pub(crate) struct RegexSet {
     items: Vec<Box<str>>,
     /// Whether any of the items in the set was ever matched. The length of this
     /// vector is exactly the length of `items`.
@@ -17,18 +17,13 @@ pub struct RegexSet {
 }
 
 impl RegexSet {
-    /// Create a new RegexSet
-    pub fn new() -> RegexSet {
-        RegexSet::default()
-    }
-
     /// Is this set empty?
-    pub fn is_empty(&self) -> bool {
+    pub(crate) fn is_empty(&self) -> bool {
         self.items.is_empty()
     }
 
     /// Insert a new regex into this set.
-    pub fn insert<S>(&mut self, string: S)
+    pub(crate) fn insert<S>(&mut self, string: S)
     where
         S: AsRef<str>,
     {
@@ -38,13 +33,13 @@ impl RegexSet {
     }
 
     /// Returns slice of String from its field 'items'
-    pub fn get_items(&self) -> &[Box<str>] {
+    pub(crate) fn get_items(&self) -> &[Box<str>] {
         &self.items
     }
 
     /// Returns an iterator over regexes in the set which didn't match any
     /// strings yet.
-    pub fn unmatched_items(&self) -> impl Iterator<Item = &str> {
+    pub(crate) fn unmatched_items(&self) -> impl Iterator<Item = &str> {
         self.items.iter().enumerate().filter_map(move |(i, item)| {
             if !self.record_matches || self.matched[i].get() {
                 return None;
@@ -59,7 +54,8 @@ impl RegexSet {
     /// Must be called before calling `matches()`, or it will always return
     /// false.
     #[inline]
-    pub fn build(&mut self, record_matches: bool) {
+    #[allow(unused)]
+    pub(crate) fn build(&mut self, record_matches: bool) {
         self.build_inner(record_matches, None)
     }
 
@@ -70,7 +66,7 @@ impl RegexSet {
     /// Must be called before calling `matches()`, or it will always return
     /// false.
     #[inline]
-    pub fn build_with_diagnostics(
+    pub(crate) fn build_with_diagnostics(
         &mut self,
         record_matches: bool,
         name: Option<&'static str>,
@@ -114,7 +110,7 @@ impl RegexSet {
     }
 
     /// Does the given `string` match any of the regexes in this set?
-    pub fn matches<S>(&self, string: S) -> bool
+    pub(crate) fn matches<S>(&self, string: S) -> bool
     where
         S: AsRef<str>,
     {
diff --git a/book/src/tutorial-3.md b/book/src/tutorial-3.md
index 3248f284..b2d15dbc 100644
--- a/book/src/tutorial-3.md
+++ b/book/src/tutorial-3.md
@@ -30,7 +30,7 @@ fn main() {
         .header("wrapper.h")
         // Tell cargo to invalidate the built crate whenever any of the
         // included header files changed.
-        .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
+        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
         // Finish the builder and generate the bindings.
         .generate()
         // Unwrap the Result and panic on failure.


Test patch:
diff --git a/bindgen-tests/Cargo.toml b/bindgen-tests/Cargo.toml
index 47fc0b8c..4a92f81f 100644
--- a/bindgen-tests/Cargo.toml
+++ b/bindgen-tests/Cargo.toml
@@ -6,15 +6,14 @@ publish = false
 
 [dev-dependencies]
 bindgen = { path = "../bindgen", features = ["__cli", "experimental"] }
-clap = { version = "4", features = ["derive"] }
-clap_complete = "4"
-shlex = "1"
+owo-colors = "3.5.0"
 prettyplease = { version = "0.2.7", features = ["verbatim"] }
-proc-macro2 = { version = "1", default-features = false }
-syn = { version = "2.0" }
-tempfile = "3"
 similar = { version = "2.2.1", features = ["inline"] }
-owo-colors = "3.5.0"
+tempfile = "3"
+
+proc-macro2.workspace = true
+shlex.workspace = true
+syn.workspace = true
 
 [features]
 logging = ["bindgen/logging"]
diff --git a/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs b/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs
index 88b9ceaa..c8f19bc5 100644
--- a/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-bitfield-method-same-name.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 /** Because this struct have array larger than 32 items
  and --with-derive-partialeq --impl-partialeq --impl-debug is provided,
@@ -219,35 +165,6 @@ impl Foo {
         }
     }
     #[inline]
-    pub unsafe fn type__bindgen_bitfield_raw(
-        this: *const Self,
-    ) -> ::std::os::raw::c_char {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 3u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_type__bindgen_bitfield_raw(
-        this: *mut Self,
-        val: ::std::os::raw::c_char,
-    ) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                3u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         type__bindgen_bitfield: ::std::os::raw::c_char,
     ) -> __BindgenBitfieldUnit<[u8; 2usize]> {
diff --git a/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-1-51.rs b/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-1-51.rs
new file mode 100644
index 00000000..fa007056
--- /dev/null
+++ b/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-1-51.rs
@@ -0,0 +1,266 @@
+#![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)]
+pub struct __BindgenBitfieldUnit<Storage> {
+    storage: Storage,
+}
+impl<Storage> __BindgenBitfieldUnit<Storage> {
+    #[inline]
+    pub const fn new(storage: Storage) -> Self {
+        Self { storage }
+    }
+}
+impl<Storage> __BindgenBitfieldUnit<Storage>
+where
+    Storage: AsRef<[u8]> + AsMut<[u8]>,
+{
+    #[inline]
+    fn extract_bit(byte: u8, index: usize) -> bool {
+        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 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];
+        Self::extract_bit(byte, index)
+    }
+    #[inline]
+    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
+        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
+        let byte_index = index / 8;
+        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
+            .offset(byte_index as isize);
+        Self::extract_bit(byte, index)
+    }
+    #[inline]
+    fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
+        let bit_index = if cfg!(target_endian = "big") {
+            7 - (index % 8)
+        } else {
+            index % 8
+        };
+        let mask = 1 << bit_index;
+        if val { byte | mask } else { byte & !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];
+        *byte = Self::change_bit(*byte, index, val);
+    }
+    #[inline]
+    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
+        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
+        let byte_index = index / 8;
+        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
+            .offset(byte_index as isize);
+        *byte = Self::change_bit(*byte, index, val);
+    }
+    #[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") {
+                    bit_width as usize - 1 - i
+                } else {
+                    i
+                };
+                val |= 1 << index;
+            }
+        }
+        val
+    }
+    #[inline]
+    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
+        debug_assert!(bit_width <= 64);
+        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
+        debug_assert!(
+            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
+        );
+        let mut val = 0;
+        for i in 0..(bit_width as usize) {
+            if Self::raw_get_bit(this, i + bit_offset) {
+                let index = if cfg!(target_endian = "big") {
+                    bit_width as usize - 1 - i
+                } else {
+                    i
+                };
+                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;
+            let index = if cfg!(target_endian = "big") {
+                bit_width as usize - 1 - i
+            } else {
+                i
+            };
+            self.set_bit(index + bit_offset, val_bit_is_set);
+        }
+    }
+    #[inline]
+    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
+        debug_assert!(bit_width <= 64);
+        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
+        debug_assert!(
+            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
+        );
+        for i in 0..(bit_width as usize) {
+            let mask = 1 << i;
+            let val_bit_is_set = val & mask == mask;
+            let index = if cfg!(target_endian = "big") {
+                bit_width as usize - 1 - i
+            } else {
+                i
+            };
+            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
+        }
+    }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct C {
+    pub _bitfield_align_1: [u8; 0],
+    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>,
+    pub large_array: [::std::os::raw::c_int; 50usize],
+}
+#[test]
+fn bindgen_test_layout_C() {
+    const UNINIT: ::std::mem::MaybeUninit<C> = ::std::mem::MaybeUninit::uninit();
+    let ptr = UNINIT.as_ptr();
+    assert_eq!(::std::mem::size_of::<C>(), 204usize, "Size of C");
+    assert_eq!(::std::mem::align_of::<C>(), 4usize, "Alignment of C");
+    assert_eq!(
+        unsafe { ::std::ptr::addr_of!((*ptr).large_array) as usize - ptr as usize },
+        4usize,
+        "Offset of field: C::large_array",
+    );
+}
+impl Default for C {
+    fn default() -> Self {
+        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
+        unsafe {
+            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
+            s.assume_init()
+        }
+    }
+}
+impl C {
+    #[inline]
+    pub fn a(&self) -> bool {
+        unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
+    }
+    #[inline]
+    pub fn set_a(&mut self, val: bool) {
+        unsafe {
+            let val: u8 = ::std::mem::transmute(val);
+            self._bitfield_1.set(0usize, 1u8, val as u64)
+        }
+    }
+    #[inline]
+    pub unsafe fn a_raw(this: *const Self) -> bool {
+        unsafe {
+            ::std::mem::transmute(
+                <__BindgenBitfieldUnit<
+                    [u8; 1usize],
+                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8) as u8,
+            )
+        }
+    }
+    #[inline]
+    pub unsafe fn set_a_raw(this: *mut Self, val: bool) {
+        unsafe {
+            let val: u8 = ::std::mem::transmute(val);
+            <__BindgenBitfieldUnit<
+                [u8; 1usize],
+            >>::raw_set(
+                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+                0usize,
+                1u8,
+                val as u64,
+            )
+        }
+    }
+    #[inline]
+    pub fn b(&self) -> bool {
+        unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) }
+    }
+    #[inline]
+    pub fn set_b(&mut self, val: bool) {
+        unsafe {
+            let val: u8 = ::std::mem::transmute(val);
+            self._bitfield_1.set(1usize, 7u8, val as u64)
+        }
+    }
+    #[inline]
+    pub unsafe fn b_raw(this: *const Self) -> bool {
+        unsafe {
+            ::std::mem::transmute(
+                <__BindgenBitfieldUnit<
+                    [u8; 1usize],
+                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 7u8) as u8,
+            )
+        }
+    }
+    #[inline]
+    pub unsafe fn set_b_raw(this: *mut Self, val: bool) {
+        unsafe {
+            let val: u8 = ::std::mem::transmute(val);
+            <__BindgenBitfieldUnit<
+                [u8; 1usize],
+            >>::raw_set(
+                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
+                1usize,
+                7u8,
+                val as u64,
+            )
+        }
+    }
+    #[inline]
+    pub fn new_bitfield_1(a: bool, b: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> {
+        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
+        __bindgen_bitfield_unit
+            .set(
+                0usize,
+                1u8,
+                {
+                    let a: u8 = unsafe { ::std::mem::transmute(a) };
+                    a as u64
+                },
+            );
+        __bindgen_bitfield_unit
+            .set(
+                1usize,
+                7u8,
+                {
+                    let b: u8 = unsafe { ::std::mem::transmute(b) };
+                    b as u64
+                },
+            );
+        __bindgen_bitfield_unit
+    }
+}
diff --git a/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-core.rs b/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-core.rs
index e88d1d6d..edcb4e2a 100644
--- a/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-core.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-debug-bitfield-core.rs
@@ -33,14 +33,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -58,14 +50,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -86,26 +70,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -123,24 +87,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 #[derive(Copy, Clone)]
@@ -188,31 +134,6 @@ impl C {
         }
     }
     #[inline]
-    pub unsafe fn a_raw(this: *const Self) -> bool {
-        unsafe {
-            ::core::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::core::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8)
-                    as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_a_raw(this: *mut Self, val: bool) {
-        unsafe {
-            let val: u8 = ::core::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::core::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn b(&self) -> bool {
         unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) }
     }
@@ -224,31 +145,6 @@ impl C {
         }
     }
     #[inline]
-    pub unsafe fn b_raw(this: *const Self) -> bool {
-        unsafe {
-            ::core::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::core::ptr::addr_of!((*this)._bitfield_1), 1usize, 7u8)
-                    as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_b_raw(this: *mut Self, val: bool) {
-        unsafe {
-            let val: u8 = ::core::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::core::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                7u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(a: bool, b: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> {
         let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
         __bindgen_bitfield_unit
diff --git a/bindgen-tests/tests/expectations/tests/derive-debug-bitfield.rs b/bindgen-tests/tests/expectations/tests/derive-debug-bitfield.rs
index 09ca288b..20c7cf0c 100644
--- a/bindgen-tests/tests/expectations/tests/derive-debug-bitfield.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-debug-bitfield.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 #[derive(Copy, Clone)]
@@ -198,30 +144,6 @@ impl C {
         }
     }
     #[inline]
-    pub unsafe fn a_raw(this: *const Self) -> bool {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_a_raw(this: *mut Self, val: bool) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn b(&self) -> bool {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) }
     }
@@ -233,30 +155,6 @@ impl C {
         }
     }
     #[inline]
-    pub unsafe fn b_raw(this: *const Self) -> bool {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 7u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_b_raw(this: *mut Self, val: bool) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                7u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(a: bool, b: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> {
         let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
         __bindgen_bitfield_unit
diff --git a/bindgen-tests/tests/expectations/tests/derive-partialeq-bitfield.rs b/bindgen-tests/tests/expectations/tests/derive-partialeq-bitfield.rs
index b27a9bb3..eaf3f45e 100644
--- a/bindgen-tests/tests/expectations/tests/derive-partialeq-bitfield.rs
+++ b/bindgen-tests/tests/expectations/tests/derive-partialeq-bitfield.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 #[derive(Copy, Clone)]
@@ -188,30 +134,6 @@ impl C {
         }
     }
     #[inline]
-    pub unsafe fn a_raw(this: *const Self) -> bool {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_a_raw(this: *mut Self, val: bool) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn b(&self) -> bool {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) }
     }
@@ -223,30 +145,6 @@ impl C {
         }
     }
     #[inline]
-    pub unsafe fn b_raw(this: *const Self) -> bool {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 7u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_b_raw(this: *mut Self, val: bool) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                7u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(a: bool, b: bool) -> __BindgenBitfieldUnit<[u8; 1usize]> {
         let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default();
         __bindgen_bitfield_unit
diff --git a/bindgen-tests/tests/expectations/tests/issue-2966.rs b/bindgen-tests/tests/expectations/tests/issue-2966.rs
new file mode 100644
index 00000000..bfdcbd9e
--- /dev/null
+++ b/bindgen-tests/tests/expectations/tests/issue-2966.rs
@@ -0,0 +1,10 @@
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+#[repr(transparent)]
+#[derive(Debug, Copy, Clone)]
+pub struct pub_var1(pub *const ::std::os::raw::c_char);
+#[repr(transparent)]
+#[derive(Debug, Copy, Clone)]
+pub struct pubcrate_var2(pub(crate) *const ::std::os::raw::c_char);
+#[repr(transparent)]
+#[derive(Debug, Copy, Clone)]
+pub struct private_var3(*const ::std::os::raw::c_char);
diff --git a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
index 5da0e799..422782d6 100644
--- a/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/jsval_layout_opaque_1_0.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
@@ -328,31 +274,6 @@ impl jsval_layout__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn payload47_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 8usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 47u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_payload47_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 8usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                47u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn tag(&self) -> JSValueTag {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(47usize, 17u8) as u32) }
     }
@@ -364,31 +285,6 @@ impl jsval_layout__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn tag_raw(this: *const Self) -> JSValueTag {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 8usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 47usize, 17u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_tag_raw(this: *mut Self, val: JSValueTag) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 8usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                47usize,
-                17u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         payload47: u64,
         tag: JSValueTag,
diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs
index d9d30e1d..4a62ddbe 100644
--- a/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_eth_conf.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 pub const ETH_MQ_RX_RSS_FLAG: u32 = 1;
 pub const ETH_MQ_RX_DCB_FLAG: u32 = 2;
@@ -260,31 +206,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn header_split_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_header_split_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_ip_checksum(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) }
     }
@@ -296,31 +217,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_ip_checksum_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_ip_checksum_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_filter(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) }
     }
@@ -332,31 +228,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_filter_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 2usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_filter_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                2usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_strip(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) }
     }
@@ -368,31 +239,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_strip_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 3usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_strip_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                3usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_extend(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) }
     }
@@ -404,31 +250,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_extend_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 4usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_extend_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                4usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn jumbo_frame(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) }
     }
@@ -440,31 +261,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn jumbo_frame_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 5usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_jumbo_frame_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                5usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_strip_crc(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) }
     }
@@ -476,31 +272,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_strip_crc_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 6usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_strip_crc_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                6usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn enable_scatter(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) }
     }
@@ -512,31 +283,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn enable_scatter_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 7usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_enable_scatter_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                7usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn enable_lro(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) }
     }
@@ -548,31 +294,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn enable_lro_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 8usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_enable_lro_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                8usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         header_split: u16,
         hw_ip_checksum: u16,
@@ -755,30 +476,6 @@ impl rte_eth_txmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_reject_tagged_raw(this: *const Self) -> u8 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_reject_tagged_raw(this: *mut Self, val: u8) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_reject_untagged(&self) -> u8 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
     }
@@ -790,30 +487,6 @@ impl rte_eth_txmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_reject_untagged_raw(this: *const Self) -> u8 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_reject_untagged_raw(this: *mut Self, val: u8) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_insert_pvid(&self) -> u8 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) }
     }
@@ -825,30 +498,6 @@ impl rte_eth_txmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_insert_pvid_raw(this: *const Self) -> u8 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 2usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_insert_pvid_raw(this: *mut Self, val: u8) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                2usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         hw_vlan_reject_tagged: u8,
         hw_vlan_reject_untagged: u8,
diff --git a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
index c5ccdd09..6cbeb042 100644
--- a/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_eth_conf_1_0.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
@@ -308,31 +254,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn header_split_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_header_split_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_ip_checksum(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) }
     }
@@ -344,31 +265,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_ip_checksum_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_ip_checksum_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_filter(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) }
     }
@@ -380,31 +276,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_filter_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 2usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_filter_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                2usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_strip(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) }
     }
@@ -416,31 +287,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_strip_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 3usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_strip_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                3usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_extend(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) }
     }
@@ -452,31 +298,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_extend_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 4usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_extend_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                4usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn jumbo_frame(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) }
     }
@@ -488,31 +309,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn jumbo_frame_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 5usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_jumbo_frame_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                5usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_strip_crc(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) }
     }
@@ -524,31 +320,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_strip_crc_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 6usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_strip_crc_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                6usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn enable_scatter(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) }
     }
@@ -560,31 +331,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn enable_scatter_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 7usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_enable_scatter_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                7usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn enable_lro(&self) -> u16 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) }
     }
@@ -596,31 +342,6 @@ impl rte_eth_rxmode {
         }
     }
     #[inline]
-    pub unsafe fn enable_lro_raw(this: *const Self) -> u16 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 2usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 8usize, 1u8)
-                    as u16,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_enable_lro_raw(this: *mut Self, val: u16) {
-        unsafe {
-            let val: u16 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 2usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                8usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         header_split: u16,
         hw_ip_checksum: u16,
@@ -808,30 +529,6 @@ impl rte_eth_txmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_reject_tagged_raw(this: *const Self) -> u8 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_reject_tagged_raw(this: *mut Self, val: u8) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_reject_untagged(&self) -> u8 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
     }
@@ -843,30 +540,6 @@ impl rte_eth_txmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_reject_untagged_raw(this: *const Self) -> u8 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 1usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_reject_untagged_raw(this: *mut Self, val: u8) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                1usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn hw_vlan_insert_pvid(&self) -> u8 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) }
     }
@@ -878,30 +551,6 @@ impl rte_eth_txmode {
         }
     }
     #[inline]
-    pub unsafe fn hw_vlan_insert_pvid_raw(this: *const Self) -> u8 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 2usize, 1u8) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_hw_vlan_insert_pvid_raw(this: *mut Self, val: u8) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                2usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         hw_vlan_reject_tagged: u8,
         hw_vlan_reject_untagged: u8,
diff --git a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
index db4f078a..38e221f3 100644
--- a/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/layout_mbuf_1_0.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
@@ -360,31 +306,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn l2_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_l2_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn l3_type(&self) -> u32 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 4u8) as u32) }
     }
@@ -396,31 +317,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn l3_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 4usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_l3_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                4usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn l4_type(&self) -> u32 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 4u8) as u32) }
     }
@@ -432,31 +328,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn l4_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 8usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_l4_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                8usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn tun_type(&self) -> u32 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 4u8) as u32) }
     }
@@ -468,31 +339,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn tun_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 12usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_tun_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                12usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn inner_l2_type(&self) -> u32 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(16usize, 4u8) as u32) }
     }
@@ -504,31 +350,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn inner_l2_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 16usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_inner_l2_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                16usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn inner_l3_type(&self) -> u32 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(20usize, 4u8) as u32) }
     }
@@ -540,31 +361,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn inner_l3_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 20usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_inner_l3_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                20usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn inner_l4_type(&self) -> u32 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 4u8) as u32) }
     }
@@ -576,31 +372,6 @@ impl rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn inner_l4_type_raw(this: *const Self) -> u32 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 24usize, 4u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_inner_l4_type_raw(this: *mut Self, val: u32) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                24usize,
-                4u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         l2_type: u32,
         l3_type: u32,
@@ -991,31 +762,6 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn l2_len_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 7usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 7u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_l2_len_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 7usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                7u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn l3_len(&self) -> u64 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 9u8) as u64) }
     }
@@ -1027,31 +773,6 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn l3_len_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 7usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 7usize, 9u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_l3_len_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 7usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                7usize,
-                9u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn l4_len(&self) -> u64 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(16usize, 8u8) as u64) }
     }
@@ -1063,31 +784,6 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn l4_len_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 7usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 16usize, 8u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_l4_len_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 7usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                16usize,
-                8u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn tso_segsz(&self) -> u64 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(24usize, 16u8) as u64) }
     }
@@ -1099,31 +795,6 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn tso_segsz_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 7usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 24usize, 16u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_tso_segsz_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 7usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                24usize,
-                16u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn outer_l3_len(&self) -> u64 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(40usize, 9u8) as u64) }
     }
@@ -1135,31 +806,6 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn outer_l3_len_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 7usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 40usize, 9u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_outer_l3_len_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 7usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                40usize,
-                9u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn outer_l2_len(&self) -> u64 {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(49usize, 7u8) as u64) }
     }
@@ -1171,31 +817,6 @@ impl rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn outer_l2_len_raw(this: *const Self) -> u64 {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 7usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 49usize, 7u8)
-                    as u64,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_outer_l2_len_raw(this: *mut Self, val: u64) {
-        unsafe {
-            let val: u64 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 7usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                49usize,
-                7u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         l2_len: u64,
         l3_len: u64,
diff --git a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
index 9cf2bf8e..bd4a772c 100644
--- a/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_bitfield_1_0.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
@@ -216,34 +162,6 @@ impl U4 {
         }
     }
     #[inline]
-    pub unsafe fn derp_raw(this: *const Self) -> ::std::os::raw::c_uint {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 1usize],
-                >>::raw_get(
-                    (*::std::ptr::addr_of!((*this)._bitfield_1)).as_ref() as *const _,
-                    0usize,
-                    1u8,
-                ) as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_derp_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 1usize],
-            >>::raw_set(
-                (*::std::ptr::addr_of_mut!((*this)._bitfield_1)).as_mut() as *mut _,
-                0usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         derp: ::std::os::raw::c_uint,
     ) -> __BindgenBitfieldUnit<[u8; 1usize]> {
@@ -292,34 +210,6 @@ impl B {
         }
     }
     #[inline]
-    pub unsafe fn foo_raw(this: *const Self) -> ::std::os::raw::c_uint {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(
-                    (*::std::ptr::addr_of!((*this)._bitfield_1)).as_ref() as *const _,
-                    0usize,
-                    31u8,
-                ) as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_foo_raw(this: *mut Self, val: ::std::os::raw::c_uint) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                (*::std::ptr::addr_of_mut!((*this)._bitfield_1)).as_mut() as *mut _,
-                0usize,
-                31u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn bar(&self) -> ::std::os::raw::c_uchar {
         unsafe {
             ::std::mem::transmute(self._bitfield_1.as_ref().get(31usize, 1u8) as u8)
@@ -333,34 +223,6 @@ impl B {
         }
     }
     #[inline]
-    pub unsafe fn bar_raw(this: *const Self) -> ::std::os::raw::c_uchar {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(
-                    (*::std::ptr::addr_of!((*this)._bitfield_1)).as_ref() as *const _,
-                    31usize,
-                    1u8,
-                ) as u8,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_bar_raw(this: *mut Self, val: ::std::os::raw::c_uchar) {
-        unsafe {
-            let val: u8 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                (*::std::ptr::addr_of_mut!((*this)._bitfield_1)).as_mut() as *mut _,
-                31usize,
-                1u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         foo: ::std::os::raw::c_uint,
         bar: ::std::os::raw::c_uchar,
diff --git a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
index 287bfebf..ff19f398 100644
--- a/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
+++ b/bindgen-tests/tests/expectations/tests/union_with_anon_struct_bitfield_1_0.rs
@@ -32,14 +32,6 @@ where
         Self::extract_bit(byte, index)
     }
     #[inline]
-    pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = *(core::ptr::addr_of!((*this).storage) as *const u8)
-            .offset(byte_index as isize);
-        Self::extract_bit(byte, index)
-    }
-    #[inline]
     fn change_bit(byte: u8, index: usize, val: bool) -> u8 {
         let bit_index = if cfg!(target_endian = "big") {
             7 - (index % 8)
@@ -57,14 +49,6 @@ where
         *byte = Self::change_bit(*byte, index, val);
     }
     #[inline]
-    pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
-        debug_assert!(index / 8 < core::mem::size_of::<Storage>());
-        let byte_index = index / 8;
-        let byte = (core::ptr::addr_of_mut!((*this).storage) as *mut u8)
-            .offset(byte_index as isize);
-        *byte = Self::change_bit(*byte, index, val);
-    }
-    #[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());
@@ -85,26 +69,6 @@ where
         val
     }
     #[inline]
-    pub unsafe fn raw_get(this: *const Self, bit_offset: usize, bit_width: u8) -> u64 {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        let mut val = 0;
-        for i in 0..(bit_width as usize) {
-            if Self::raw_get_bit(this, i + bit_offset) {
-                let index = if cfg!(target_endian = "big") {
-                    bit_width as usize - 1 - i
-                } else {
-                    i
-                };
-                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());
@@ -122,24 +86,6 @@ where
             self.set_bit(index + bit_offset, val_bit_is_set);
         }
     }
-    #[inline]
-    pub unsafe fn raw_set(this: *mut Self, bit_offset: usize, bit_width: u8, val: u64) {
-        debug_assert!(bit_width <= 64);
-        debug_assert!(bit_offset / 8 < core::mem::size_of::<Storage>());
-        debug_assert!(
-            (bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>(),
-        );
-        for i in 0..(bit_width as usize) {
-            let mask = 1 << i;
-            let val_bit_is_set = val & mask == mask;
-            let index = if cfg!(target_endian = "big") {
-                bit_width as usize - 1 - i
-            } else {
-                i
-            };
-            Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
-        }
-    }
 }
 #[repr(C)]
 pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
@@ -228,31 +174,6 @@ impl foo__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn b_raw(this: *const Self) -> ::std::os::raw::c_int {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 0usize, 7u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_b_raw(this: *mut Self, val: ::std::os::raw::c_int) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                0usize,
-                7u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn c(&self) -> ::std::os::raw::c_int {
         unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 25u8) as u32) }
     }
@@ -264,31 +185,6 @@ impl foo__bindgen_ty_1 {
         }
     }
     #[inline]
-    pub unsafe fn c_raw(this: *const Self) -> ::std::os::raw::c_int {
-        unsafe {
-            ::std::mem::transmute(
-                <__BindgenBitfieldUnit<
-                    [u8; 4usize],
-                >>::raw_get(::std::ptr::addr_of!((*this)._bitfield_1), 7usize, 25u8)
-                    as u32,
-            )
-        }
-    }
-    #[inline]
-    pub unsafe fn set_c_raw(this: *mut Self, val: ::std::os::raw::c_int) {
-        unsafe {
-            let val: u32 = ::std::mem::transmute(val);
-            <__BindgenBitfieldUnit<
-                [u8; 4usize],
-            >>::raw_set(
-                ::std::ptr::addr_of_mut!((*this)._bitfield_1),
-                7usize,
-                25u8,
-                val as u64,
-            )
-        }
-    }
-    #[inline]
     pub fn new_bitfield_1(
         b: ::std::os::raw::c_int,
         c: ::std::os::raw::c_int,
diff --git a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs
index 2f5b4cc5..05be5d99 100644
--- a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs
+++ b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs
@@ -16,13 +16,14 @@ pub struct TestLib {
         unsafe extern "C" fn() -> ::std::os::raw::c_int,
         ::libloading::Error,
     >,
+    pub FLUX: Result<*mut ::std::os::raw::c_int, ::libloading::Error>,
 }
 impl TestLib {
     pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
     where
         P: AsRef<::std::ffi::OsStr>,
     {
-        let library = ::libloading::Library::new(path)?;
+        let library = unsafe { ::libloading::Library::new(path) }?;
         unsafe { Self::from_library(library) }
     }
     pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
@@ -33,11 +34,14 @@ impl TestLib {
         let foo = unsafe { __library.get(b"foo\0") }.map(|sym| *sym);
         let bar = unsafe { __library.get(b"bar\0") }.map(|sym| *sym);
         let baz = unsafe { __library.get(b"baz\0") }.map(|sym| *sym);
+        let FLUX = unsafe { __library.get::<*mut ::std::os::raw::c_int>(b"FLUX\0") }
+            .map(|sym| *sym);
         Ok(TestLib {
             __library,
             foo,
             bar,
             baz,
+            FLUX,
         })
     }
     pub unsafe fn foo(
@@ -53,4 +57,7 @@ impl TestLib {
     pub unsafe fn baz(&self) -> ::std::os::raw::c_int {
         unsafe { (self.baz.as_ref().expect("Expected function, got error."))() }
     }
+    pub unsafe fn FLUX(&self) -> *mut ::std::os::raw::c_int {
+        *self.FLUX.as_ref().expect("Expected variable, got error.")
+    }
 }
diff --git a/bindgen-tests/tests/headers/derive-debug-bitfield-1-51.hpp b/bindgen-tests/tests/headers/derive-debug-bitfield-1-51.hpp
new file mode 100644
index 00000000..a68611d9
--- /dev/null
+++ b/bindgen-tests/tests/headers/derive-debug-bitfield-1-51.hpp
@@ -0,0 +1,7 @@
+// bindgen-flags: --impl-debug --rust-target 1.51
+
+class C {
+  bool a: 1;
+  bool b: 7;
+  int large_array[50];
+};
diff --git a/bindgen-tests/tests/headers/issue-2966.h b/bindgen-tests/tests/headers/issue-2966.h
new file mode 100644
index 00000000..3f00dec6
--- /dev/null
+++ b/bindgen-tests/tests/headers/issue-2966.h
@@ -0,0 +1,6 @@
+// bindgen-flags: --default-alias-style=new_type
+// bindgen-parse-callbacks: type-visibility
+
+typedef const char *  pub_var1;
+typedef const char *  pubcrate_var2;
+typedef const char *  private_var3;
diff --git a/bindgen-tests/tests/headers/wrap_unsafe_ops_dynamic_loading_simple.h b/bindgen-tests/tests/headers/wrap_unsafe_ops_dynamic_loading_simple.h
index 2b8c1071..36a638ae 100644
--- a/bindgen-tests/tests/headers/wrap_unsafe_ops_dynamic_loading_simple.h
+++ b/bindgen-tests/tests/headers/wrap_unsafe_ops_dynamic_loading_simple.h
@@ -3,3 +3,5 @@
 int foo(int x, int y);
 int bar(void *x);
 int baz();
+
+const int FLUX;
diff --git a/bindgen-tests/tests/parse_callbacks/mod.rs b/bindgen-tests/tests/parse_callbacks/mod.rs
index ee31d56e..9f4b04a2 100644
--- a/bindgen-tests/tests/parse_callbacks/mod.rs
+++ b/bindgen-tests/tests/parse_callbacks/mod.rs
@@ -93,8 +93,8 @@ struct FieldVisibility {
 }
 
 /// Implements the `field_visibility` function of the trait by checking if the
-/// field name starts with `private_`. If it does it makes it private, if it
-/// doesn't it makes it public, taking into account the default visibility.
+/// field name starts with `private_`. If it does, it makes it private, if it
+/// doesn't, it makes it public, taking into account the default visibility.
 impl ParseCallbacks for FieldVisibility {
     fn field_visibility(
         &self,
@@ -113,6 +113,28 @@ impl ParseCallbacks for FieldVisibility {
     }
 }
 
+#[derive(Debug)]
+struct TypeVisibility;
+
+/// Implements the `field_visibility` function of the trait by checking the
+/// type name. Depending on name prefix, it will return a different visibility.
+impl ParseCallbacks for TypeVisibility {
+    fn field_visibility(
+        &self,
+        FieldInfo { type_name, .. }: FieldInfo,
+    ) -> Option<FieldVisibilityKind> {
+        if type_name.starts_with("private_") {
+            Some(FieldVisibilityKind::Private)
+        } else if type_name.starts_with("pubcrate_") {
+            Some(FieldVisibilityKind::PublicCrate)
+        } else if type_name.starts_with("pub_") {
+            Some(FieldVisibilityKind::Public)
+        } else {
+            None
+        }
+    }
+}
+
 #[derive(Debug)]
 pub(super) struct WrapAsVariadicFn;
 
@@ -129,6 +151,7 @@ pub fn lookup(cb: &str) -> Box<dyn ParseCallbacks> {
             Box::new(BlocklistedTypeImplementsTrait)
         }
         "wrap-as-variadic-fn" => Box::new(WrapAsVariadicFn),
+        "type-visibility" => Box::new(TypeVisibility),
         call_back => {
             if let Some(prefix) =
                 call_back.strip_prefix("remove-function-prefix-")
diff --git a/bindgen-tests/tests/tests.rs b/bindgen-tests/tests/tests.rs
index 14988e46..c008766d 100644
--- a/bindgen-tests/tests/tests.rs
+++ b/bindgen-tests/tests/tests.rs
@@ -7,10 +7,7 @@ use std::fs;
 use std::io::{BufRead, BufReader, Error, ErrorKind, Read, Write};
 use std::path::{Path, PathBuf};
 
-use crate::options::builder_from_flags;
-
-#[path = "../../bindgen-cli/options.rs"]
-mod options;
+use bindgen::builder_from_flags;
 
 mod parse_callbacks;
 
@@ -709,8 +706,7 @@ fn build_flags_output_helper(builder: &bindgen::Builder) {
     println!("{}", flags_str);
 
     let (builder, _output, _verbose) =
-        crate::options::builder_from_flags(command_line_flags.into_iter())
-            .unwrap();
+        builder_from_flags(command_line_flags.into_iter()).unwrap();
     builder.generate().expect("failed to generate bindings");
 }
 
diff --git a/ci/test.sh b/ci/test.sh
index bec7cfbb..a90af844 100755
--- a/ci/test.sh
+++ b/ci/test.sh
@@ -154,7 +154,7 @@ if [ "$BINDGEN_RUST_FOR_LINUX_TEST" == "1" ]; then
   # and each update should only contain this change.
   #
   # Both commit hashes and tags are supported.
-  LINUX_VERSION=c13320499ba0efd93174ef6462ae8a7a2933f6e7
+  LINUX_VERSION=v6.12-rc5
 
   # Download Linux at a specific commit
   mkdir -p linux