Skip to content

Commit d113b5b

Browse files
authored
Rollup merge of #114246 - Bryanskiy:type-privacy-lints-fixes, r=petrochenkov
Weaken unnameable_types lint `unnameable_types` lint is no longer emitted for - associated types - internal types r? ``@petrochenkov``
2 parents b192576 + 8203d1d commit d113b5b

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

compiler/rustc_privacy/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
19411941
let reexported_at_vis = effective_vis.at_level(Level::Reexported);
19421942
let reachable_at_vis = effective_vis.at_level(Level::Reachable);
19431943

1944-
if reexported_at_vis != reachable_at_vis {
1944+
if reachable_at_vis.is_public() && reexported_at_vis != reachable_at_vis {
19451945
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
19461946
let span = self.tcx.def_span(def_id.to_def_id());
19471947
self.tcx.emit_spanned_lint(
@@ -1973,10 +1973,6 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
19731973
AssocItemKind::Type => (self.tcx.defaultness(def_id).has_value(), true),
19741974
};
19751975

1976-
if is_assoc_ty {
1977-
self.check_unnameable(def_id, self.get(def_id));
1978-
}
1979-
19801976
check.in_assoc_ty = is_assoc_ty;
19811977
check.generics().predicates();
19821978
if check_ty {

tests/ui/privacy/unnameable_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ mod m {
1111

1212
pub trait PubTr { //~ ERROR trait `PubTr` is reachable but cannot be named
1313
const C : i32 = 0;
14-
type Alias; //~ ERROR associated type `PubTr::Alias` is reachable but cannot be named
14+
type Alias;
1515
fn f() {}
1616
}
1717

1818
impl PubTr for PubStruct {
19-
type Alias = i32; //~ ERROR associated type `<PubStruct as PubTr>::Alias` is reachable but cannot be named
19+
type Alias = i32;
2020
fn f() {}
2121
}
2222
}

tests/ui/privacy/unnameable_types.stderr

+1-13
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,5 @@ error: trait `PubTr` is reachable but cannot be named
2222
LL | pub trait PubTr {
2323
| ^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
2424

25-
error: associated type `PubTr::Alias` is reachable but cannot be named
26-
--> $DIR/unnameable_types.rs:14:9
27-
|
28-
LL | type Alias;
29-
| ^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
30-
31-
error: associated type `<PubStruct as PubTr>::Alias` is reachable but cannot be named
32-
--> $DIR/unnameable_types.rs:19:9
33-
|
34-
LL | type Alias = i32;
35-
| ^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
36-
37-
error: aborting due to 5 previous errors
25+
error: aborting due to 3 previous errors
3826

0 commit comments

Comments
 (0)