-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
feat: function privacy leak validator #338
Conversation
crates/mun_hir/src/expr/validator.rs
Outdated
|
||
param_types | ||
.chain(std::iter::once(ret_ty)) | ||
.filter(type_is_not_allowed) |
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.
add .take(1) to show only a single diagnostic per function
Thanks for this! Would it be possible to highlight the region of the type thas has a more private type? So in the case of:
|
3e72c8b
to
36c93d8
Compare
Alright, I've changed the diagnostic to highlight the type, but it's a bit harder to make it actually display the type name in the diagnostic message. I don't think it's a big deal since the name is highlighted anyway though.
|
You can implement something in The goal of Adding the name is not required perse but I think it will provide users with a much better experience down the road. |
Codecov Report
@@ Coverage Diff @@
## master #338 +/- ##
==========================================
+ Coverage 80.24% 80.30% +0.06%
==========================================
Files 258 259 +1
Lines 15572 15637 +65
==========================================
+ Hits 12496 12558 +62
- Misses 3076 3079 +3
Continue to review full report at Codecov.
|
36c93d8
to
0f52b00
Compare
I've added a |
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! 👍
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 good overall. I had one question
|
||
impl Diagnostic for ExportedPrivate { | ||
fn message(&self) -> String { | ||
"can't leak private type".to_string() |
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.
We have duplication of this error message. Is there a way to reuse it to avoid code+paste errors?
Other occurance:
https://github.com/mun-lang/mun/pull/338/files#diff-7a57632f7acc9a0b1abad5ef6f9447f95fabecf03312d0ab7d0597807ae8e25dR24
0f52b00
to
070807b
Compare
I've updated it so that there's no duplication |
Added a validation for privacy leaks in function signatures, added a few tests, and updated existing tests/examples
070807b
to
f0a27e3
Compare
Part of #309
Adds a validation for leaking private types from function signatures