Support passing attributes on the command line

Đang mở
#3,343 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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Bắt đầu bằng việc xem xét các tùy chọn dòng lệnh của bindgen và đường dẫn tạo kiểu dẫn xuất; issue không nêu tên tệp nào trong repository hoặc test nào. Xác định cách một flag sẽ thêm các thuộc tính zerocopy vào các kiểu được tạo, bao gồm các derives vô điều kiện được yêu cầu và hành vi của on_error, sau đó thêm coverage cho thấy các bindings được tạo có thể biên dịch.

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

Mô tả

Seems like this has been discussed in various places, but I'm not sure if there's a single issue that tracks this. Feel free to close in favor of one of those.

In https://github.com/google/zerocopy/pull/2982, we're adding a #[zerocopy(on_error = skip/fail)] attribute that would allow code to compile even if a type derives a trait which it can't implement, e.g.:

use zerocopy::*;

// Can't be `FromBytes` because `bool: !FromBytes`
#[derive(IntoBytes, FromBytes)]
#[zerocopy(on_error = skip)]
struct Foo(bool);

This is especially useful in conjunction with bindgen. Many zerocopy users add zerocopy derives to bindgen-generated types, but need to jump through significant hoops (such as the hoops that Fuchsia jumps through) in order to avoid adding #[derive(Xxx)] on a type that can't support the trait being derived.

Once this attribute is supported, they can unconditionally add all zerocopy traits and add #[zerocopy(on_error = skip)] to ensure everything compiles regardless of which traits are supported.

Currently, bindgen doesn't support a flag to automatically add attributes to derived types, so this would have to be done as a post-processing step. It'd be great if such a flag were supported. Note that this is a soft blocker for the Linux kernel to be able to use zerocopy.

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.