Skip to content

privacy: Fix type privacy holes when it doesn't cause too much breakage#152543

Open
petrochenkov wants to merge 1 commit intorust-lang:mainfrom
petrochenkov:rprivtit2
Open

privacy: Fix type privacy holes when it doesn't cause too much breakage#152543
petrochenkov wants to merge 1 commit intorust-lang:mainfrom
petrochenkov:rprivtit2

Conversation

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Feb 12, 2026

View all comments

A subset of #146470.

Private types in RPITITs now report hard errors.
Private types in bounds of associated types still only report the private_bounds lint due to unacceptable amount of breakage (#146470 (comment)).

Closes #144139

@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 Feb 12, 2026
@petrochenkov
Copy link
Contributor Author

@bors try

rust-bors bot pushed a commit that referenced this pull request Feb 12, 2026
privacy: Fix type privacy holes when it doesn't cause too much breakage
@rust-bors

This comment has been minimized.

@petrochenkov
Copy link
Contributor Author

TODO: @craterbot check p=1 crates=https://crater-reports.s3.amazonaws.com/pr-146470-3/retry-regressed-list.txt

@petrochenkov petrochenkov marked this pull request as ready for review February 12, 2026 15:38
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 12, 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 Feb 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 12, 2026

r? @fmease

rustbot has assigned @fmease.
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 68 candidates
  • Random selection from 16 candidates

@petrochenkov petrochenkov added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 12, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 12, 2026

☀️ Try build successful (CI)
Build commit: fcfb0ff (fcfb0ffc7ed7fc631df1136063939ef648434735, parent: 7ad4e69ad585d8ff214f7b42d01f1959eda08f40)

@petrochenkov
Copy link
Contributor Author

@craterbot
Copy link
Collaborator

👌 Experiment pr-152543 created and queued.
🤖 Automatically detected try build fcfb0ff
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-152543 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@traviscross traviscross added the I-lang-radar Items that are on lang's radar and will need eventual work or consideration. label Feb 12, 2026
@craterbot
Copy link
Collaborator

🎉 Experiment pr-152543 is completed!
📊 27 regressed and 0 fixed (5514 total)
📊 267 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-152543/retry-regressed-list.txt

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Feb 12, 2026
@petrochenkov petrochenkov 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 Feb 13, 2026
@petrochenkov
Copy link
Contributor Author

Crater results are basically the same as #146470 without the second commit (see e.g. #146470 (comment)).

@petrochenkov
Copy link
Contributor Author

Previous FCP - #146470 (comment).

@petrochenkov petrochenkov added T-lang Relevant to the language team and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 13, 2026
@petrochenkov petrochenkov added S-waiting-on-t-lang Status: Awaiting decision from T-lang I-lang-nominated Nominated for discussion during a lang team meeting. labels Feb 13, 2026
@traviscross traviscross added the P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang label Feb 14, 2026
@traviscross
Copy link
Contributor

We talked about this in the lang call last week. @petrochenkov, it'd be helpful to us to have a brief write-up of what's being proposed here and what's changed since our FCP in #146470 (comment).

@petrochenkov
Copy link
Contributor Author

and what's changed since our FCP in #146470 (comment).

Nothing is changed since the FCP in #146470 (comment).

@petrochenkov
Copy link
Contributor Author

The previous summary (#146470 (comment)) is still relevant, except user-written private bounds on associated types are not turned into an error due to the amount breakage.

pub trait PubTrait {
  fn foo1() -> impl PrivTrait; // error now
  fn foo2() -> impl PubTrait<PrivType>; // error now

  type A1: PrivTrait; // not error, too much breakage (but reports `private_bounds` lint)
  type A2: PubTrait<PrivType>; // not error, too much breakage (but reports `private_bounds` lint)
}

@traviscross
Copy link
Contributor

traviscross commented Mar 11, 2026

Thanks for that. For my part, I'm still motivated to fix the asymmetry with RPIT, so:

@rfcbot fcp merge lang

It is a bit inelegant that we're left, for now, with an asymmetry between RPITIT and associated types. If we were to turn out to need this space, e.g., to make a future feature sound, we'd need to fix that.

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Mar 11, 2026

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Mar 11, 2026
@scottmcm
Copy link
Member

scottmcm commented Mar 11, 2026

Making RPITIT match the RPIT behaviour makes sense to me.

(TBH it's not obvious to me that private bounds on an associated type are even a "problem" that we'd need to fix, but now that this isn't changing that, sure, happy to make it consistent in function return position. Especially if the public trait is sealed, having various non-public bounds on things doesn't seem unreasonable.)

@rfcbot reviewed

@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Mar 11, 2026
@tmandry
Copy link
Member

tmandry commented Mar 11, 2026

Agreed with @scottmcm. I'm happy to make things more consistent and save space for another model in the future. Not sure we'll need this restriction in the long run.

@rfcbot reviewed

@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Mar 11, 2026
@rust-rfcbot
Copy link
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Mar 11, 2026

Soooooo I still feel like I am missing a mental model for what we are attempting to achieve with our rules around privacy and private traits. It makes all of these changes feel kind of random to me. That said, I think we previously decided to move forward here, and this seems consistent with that, and RPITIT/RPIT consistency is good, and it seems like this will give us room to make more decisions in the future, so....

@rfcbot reviewed

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-t-lang Status: Awaiting decision from T-lang T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(re-)Fix private-in-public for RPITIT

9 participants