-
Notifications
You must be signed in to change notification settings - Fork 742
Add #[must_use] to functions annotated with __attribute__((warn_unused_result)) #1451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you! Just some minor nits, looks good to go otherwise :)
src/ir/function.rs
Outdated
@@ -387,6 +392,24 @@ impl FunctionSig { | |||
} | |||
}; | |||
|
|||
let mut must_use = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move all this block to a function in clang.rs
, probably a method of cursor
?
Something like the following maybe:
pub fn has_simple_attr(&self, attr: &str) -> bool;
Then this code could just be:
let must_use = cursor.has_simple_attribute("warn_unused_result");
WDYT?
src/ir/function.rs
Outdated
abi: Abi, | ||
) -> Self { | ||
FunctionSig { | ||
return_type: return_type, | ||
argument_types: arguments, | ||
is_variadic: is_variadic, | ||
must_use: must_use, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's pre-existing, but if you want this can just be must_use,
(same for the other members).
Alright, pushed some changes to address your comments. Thanks for the quick review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks amazing :)
return_type, | ||
argument_types, | ||
is_variadic, | ||
must_use, | ||
abi: abi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could've done this for abi
as well, but no big deal in any case :)
@bors-servo r+ |
Ah, forgot bors is still dead. |
First pass at implementing #1450. Take a look at the tests to see the behavior difference on rustc 1.27.
r? @emilio