Repository: mozilla/cbindgen (language: rust)

Issue:
Make `ir` module public
This would allow users to easily customize the bindings by inspecting the bindings items.

Is there any particular reason why most of the modules are private?  
If the concern is exposing too much complexity, we could just make `ir` and other modules public with a feature flag, such as `"internals"`.

AFAIK the only walk-around at the moment is to use a modified version of this crate.


Discussion / hints:
I think this feature would be nice too, currently I am also using a modified version of this crate to do this. The IR is very useful when using the generated C objects in bindings for other languages. 

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 3fafaa64..01a48452 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -41,6 +41,7 @@ pretty_assertions = "1.4.0"
 
 [features]
 default =  ["clap"]
+unstable_ir = []
 
 [[bin]]
 name = "cbindgen"
diff --git a/docs.md b/docs.md
index c8ce9f4f..3d00d814 100644
--- a/docs.md
+++ b/docs.md
@@ -94,9 +94,18 @@ cbindgen = "0.24.0"
 
 If you'd like to use a `build.rs` script with a `cbindgen.toml`, consider using [`cbindgen::generate()`](https://docs.rs/cbindgen/*/cbindgen/fn.generate.html) instead.
 
+## Internal Representation
 
+Some users may find it useful to access the **unstable** internal representation (IR) that cbindgen uses to parse and generate code. By default, the IR is private, but you can access it by enabling the `"unstable_ir"` feature flag like so:
 
+```
+[build-dependencies]
+cbindgen = { version = "0.27.0", features = ["unstable_ir"] }
+```
+
+This opens up the `cbindgen::bindgen::ir` module.
 
+Please remember that the IR is **not stable**, so if you use this feature, you will need to pin cbindgen to avoid breakages.
 
 # Writing Your C API
 
diff --git a/src/bindgen/mod.rs b/src/bindgen/mod.rs
index 5d788211..8cde9116 100644
--- a/src/bindgen/mod.rs
+++ b/src/bindgen/mod.rs
@@ -45,6 +45,9 @@ mod config;
 mod declarationtyperesolver;
 mod dependencies;
 mod error;
+#[cfg(feature = "unstable_ir")]
+pub mod ir;
+#[cfg(not(feature = "unstable_ir"))]
 mod ir;
 mod language_backend;
 mod library;
diff --git a/src/lib.rs b/src/lib.rs
index f98f4fc0..f7f0d32a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,6 +14,9 @@ extern crate quote;
 extern crate syn;
 extern crate toml;
 
+#[cfg(feature = "unstable_ir")]
+pub mod bindgen;
+#[cfg(not(feature = "unstable_ir"))]
 mod bindgen;
 
 pub use crate::bindgen::*;


Test patch: