1
Fork 0

Add warn(unreachable_pub) to rustc_codegen_ssa.

This commit is contained in:
Nicholas Nethercote 2024-07-06 22:30:39 +10:00
parent 61627438eb
commit cc8444274b
4 changed files with 8 additions and 7 deletions

View file

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

View file

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

View file

@ -12,6 +12,7 @@
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(strict_provenance)] #![feature(strict_provenance)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
//! This crate contains codegen code that is used by all codegen backends (LLVM and others). //! This crate contains codegen code that is used by all codegen backends (LLVM and others).

View file

@ -13,7 +13,7 @@ use tracing::debug;
use super::FunctionCx; use super::FunctionCx;
use crate::traits::*; use crate::traits::*;
pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( pub(crate) fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
fx: &FunctionCx<'a, 'tcx, Bx>, fx: &FunctionCx<'a, 'tcx, Bx>,
) -> BitSet<mir::Local> { ) -> BitSet<mir::Local> {
let mir = fx.mir; let mir = fx.mir;
@ -251,14 +251,14 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum CleanupKind { pub(crate) enum CleanupKind {
NotCleanup, NotCleanup,
Funclet, Funclet,
Internal { funclet: mir::BasicBlock }, Internal { funclet: mir::BasicBlock },
} }
impl CleanupKind { impl CleanupKind {
pub fn funclet_bb(self, for_bb: mir::BasicBlock) -> Option<mir::BasicBlock> { pub(crate) fn funclet_bb(self, for_bb: mir::BasicBlock) -> Option<mir::BasicBlock> {
match self { match self {
CleanupKind::NotCleanup => None, CleanupKind::NotCleanup => None,
CleanupKind::Funclet => Some(for_bb), CleanupKind::Funclet => Some(for_bb),
@ -270,7 +270,7 @@ impl CleanupKind {
/// MSVC requires unwinding code to be split to a tree of *funclets*, where each funclet can only /// MSVC requires unwinding code to be split to a tree of *funclets*, where each funclet can only
/// branch to itself or to its parent. Luckily, the code we generates matches this pattern. /// branch to itself or to its parent. Luckily, the code we generates matches this pattern.
/// Recover that structure in an analyze pass. /// Recover that structure in an analyze pass.
pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> { pub(crate) fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
fn discover_masters<'tcx>( fn discover_masters<'tcx>(
result: &mut IndexSlice<mir::BasicBlock, CleanupKind>, result: &mut IndexSlice<mir::BasicBlock, CleanupKind>,
mir: &mir::Body<'tcx>, mir: &mir::Body<'tcx>,