taiki-e / pin-project-lite

A lightweight version of pin-project written with declarative macros.
https://docs.rs/pin-project-lite
Apache License 2.0
216 stars 15 forks source link

Can bypass `repr(packed)` checking by using --cap-lints #26

Closed taiki-e closed 1 year ago

taiki-e commented 4 years ago

NOTE: pin-project (not lite) is not affected by this issue. see https://github.com/taiki-e/pin-project/pull/34#issuecomment-688801015 for more. EDIT: see https://github.com/taiki-e/pin-project/issues/342 for pin-project (not lite)

Currently, pin-project-lite uses safe_packed_borrow lint to check that the struct is not repr(packed). Unfortunately, safe_packed_borrow is lint and you can use the rustc's --cap-lints flag to lower the lint cap level: https://godbolt.org/z/jEf1fG

The current pin-project-lite generates almost the same code as pin-project, but does not have the equivalent of the repr(packed) checking that proc-macro(pin-project) does during expansion. (Since the proc-macro-attribute used on the struct expand later than declarative macro used for the struct, a complete fix for the problem is probably impossible until safe_packed_borrow gets a hard error.)

RalfJung commented 4 years ago

FWIW, safe_packed_borrow should become a hard error eventually. However, that cannot happen before we stabilize https://github.com/rust-lang/rust/issues/73394 (and then wait some time).

taiki-e commented 1 year ago

unaligned_references is now a hard error 🎉: https://github.com/rust-lang/rust/pull/102513