From b457ab31860b9c92fd2a52c7a2ca328a04cdfa23 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 30 Aug 2024 12:59:35 +1000 Subject: [PATCH] Add `warn(unreachable_pub)` to `rustc_smir`. --- compiler/rustc_smir/src/lib.rs | 1 + compiler/rustc_smir/src/rustc_smir/alloc.rs | 4 ++-- compiler/rustc_smir/src/rustc_smir/builder.rs | 6 +++--- compiler/rustc_smir/src/rustc_smir/context.rs | 2 +- compiler/rustc_smir/src/rustc_smir/convert/mod.rs | 2 +- compiler/rustc_smir/src/rustc_smir/convert/ty.rs | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_smir/src/lib.rs b/compiler/rustc_smir/src/lib.rs index 9f888875306..2215e2f01ad 100644 --- a/compiler/rustc_smir/src/lib.rs +++ b/compiler/rustc_smir/src/lib.rs @@ -15,6 +15,7 @@ )] #![doc(rust_logo)] #![feature(rustdoc_internals)] +#![warn(unreachable_pub)] // tidy-alphabetical-end pub mod rustc_internal; diff --git a/compiler/rustc_smir/src/rustc_smir/alloc.rs b/compiler/rustc_smir/src/rustc_smir/alloc.rs index 677b4c7a9c0..11fbc005e37 100644 --- a/compiler/rustc_smir/src/rustc_smir/alloc.rs +++ b/compiler/rustc_smir/src/rustc_smir/alloc.rs @@ -20,7 +20,7 @@ fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation { // because we need to get `Ty` of the const we are trying to create, to do that // we need to have access to `ConstantKind` but we can't access that inside Stable impl. #[allow(rustc::usage_of_qualified_ty)] -pub fn new_allocation<'tcx>( +pub(crate) fn new_allocation<'tcx>( ty: rustc_middle::ty::Ty<'tcx>, const_value: ConstValue<'tcx>, tables: &mut Tables<'tcx>, @@ -30,7 +30,7 @@ pub fn new_allocation<'tcx>( } #[allow(rustc::usage_of_qualified_ty)] -pub fn try_new_allocation<'tcx>( +pub(crate) fn try_new_allocation<'tcx>( ty: rustc_middle::ty::Ty<'tcx>, const_value: ConstValue<'tcx>, tables: &mut Tables<'tcx>, diff --git a/compiler/rustc_smir/src/rustc_smir/builder.rs b/compiler/rustc_smir/src/rustc_smir/builder.rs index 883ab7c18b4..cd91fc26c10 100644 --- a/compiler/rustc_smir/src/rustc_smir/builder.rs +++ b/compiler/rustc_smir/src/rustc_smir/builder.rs @@ -12,13 +12,13 @@ use crate::rustc_smir::{Stable, Tables}; /// Builds a monomorphic body for a given instance. -pub struct BodyBuilder<'tcx> { +pub(crate) struct BodyBuilder<'tcx> { tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>, } impl<'tcx> BodyBuilder<'tcx> { - pub fn new(tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>) -> Self { + pub(crate) fn new(tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>) -> Self { let instance = match instance.def { // To get the fallback body of an intrinsic, we need to convert it to an item. ty::InstanceKind::Intrinsic(def_id) => ty::Instance::new(def_id, instance.args), @@ -30,7 +30,7 @@ pub fn new(tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>) -> Self { /// Build a stable monomorphic body for a given instance based on the MIR body. /// /// All constants are also evaluated. - pub fn build(mut self, tables: &mut Tables<'tcx>) -> stable_mir::mir::Body { + pub(crate) fn build(mut self, tables: &mut Tables<'tcx>) -> stable_mir::mir::Body { let body = tables.tcx.instance_mir(self.instance.def).clone(); let mono_body = if !self.instance.args.is_empty() // Without the `generic_const_exprs` feature gate, anon consts in signatures do not diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs index f9663f2dd30..a4ede374a19 100644 --- a/compiler/rustc_smir/src/rustc_smir/context.rs +++ b/compiler/rustc_smir/src/rustc_smir/context.rs @@ -784,7 +784,7 @@ fn unop_ty(&self, un_op: UnOp, arg: Ty) -> Ty { } } -pub struct TablesWrapper<'tcx>(pub RefCell>); +pub(crate) struct TablesWrapper<'tcx>(pub RefCell>); /// Implement error handling for extracting function ABI information. impl<'tcx> FnAbiOfHelpers<'tcx> for Tables<'tcx> { diff --git a/compiler/rustc_smir/src/rustc_smir/convert/mod.rs b/compiler/rustc_smir/src/rustc_smir/convert/mod.rs index 50687935473..c9795fca399 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/mod.rs @@ -9,7 +9,7 @@ mod mir; mod ty; -pub use ty::mir_const_from_ty_const; +pub(crate) use ty::mir_const_from_ty_const; impl<'tcx> Stable<'tcx> for rustc_hir::Safety { type T = stable_mir::mir::Safety; diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index 9afd732486c..efbb0f244fc 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -411,7 +411,7 @@ fn stable(&self, tables: &mut Tables<'_>) -> Self::T { } } -pub fn mir_const_from_ty_const<'tcx>( +pub(crate) fn mir_const_from_ty_const<'tcx>( tables: &mut Tables<'tcx>, ty_const: ty::Const<'tcx>, ty: Ty<'tcx>,