-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add a suggestion to add or remove pub on private-in-public error #112540
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @WaffleLapkin (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
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 could use a better PR title -- somethat that describes what it does, like "add a suggestion to add or remove
pub
on private-in-public error" - this probably needs the UI tests blessed (
./x.py test tests/ui --bless
) or if no UI tests changed due to this modification, then it needs a new UI test demonstrating the changes. - Should this be a suggestion instead of a help message? Ideally we'd be suggesting where to add the "pub".
compiler/rustc_privacy/messages.ftl
Outdated
@@ -8,6 +8,8 @@ privacy_from_private_dep_in_public_interface = | |||
privacy_in_public_interface = {$vis_descr} {$kind} `{$descr}` in public interface | |||
.label = can't leak {$vis_descr} {$kind} | |||
.visibility_label = `{$descr}` declared as {$vis_descr} | |||
.help = - Either remove the `pub` from the function |
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 says "from the function" -- but this isn't always fired on a function, is it?
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 for reviewing my changes. I am not sure if it's always fired on a function, but you are most likely correct. In that case, what would be a better suggestion?
This comment has been minimized.
This comment has been minimized.
r? compiler-errors since they already left a review |
I agree that the initially proposed help message does not conform to the same style as other help messages. We have a standard way of making code suggestions that modifies the original code in the needed way, which is better than a text-only help message. So if the original code says |
@nyurik Sure, we can do that, but I am not sure how, since this is my very first contribution to the rust compiler. So, can you guide me on how I would get the error message to suggest the fix with green underline? |
@aryan-debug thx for contributing! My understanding is that the usual process of a lint/error reporting is that you create one or more suggestions - a I'm not even close to being an expert on the Rust compiler, so take with a grain of salt :) |
P.S. Search *.rs files for |
Marking this as waiting on author, see this comment for instructions how to switch it back when ready to review: #112540 (comment) @rustbot author |
@rustbot review |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Still needs tests blessed 😅 @rustbot author |
No idea how to fix your error without trying it locally, @aryan-debug. Try rebasing your code onto the latest master and blessing your tests again? |
@@ -73,6 +73,8 @@ pub struct InPublicInterface<'a> { | |||
pub descr: DiagnosticArgFromDisplay<'a>, | |||
#[label(privacy_visibility_label)] | |||
pub vis_span: Span, | |||
#[suggestion(code = "", applicability = "maybe-incorrect")] |
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 suggestion isn't actually modifying anything
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 am not sure what it should modify and how to do it
@@ -8,6 +8,7 @@ privacy_from_private_dep_in_public_interface = | |||
privacy_in_public_interface = {$vis_descr} {$kind} `{$descr}` in public interface | |||
.label = can't leak {$vis_descr} {$kind} | |||
.visibility_label = `{$descr}` declared as {$vis_descr} | |||
.suggestion = consider adding `pub` in front of it |
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 wording is a bit awkward, perhaps "consider making the{$descr}
public" or something.
i also don't know if this will unilaterally be applicable. have you tested combinations of items that are already pub(crate)
but being exported in pub
signatures, for example?
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 agree with you so I changed the message to what you suggested.
Also, I am not sure what you mean by that example, sorry
I made a few modifications to this PR in #113983 (since I cannot alter the original one), namely addressing @compiler-errors point about suggesting different visibility modifiers in the help message. |
☔ The latest upstream changes (presumably #113126) made this pull request unmergeable. Please resolve the merge conflicts. |
@aryan-debug FYI: when a PR is ready for review, send a message containing |
@JohnCSimon this PR was updated/refactored a bit in #113983 |
Superseded by #113983 |
Fixes #112284