Rollup merge of #126013 - nnethercote:unreachable_pub, r=Urgau

Add `#[warn(unreachable_pub)]` to a bunch of compiler crates

By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal.

There are plenty more crates to do but this seems like enough for a first PR.

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger
2024-08-27 00:41:57 +02:00
committed by GitHub
76 changed files with 503 additions and 464 deletions

View File

@@ -1207,7 +1207,7 @@ mod win {
/// Get the Windows system OEM code page. This is most notably the code page
/// used for link.exe's output.
pub fn oem_code_page() -> u32 {
pub(super) fn oem_code_page() -> u32 {
unsafe {
let mut cp: u32 = 0;
// We're using the `LOCALE_RETURN_NUMBER` flag to return a u32.
@@ -1230,7 +1230,7 @@ mod win {
///
/// It will fail if the multi-byte string is longer than `i32::MAX` or if it contains
/// any invalid bytes for the expected encoding.
pub fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> {
pub(super) fn locale_byte_str_to_string(s: &[u8], code_page: u32) -> Option<String> {
// `MultiByteToWideChar` requires a length to be a "positive integer".
if s.len() > isize::MAX as usize {
return None;

View File

@@ -754,7 +754,7 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
}
impl<B: WriteBackendMethods> WorkItem<B> {
pub fn module_kind(&self) -> ModuleKind {
fn module_kind(&self) -> ModuleKind {
match *self {
WorkItem::Optimize(ref m) => m.kind,
WorkItem::CopyPostLtoArtifacts(_) | WorkItem::LTO(_) => ModuleKind::Regular,