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

Better diagnostic for relative paths in visibilities#162114
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. in super is valid but tell me if there are better ways to do this :)

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

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