Repository navigation
Conversation
Collaborator
|
r? @khyperia rustbot has assigned @khyperia. Use Why was this reviewer chosen?The reviewer was selected based on:
|
N1ark
commented
Nov 27, 2026
Comment on lines
+293
to
+299
| impl<'tcx> TyCtxt<'tcx> { | ||
| /// Whether the item is public at the given effective visibility level. | ||
| /// Unlike [`EffectiveVisibilities::is_public_at_level`], this works on foreign items. | ||
| pub fn is_public_at_level(self, def_id: DefId, level: Level) -> bool { | ||
| self.effective_visibility_level(def_id).is_some_and(|l| l >= level) | ||
| } | ||
| } |
Member
Author
There was a problem hiding this comment.
btw i added this to match EffectiveVisibilities::is_public_at_level and for convenience but i don't know exactly what's the policy on adding functions to TyCtxt -- happy to remove it to avoid cluttering the already large amount of inherent methods
Instead of checking whether the supertrait is in the visible parent map, which only contains items reachable from direct dependencies, check whether it is nameable from outside its crate, like we already do for local traits.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #90258 -- that issue was closed but it still occurs, I think it was "fixed" by the leaked trait
RingSlicesbeing removed, not by actually having it's cause fixed :pAlso fixes a diagnostic that considered a foreign trait not provided by that module to be sealed -- see bf3fd5f
We currently don't handle foreign traits correctly when suggesting candidates, as we check
visibilitywhich returns whether the trait ispubbut not whether it's actually exported by the crate.A solution is then to encode effective visibility into crate metadata (as
tcx.effective_visibilitiesonly works on local items). This makes crate metadata slightly bigger but hopefully should be negligible, as it's a simple 4 variant enum. a perf run might be neededAdditionally, this also makes life easier for out-of-tree tools that want to learn effective visibility of items -- in Charon, we have to copy a quite nasty logic from rustc to be able to get this back ^^' fwiw rustdoc does a similar "is this visible" walk here but in that case we also need to check
doc(hidden)so i don't think it's equivalent or replaceableReproducer:
LLM Disclosure: this was implemented with assistance from an LLM as I am unfamiliar with the implementation of the query and metadata systems. I have of course reviewed all code and rewritten all comments etc.