Add warn(unreachable_pub) to rustc_smir.

This commit is contained in:
Nicholas Nethercote 2024-08-30 12:59:35 +10:00
parent 19ff6e6e63
commit b457ab3186
6 changed files with 9 additions and 8 deletions

View File

@ -15,6 +15,7 @@
)] )]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod rustc_internal; pub mod rustc_internal;

View File

@ -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 // 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. // we need to have access to `ConstantKind` but we can't access that inside Stable impl.
#[allow(rustc::usage_of_qualified_ty)] #[allow(rustc::usage_of_qualified_ty)]
pub fn new_allocation<'tcx>( pub(crate) fn new_allocation<'tcx>(
ty: rustc_middle::ty::Ty<'tcx>, ty: rustc_middle::ty::Ty<'tcx>,
const_value: ConstValue<'tcx>, const_value: ConstValue<'tcx>,
tables: &mut Tables<'tcx>, tables: &mut Tables<'tcx>,
@ -30,7 +30,7 @@ pub fn new_allocation<'tcx>(
} }
#[allow(rustc::usage_of_qualified_ty)] #[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>, ty: rustc_middle::ty::Ty<'tcx>,
const_value: ConstValue<'tcx>, const_value: ConstValue<'tcx>,
tables: &mut Tables<'tcx>, tables: &mut Tables<'tcx>,

View File

@ -12,13 +12,13 @@ use rustc_middle::ty::{self, TyCtxt};
use crate::rustc_smir::{Stable, Tables}; use crate::rustc_smir::{Stable, Tables};
/// Builds a monomorphic body for a given instance. /// Builds a monomorphic body for a given instance.
pub struct BodyBuilder<'tcx> { pub(crate) struct BodyBuilder<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
instance: ty::Instance<'tcx>, instance: ty::Instance<'tcx>,
} }
impl<'tcx> BodyBuilder<'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 { let instance = match instance.def {
// To get the fallback body of an intrinsic, we need to convert it to an item. // 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), ty::InstanceKind::Intrinsic(def_id) => ty::Instance::new(def_id, instance.args),
@ -30,7 +30,7 @@ impl<'tcx> BodyBuilder<'tcx> {
/// Build a stable monomorphic body for a given instance based on the MIR body. /// Build a stable monomorphic body for a given instance based on the MIR body.
/// ///
/// All constants are also evaluated. /// 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 body = tables.tcx.instance_mir(self.instance.def).clone();
let mono_body = if !self.instance.args.is_empty() let mono_body = if !self.instance.args.is_empty()
// Without the `generic_const_exprs` feature gate, anon consts in signatures do not // Without the `generic_const_exprs` feature gate, anon consts in signatures do not

View File

@ -784,7 +784,7 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
} }
} }
pub struct TablesWrapper<'tcx>(pub RefCell<Tables<'tcx>>); pub(crate) struct TablesWrapper<'tcx>(pub RefCell<Tables<'tcx>>);
/// Implement error handling for extracting function ABI information. /// Implement error handling for extracting function ABI information.
impl<'tcx> FnAbiOfHelpers<'tcx> for Tables<'tcx> { impl<'tcx> FnAbiOfHelpers<'tcx> for Tables<'tcx> {

View File

@ -9,7 +9,7 @@ mod error;
mod mir; mod mir;
mod ty; 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 { impl<'tcx> Stable<'tcx> for rustc_hir::Safety {
type T = stable_mir::mir::Safety; type T = stable_mir::mir::Safety;

View File

@ -411,7 +411,7 @@ impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
} }
} }
pub fn mir_const_from_ty_const<'tcx>( pub(crate) fn mir_const_from_ty_const<'tcx>(
tables: &mut Tables<'tcx>, tables: &mut Tables<'tcx>,
ty_const: ty::Const<'tcx>, ty_const: ty::Const<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,