-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Adds lint for public function ABI change #546
Adds lint for public function ABI change #546
Conversation
710cb32
to
9f44a08
Compare
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 in very good shape, and I'm looking forward to merging it soon! Just a couple of minor tweaks and suggestions to further improve it and it's good to go — should only take just another minute of your time or so.
Thanks for putting this together! 🚀
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} |
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.
Probably best if we grab the span info of the current function (instead of the baseline) so we can point to the file+line in the current code where the user should look.
|
||
pub extern "Rust" fn implicit_c_function_becomes_rust() -> () {} | ||
|
||
pub extern "Rust" fn rust_function_remains_rust() -> () {} |
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.
Suggestion for a couple more cases here:
- an explicitly-Rust ABI function remains Rust ABI but implicitly so, by removing the
extern "Rust"
- the same thing in the opposite direction: adding explicit Rust ABI to an already implicitly-Rust ABI function
These cases are important guards against possible false-positives, which are very annoying for users and so are at least as important to protect against as the test cases for true-positives that make sure our functionality continues to work.
"public": "public", | ||
"zero": 0, | ||
}, | ||
error_message: "A publicly-visible function changed it's ABI type.", |
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.
error_message: "A publicly-visible function changed it's ABI type.", | |
error_message: "A publicly-visible function changed its 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.
Just consistency with the text below.
"zero": 0, | ||
}, | ||
error_message: "A publicly-visible function changed it's ABI type.", | ||
per_result_error_template: Some("function {{join \"::\" path}} changed ABI type from {{abi_name}} to {{new_abi_name}} in {{span_filename}}:{{span_begin_line}}"), |
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.
per_result_error_template: Some("function {{join \"::\" path}} changed ABI type from {{abi_name}} to {{new_abi_name}} in {{span_filename}}:{{span_begin_line}}"), | |
per_result_error_template: Some("{{join \"::\" path}} changed ABI from {{abi_name}} to {{new_abi_name}} in {{span_filename}}:{{span_begin_line}}"), |
We really want to try to fit this on one line in the terminal, so brevity is everything.
abi @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) { | ||
name @filter(op: "=", value: ["%name"]) | ||
} | ||
|
||
new_abi_: abi { | ||
name @output | ||
} |
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.
Functions are guaranteed to have exactly one ABI: we see this in the Trustfall schema where the ABI edge is defined abi: FunctionAbi!
meaning exactly one neighboring vertex.
That makes this combination of query clauses equivalent to:
abi @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) { | |
name @filter(op: "=", value: ["%name"]) | |
} | |
new_abi_: abi { | |
name @output | |
} | |
new_abi_: abi { | |
name @filter(op: "!=", value: ["%name"]) @output | |
} |
In the original, we say a combination of "there is no matching ABI" + "get the actual ABI here." In the revised version I'm suggesting, we just say "the ABI that exists is not a match." This is the same thing when there's exactly one ABI, no more and no less. If there could be zero or more than one ABI, that wouldn't be equivalent and we'd need a structure like the original one here.
Actually I'm not sure about the convention for the lint name. I went with: |
Oof, we don't have any official convention but we probably should. Let's omit |
Heads up that I'm planning to publish a new release soon, probably on Sunday. I'd be happy to merge and ship this new lint, but it's also totally okay if we don't get it there in time. I just wanted to let you know my plans so you don't feel surprised to see it 👍 Thanks again for contributing! |
4453efc
to
b84724f
Compare
|
Awesome stuff, merging! Thanks for putting it together, much appreciated 🚀 |
Adds a new lint for extern function ABI changes.
I've left the unwind cases for now (this can be the next lint). If you'd like any more examples please let me know. This hopefully closes the first bullet point on this issue: #503