Skip to content

Commit

Permalink
collecting multiple errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheukting committed Jun 12, 2024
1 parent f66124a commit 6231d2a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions pyo3-macros-backend/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,28 @@ pub fn take_attributes(

pub fn take_pyo3_options<T: Parse>(attrs: &mut Vec<syn::Attribute>) -> Result<Vec<T>> {
let mut out = Vec::new();
take_attributes(attrs, |attr| {
if let Some(options) = get_pyo3_options(attr)? {
out.extend(options);
let mut allerr = Vec::new();
take_attributes(attrs, |attr| match get_pyo3_options(attr) {
Ok(result) => {
if let Some(options) = result {
out.extend(options);
Ok(true)
} else {
Ok(false)
}
}
Err(err) => {
allerr.extend(err);
Ok(true)
} else {
Ok(false)
}
})?;
Ok(out)
if !allerr.is_empty() {
let mut error = allerr[0].clone();
for err in &allerr[1..] {
error.combine(err.clone());
}
Err(error)
} else {
Ok(out)
}
}

0 comments on commit 6231d2a

Please sign in to comment.