From e4b1e2803378e1f4eb6eff0d5042e15239fae6e2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 30 Aug 2024 16:15:56 +1000 Subject: [PATCH] Add `warn(unreachable_pub)` to `rustc_transmute`. --- compiler/rustc_transmute/src/layout/tree.rs | 2 +- compiler/rustc_transmute/src/layout/tree/tests.rs | 2 +- compiler/rustc_transmute/src/lib.rs | 1 + compiler/rustc_transmute/src/maybe_transmutable/mod.rs | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index 2c67e7d4847..c3fd771b797 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -204,7 +204,7 @@ fn from(err: &LayoutError<'tcx>) -> Self { } impl<'tcx> Tree, Ref<'tcx>> { - pub fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Result { + pub(crate) fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Result { use rustc_target::abi::HasDataLayout; let layout = layout_of(cx, ty)?; diff --git a/compiler/rustc_transmute/src/layout/tree/tests.rs b/compiler/rustc_transmute/src/layout/tree/tests.rs index 3cb47517c21..44f50a25c93 100644 --- a/compiler/rustc_transmute/src/layout/tree/tests.rs +++ b/compiler/rustc_transmute/src/layout/tree/tests.rs @@ -1,7 +1,7 @@ use super::Tree; #[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)] -pub enum Def { +enum Def { NoSafetyInvariants, HasSafetyInvariants, } diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index bdc98bcea5e..c1d0b704ab2 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -2,6 +2,7 @@ #![allow(unused_variables)] #![feature(alloc_layout_extra)] #![feature(never_type)] +#![warn(unreachable_pub)] // tidy-alphabetical-end pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set}; diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index 2762b4e6384..b3e1bb31e58 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -366,13 +366,13 @@ fn or(lhs: Answer, rhs: Answer) -> Answer } } -pub enum Quantifier { +enum Quantifier { ThereExists, ForAll, } impl Quantifier { - pub fn apply(&self, iter: I) -> Answer + fn apply(&self, iter: I) -> Answer where R: layout::Ref, I: IntoIterator>,