-
Notifications
You must be signed in to change notification settings - Fork 187
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
Basic unsafe
support
#569
Basic unsafe
support
#569
Conversation
Codecov Report
@@ Coverage Diff @@
## master #569 +/- ##
==========================================
- Coverage 86.67% 86.63% -0.04%
==========================================
Files 87 87
Lines 6362 6428 +66
==========================================
+ Hits 5514 5569 +55
- Misses 848 859 +11
Continue to review full report at Codecov.
|
@@ -25,6 +26,17 @@ pub fn function_signature( | |||
let mut scope = ItemScope::new(db, function.module(db)); | |||
let contract = function.contract(db); | |||
|
|||
if_chain! { |
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.
Sweet helper :)
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! I think there's one incorrect error message though.
"`pub` visibility modifier must come before `unsafe`", | ||
vec![Label::primary( | ||
unsafe_span + pub_.span, | ||
"use `pub unsafe` here", |
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've decided to enforce the rule that contract functions can be either pub or unsafe, but not both
As I understand pub unsafe
is a compile time error so the error message of "use pub unsafe here"
seems to be misleading.
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.
pub unsafe
is allowed on functions defined at the module level, and will be allowed for struct functions, but it is misleading for contracts. I guess I'm inclined to just leave this, rather than add special behavior here for fns inside contracts.
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.
Ah, understood 👍
This adds basic support for unsafe functions and unsafe blocks. This doesn't add any built-in unsafe functions; someday soon there will be some fun unsafe fns in a
std::evm
module, but that'll come in a separate PR. So there's currently no point in using any of this.I've decided to enforce the rule that contract functions can be either pub or unsafe, but not both. I don't have strong feelings about this, it just seemed reasonable.
To-Do
OPTIONAL: Update Spec if applicable
Add entry to the release notes (may forgo for trivial changes)
Clean up commit history