mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
rust: pin-init: internal: error on duplicate #[pin] attribute
Duplicated `#[pin]` has no effect, thus error if misused. Reported-by: Mohamad Alsadhan <[email protected]> Closes: https://github.com/Rust-for-Linux/pin-init/issues/119 Signed-off-by: Luiz Georg <[email protected]> Link: https://patch.msgid.link/[email protected] [ Reworded commit message, and change the logic so code generation still continue after reporting error - Gary ] Signed-off-by: Gary Guo <[email protected]>
This commit is contained in:
1 parent
a13c140cc2
commit
f26f2f22c6
1 file changed
+5
-2
@@ -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