Visitar URL original
Better diagnostic for relative paths in visibilities by bb1yd · Pull Request #162114 · rust-lang/rust · GitHub
Skip to content

Better diagnostic for relative paths in visibilities - #162114

Open
bb1yd wants to merge 1 commit into
rust-lang:mainfrom
bb1yd:better-diag-for-visibility
Open

bb1yd wants to merge 1 commit into
rust-lang:mainfrom
bb1yd:better-diag-for-visibility

Conversation

@bb1yd

@bb1yd bb1yd commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #118878

Note that the compiler suggest pub(in super) instead of pub(super), because we can only get the span of the path. It is possible to add another field in VisibilityKind::Restricted and pass a span of the entire parentheses for this diagnostic, but it will increase the size of the Item struct, not sure if it's worth doing.

I also change the original message from try to try adding a `crate` prefix because rustc stops inlining the suggestion when there are multiple, and a single word looks weird:

error[E0807]: relative paths are not supported in visibilities in 2018 edition or later
  --> $DIR/E0807.rs:6:5
   |
LL |     pub(in parent) struct Baz;
   |     ^^^^^^^^^^^^^^
   |
help: try
   |
LL |     pub(in crate::parent) struct Baz;
   |            +++++++
help: use `super` if you want this item to be visible in the parent module
   |
LL -     pub(in parent) struct Baz;
LL +     pub(in super) struct Baz;
   |
`

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 1, 2026
@bb1yd
bb1yd force-pushed the better-diag-for-visibility branch 2 times, most recently from 917b062 to db99edf Compare September 1, 2026 10:30
@rust-log-analyzer

This comment has been minimized.

@bb1yd
bb1yd force-pushed the better-diag-for-visibility branch from db99edf to 753af44 Compare September 1, 2026 10:57
@bb1yd
bb1yd marked this pull request as ready for review September 1, 2026 14:50
@rustbot

rustbot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 1, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 1, 2026
@rustbot

rustbot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

@bb1yd
bb1yd marked this pull request as draft October 12, 2026 07:23
@rustbot rustbot 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 Oct 12, 2026
@bb1yd
bb1yd marked this pull request as ready for review October 17, 2026 05:47
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 17, 2026
@rustbot

This comment has been minimized.

@bb1yd
bb1yd force-pushed the better-diag-for-visibility branch from 753af44 to c1ba15c Compare October 17, 2026 06:26
@rustbot

rustbot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

Better help for pub(in parent) in edition 2018 and beyond

4 participants