rust-lang / rust-lang/rust-bindgen
--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
int take(int t);
namespace [[deprecated]] {
int helper(int t);
}
Bindgen Invocation
$ bindgen input.h --enable-cxx-namespaces -- -x c++ -std=c++17
Actual Results
bindgen aborts before emitting take:
clang diag: ... warning: 'deprecated' attribute on anonymous namespace ignored [-Wignored-attributes]
panicked at bindgen/ir/context.rs:903:9:
"[" is not a valid Ident
tokenize_namespace takes the next token after namespace as the module name. For an unnamed namespace the next token is [ from [[deprecated]].
namespace [[deprecated]] Foo does not panic (cursor spelling is Foo). Without --enable-cxx-namespaces there is no module Ident and take is emitted.
This is not #1676 (macro prefix) or #2293 (inline nested namespaces).
Expected Results
Do not abort. Ignore the attribute-specifier-seq on an unnamed namespace (clang already ignores deprecated here) and treat it like namespace { ... }.
Environment
bindgen: 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
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
Start in bindgen/ir/context.rs at tokenize_namespace and the panic near line 903, then reproduce the issue with the shown C++ header and bindgen invocation. Done means an unnamed namespace with [[deprecated]] no longer panics, the attribute is ignored, and the take declaration is emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100