Skip to content

Suggest pub when public is used #99706

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

Closed
wants to merge 4 commits into from
Closed

Suggest pub when public is used #99706

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 25, 2022

Fixes #99653

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 25, 2022
@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2022
@rust-log-analyzer

This comment has been minimized.

@ghost ghost changed the title Add public diag Suggest pub when public is used Jul 25, 2022
@rust-log-analyzer

This comment has been minimized.

@JohnTitor
Copy link
Member

Could you add a UI test to ensure your change works as expected? There's a guide for it: https://rustc-dev-guide.rust-lang.org/tests/adding.html

Also, it'd be great if you could squash commits not to show up unrelated changes in Git history.

@ghost
Copy link
Author

ghost commented Jul 25, 2022

I've already squashed, adding UI tests 👍🏻

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with a test case

@davidtwco davidtwco added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2022
@ghost
Copy link
Author

ghost commented Jul 26, 2022

Added tests and squashed

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, would appreciate if you could move the test (and fix the other nits if you're so inclined) and then I'll r=me :)

// Checks what happens when `public` is used instead of the correct, `pub`
// edition:2018
public struct MyStruct;
//~^ ERROR 3:8: 3:14: expected one of `!` or `::`, found keyword `struct`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//~^ ERROR 3:8: 3:14: expected one of `!` or `::`, found keyword `struct`
//~^ ERROR expected one of `!` or `::`, found keyword `struct`

nit: you don't need to include the line/column numbers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failed when I didn't include the line/column

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It definitely shouldn't - almost every test is written with error annotations that don't include the line/column numbers. What error are you seeing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the line/column makes it fail like this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you just need to --bless the test again. The important part of that error is where it says "The actual fixed differed from the expected fixed" - that just means that the output it gets from running rustfix on the test is different from what it expects the output to be (this happens when you first add // run-rustfix, or when the test changes such that the output is genuinely different, such as if it the output had the comment with line numbers in it).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/rust-lang/rust/runs/7518469562?check_suite_focus=true

This also happens in CI, blessing the test again in a minute

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@davidtwco
Copy link
Member

Could you rebase instead of merging? See our no merge policy :)

@ghost
Copy link
Author

ghost commented Jul 29, 2022

[I have accidentally messed up and mixed my commit history of this branch with something else, closing and re-opening with a new PR, sorry]

@Dylan-DPC Dylan-DPC removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 29, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 30, 2022
Add diagnostic when using public instead of pub

Forwarding from rust-lang#99706

I accidentally broke something(??) in git and the commits in that PR are absolutely not what I did in that branch

Anyways, this is the PR for this now. Adding tests again in a minute.

cc `@davidtwco`
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recover from 'public' in 'pub' position
8 participants