mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 05:49:47 -04:00
rust: pin-init: internal: error on duplicate #[pin] attribute
Duplicated `#[pin]` has no effect, thus error if misused. Reported-by: Mohamad Alsadhan <mo@sdhn.cc> Closes: https://github.com/Rust-for-Linux/pin-init/issues/119 Signed-off-by: Luiz Georg <luizgngeorg@gmail.com> Link: https://patch.msgid.link/20260710-pin-init-sync-v1-1-8fa16cde87ae@garyguo.net [ Reworded commit message, and change the logic so code generation still continue after reporting error - Gary ] Signed-off-by: Gary Guo <gary@garyguo.net>
This commit is contained in:
@@ -85,7 +85,10 @@ pub(crate) fn pin_data(
|
||||
.map(|field| {
|
||||
let len = field.attrs.len();
|
||||
field.attrs.retain(|a| !a.path().is_ident("pin"));
|
||||
let pinned = len != field.attrs.len();
|
||||
let pinned_count = len - field.attrs.len();
|
||||
if pinned_count > 1 {
|
||||
dcx.error(&field, "#[pin] attribute specified more than once");
|
||||
}
|
||||
|
||||
let cfg_attrs = field
|
||||
.attrs
|
||||
@@ -95,7 +98,7 @@ pub(crate) fn pin_data(
|
||||
|
||||
FieldInfo {
|
||||
field: &*field,
|
||||
pinned,
|
||||
pinned: pinned_count != 0,
|
||||
cfg_attrs,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user