-
Notifications
You must be signed in to change notification settings - Fork 148
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
unsafe: check uses of static variables #1417
Conversation
This allows us to perform checks and dispatch when getting an HIR::Item* from Mappings::lookup_hir_item()
Using a mutable static or an extern static requires an unsafe function or block
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.
Nice work. LGTM
Something we might start to think about doing is for every error diagnostic have some kind of class for them all, so we can enforce good error messages so for example we might have:
class ErrorDiagnostics {
static void EStaticMutableUnsafe(Location) { }
}
NodeId ref_node_id; | ||
HirId definition_id; | ||
|
||
if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id)) |
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.
This is good, ideally this pass should be permissive of saw_errors eventually but we need to have the safe interface for the type context to return error nodes instead of nullptr to do that properly.
Yeah, this will definitely come in handy when adding error codes as well! I'll open up an issue regarding this |
bors r+ |
Build succeeded: |
Addresses #1411
Accessing an extern static or a mut static is unsafe and requires an unsafe function or block