Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 1eed20b

Browse files
committed
Deny missing no_panic and inline attrs
1 parent 63ec2ef commit 1eed20b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

crates/libm-analyze/src/lib.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,22 +211,26 @@ fn get_functions(files: &[syn::File]) -> Vec<FnSig> {
211211
syn_to_str!(generics.clone())
212212
));
213213
}
214-
// FIXME: we can do better here, but right now, we should
215-
// error if inline and no_panic are not used, which is the
216-
// case if the public API has no attributes.
217-
//
218-
// We might also want to check other attributes as well.
219214
if attrs.is_empty() {
220-
let e2 = e;
221215
err!(format!(
222-
"missing `#[inline]` and `#[no_panic]` attributes {}",
223-
attrs
224-
.iter()
225-
.map(|a| syn_to_str!(a))
226-
.collect::<Vec<_>>()
227-
.join(",")
216+
"missing `#[inline]` and `#[no_panic]` attributes"
228217
));
229-
e = e2;
218+
} else {
219+
let attrs = attrs
220+
.iter()
221+
.map(|a| syn_to_str!(a))
222+
.collect::<Vec<_>>()
223+
.join(",");
224+
if !attrs.contains("inline") {
225+
err!(format!(
226+
"missing `#[inline]` attribute"
227+
));
228+
}
229+
if !attrs.contains("no_panic") {
230+
err!(format!(
231+
"missing `#[no_panic]` attributes"
232+
));
233+
}
230234
}
231235
// Validate and parse output parameters and function arguments:
232236
match output {

0 commit comments

Comments
 (0)