rust-lang / rust-lang/rust-bindgen
Bindings fail to compile with 'cannot find type ... in this scope'
Open
Nobody has claimed this yet.
A-templates
bug
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
C++ header
template <typename a> struct b { static const a c; };
template <typename a> const a b<a>::c;
bindgen test-case-1.hpp -- -x c++ produces
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct b {
pub _address: u8,
}
extern "C" {
pub static c: a;
}
rustc --crate-type lib bindings.rs produces
error[E0412]: cannot find type `a` in this scope
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with bindgen test-case-1.hpp -- -x c++, then compile the generated bindings.rs with rustc --crate-type lib. Inspect how the C++ template and static member are represented in the generated Rust output. Done means the reproduced binding no longer refers to an unresolved type and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100