--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)

Đang mở Phù hợp với người mới
#3,485 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lwz23 đang làm issue này rồi.

Từ ngày 23/9/2026.

  • #3502 của @lwz23 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, rust
Lĩnh vực
compilers, tooling

Hướng nghiên cứu

Bắt đầu trong bindgen/ir/context.rs tại tokenize_namespace và panic gần dòng 903, sau đó tái hiện vấn đề với header C++ và lệnh gọi bindgen được nêu. Hoàn thành khi một namespace không tên có [[deprecated]] không còn gây panic, thuộc tính bị bỏ qua và khai báo take được phát ra.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Rust
Star
5.3k
Fork
846
Merge trung bình
2 ngày 6 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-lang/rust-bindgen

Tất cả issue của rust-lang/rust-bindgen

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.