Skip to content

Commit b82c7c3

Browse files
authored
Unrolled build for rust-lang#115633
Rollup merge of rust-lang#115633 - compiler-errors:PRIVATE_BOUNDS-lint-node, r=petrochenkov Lint node for `PRIVATE_BOUNDS`/`PRIVATE_INTERFACES` is the item which names the private type The HIR that the `PRIVATE_BOUNDS` lint should be attached to is the item that has the *bounds*, not the private type. This PR also aligns this behavior with the `EXPORTED_PRIVATE_DEPENDENCIES` lint, which also requires putting the `allow` on the item that names the private type. Fixes rust-lang#115475 r? petrochenkov
2 parents cd71a37 + 14e59bb commit b82c7c3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compiler/rustc_privacy/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1463,14 +1463,15 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
14631463
};
14641464

14651465
let vis = self.tcx.local_visibility(local_def_id);
1466-
let hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
14671466
let span = self.tcx.def_span(self.item_def_id.to_def_id());
14681467
let vis_span = self.tcx.def_span(def_id);
14691468
if self.in_assoc_ty && !vis.is_at_least(self.required_visibility, self.tcx) {
14701469
let vis_descr = match vis {
14711470
ty::Visibility::Public => "public",
14721471
ty::Visibility::Restricted(vis_def_id) => {
1473-
if vis_def_id == self.tcx.parent_module(hir_id).to_local_def_id() {
1472+
if vis_def_id
1473+
== self.tcx.parent_module_from_def_id(local_def_id).to_local_def_id()
1474+
{
14741475
"private"
14751476
} else if vis_def_id.is_top_level_module() {
14761477
"crate-private"
@@ -1504,7 +1505,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> {
15041505
};
15051506
self.tcx.emit_spanned_lint(
15061507
lint,
1507-
hir_id,
1508+
self.tcx.hir().local_def_id_to_hir_id(self.item_def_id),
15081509
span,
15091510
PrivateInterfacesOrBoundsLint {
15101511
item_span: span,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// check-pass
2+
// compile-flags: --crate-type=lib
3+
4+
#[allow(private_bounds)]
5+
pub trait Foo: FooImpl {}
6+
7+
trait FooImpl {}

0 commit comments

Comments
 (0)