Skip to content
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

Lint node for PRIVATE_BOUNDS/PRIVATE_INTERFACES is the item which names the private type #115633

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1463,14 +1463,15 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
};

let vis = self.tcx.local_visibility(local_def_id);
let hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
let span = self.tcx.def_span(self.item_def_id.to_def_id());
let vis_span = self.tcx.def_span(def_id);
if self.in_assoc_ty && !vis.is_at_least(self.required_visibility, self.tcx) {
let vis_descr = match vis {
ty::Visibility::Public => "public",
ty::Visibility::Restricted(vis_def_id) => {
if vis_def_id == self.tcx.parent_module(hir_id).to_local_def_id() {
if vis_def_id
== self.tcx.parent_module_from_def_id(local_def_id).to_local_def_id()
{
"private"
} else if vis_def_id.is_top_level_module() {
"crate-private"
Expand Down Expand Up @@ -1504,7 +1505,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
};
self.tcx.emit_spanned_lint(
lint,
hir_id,
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id),
petrochenkov marked this conversation as resolved.
Show resolved Hide resolved
span,
PrivateInterfacesOrBoundsLint {
item_span: span,
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/privacy/private-bounds-locally-allowed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// check-pass
// compile-flags: --crate-type=lib

#[allow(private_bounds)]
pub trait Foo: FooImpl {}

trait FooImpl {}
Loading