Rename hooks should affect names passed to subsequent hooks; rename hook for a thing should be called before any hook that receives data referring to that thing
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with the reproduction: a demo.h with an anonymous union inside in6_addr, a ParseCallbacks impl overriding item_name and field_name, and debug output showing the order of calls. Find where bindgen invokes item_name and field_name in the parse and codegen passes, and check whether the renamed name is used when field_name runs. Done means field_name receives in6_addr_u and item_name runs once for that type, with a regression test added to the bindgen test suite.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
If you build and run this test program, using bindgen 0.73...
use bindgen::callbacks::{ParseCallbacks, ItemInfo, ItemKind, FieldInfo};
#[derive(Debug)]
struct DemoCallbacks;
impl ParseCallbacks for DemoCallbacks {
fn item_name(&self, info: ItemInfo<'_>) -> Option<String> {
if info.kind == ItemKind::Type {
eprintln!("item_name: {:?}", &info);
if let Some(trimmed) = info.name.strip_suffix("__bindgen_ty_1") {
return Some(format!("{trimmed}_u"));
}
}
None
}
fn field_name(&self, info: FieldInfo<'_>) -> Option<String> {
eprintln!("field_name: {:?}", info);
None
}
}
fn main() {
bindgen::builder()
.header("demo.h")
.parse_callbacks(Box::new(DemoCallbacks))
.allowlist_type("in6_addr")
.generate()
.expect("parsing failed")
.write(std::io::stdout().lock())
.expect("write error");
}
... with this file as demo.h in the working directory:
struct in6_addr {
union {
unsigned char u6_addr8[16];
unsigned short u6_addr16[8];
unsigned int u6_addr32[8];
} in6_u;
};
... you will get this output:
item_name: ItemInfo { name: "in6_addr", kind: Type }
field_name: FieldInfo { type_name: "in6_addr", field_name: "in6_u", field_type_name: Some("union (unnamed at demo.h:2:3)") }
item_name: ItemInfo { name: "in6_addr__bindgen_ty_1", kind: Type }
field_name: FieldInfo { type_name: "in6_addr_u", field_name: "u6_addr8", field_type_name: None }
field_name: FieldInfo { type_name: "in6_addr_u", field_name: "u6_addr16", field_type_name: None }
field_name: FieldInfo { type_name: "in6_addr_u", field_name: "u6_addr32", field_type_name: None }
item_name: ItemInfo { name: "in6_addr__bindgen_ty_1", kind: Type }
/* automatically generated by rust-bindgen 0.73.2 */
#[repr(C)]
#[derive(Copy, Clone)]
pub struct in6_addr {
pub in6_u: in6_addr_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union in6_addr_u {
pub u6_addr8: [::std::os::raw::c_uchar; 16usize],
pub u6_addr16: [::std::os::raw::c_ushort; 8usize],
pub u6_addr32: [::std::os::raw::c_uint; 8usize],
}
// ... size/alignment/offset assertions omitted ...
The generated bindings (everything after the "automatically generated by ..." line) correctly reflect the renamed anonymous union in the input, but the calls to field_name do not. This is the key part of the debug spew:
field_name: FieldInfo { type_name: "in6_addr", field_name: "in6_u", field_type_name: Some("union (unnamed at demo.h:2:3)") }
item_name: ItemInfo { name: "in6_addr__bindgen_ty_1", kind: Type }
These calls should have happened in the opposite order, and the FieldInfo passed to the field_name hook should have had field_type_name: Some("in6_addr_u"). Also, item_name should not have been called a second time for this type.
This is just one example instance of a general principle: in all cases, whenever bindgen finds a thing that has or needs a name, the relevant rename hook should have a chance to act on that thing before any operation that refers to that thing happens, and all the hooks for subsequent operations should see adjusted names, not the originals, and especially not placeholders like "union (unnamed at demo.h.2:3)".
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/rust-bindgen
-
--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)Có thể đã có người làm @lwz23 đã nhận 49 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
rust-lang/rust-bindgen#3485 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rust-lang/rust-bindgen#3483 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
rust-lang/rust-bindgen#3370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
rust-lang/rust-bindgen#3363 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
rust-lang/rust-bindgen#3539 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/rust-bindgen
Issue tương tự
-
enhancement good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openfootmanager/openfootmanager#1365 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
JackMechem/marbble#305 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ci:stability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 5 ngày
-
antora bug review-2026-11-11
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bovinemagnet/AdocFoundry#546 ·
Maintainer thường phản hồi trong vòng 1 ngày