proc_macro: add #![warn(unreachable_pub)]

This commit is contained in:
Urgau 2025-01-09 22:44:39 +01:00
parent 6a64e3b897
commit bf5e634b68
5 changed files with 8 additions and 7 deletions

View file

@ -3,7 +3,7 @@
use std::marker::PhantomData; use std::marker::PhantomData;
#[repr(C)] #[repr(C)]
pub struct Closure<'a, A, R> { pub(super) struct Closure<'a, A, R> {
call: unsafe extern "C" fn(*mut Env, A) -> R, call: unsafe extern "C" fn(*mut Env, A) -> R,
env: *mut Env, env: *mut Env,
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing // Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing
@ -26,7 +26,7 @@ impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
} }
impl<'a, A, R> Closure<'a, A, R> { impl<'a, A, R> Closure<'a, A, R> {
pub fn call(&mut self, arg: A) -> R { pub(super) fn call(&mut self, arg: A) -> R {
unsafe { (self.call)(self.env, arg) } unsafe { (self.call)(self.env, arg) }
} }
} }

View file

@ -9,7 +9,7 @@ use std::hash::{BuildHasherDefault, Hasher};
use std::ops::BitXor; use std::ops::BitXor;
/// Type alias for a hashmap using the `fx` hash algorithm. /// Type alias for a hashmap using the `fx` hash algorithm.
pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>; pub(super) type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
/// A speedy hash algorithm for use within rustc. The hashmap in alloc by /// A speedy hash algorithm for use within rustc. The hashmap in alloc by
/// default uses SipHash which isn't quite as speedy as we want. In the compiler /// default uses SipHash which isn't quite as speedy as we want. In the compiler
@ -23,7 +23,7 @@ pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
/// similar or slightly worse than FNV, but the speed of the hash function /// similar or slightly worse than FNV, but the speed of the hash function
/// itself is much higher because it works on up to 8 bytes at a time. /// itself is much higher because it works on up to 8 bytes at a time.
#[derive(Default)] #[derive(Default)]
pub struct FxHasher { pub(super) struct FxHasher {
hash: usize, hash: usize,
} }

View file

@ -67,7 +67,7 @@ macro_rules! rpc_encode_decode {
mod tag { mod tag {
#[repr(u8)] enum Tag { $($variant),* } #[repr(u8)] enum Tag { $($variant),* }
$(pub const $variant: u8 = Tag::$variant as u8;)* $(pub(crate) const $variant: u8 = Tag::$variant as u8;)*
} }
match self { match self {
@ -89,7 +89,7 @@ macro_rules! rpc_encode_decode {
mod tag { mod tag {
#[repr(u8)] enum Tag { $($variant),* } #[repr(u8)] enum Tag { $($variant),* }
$(pub const $variant: u8 = Tag::$variant as u8;)* $(pub(crate) const $variant: u8 = Tag::$variant as u8;)*
} }
match u8::decode(r, s) { match u8::decode(r, s) {

View file

@ -44,7 +44,7 @@ macro_rules! define_reify_functions {
fn $name:ident $(<$($param:ident),*>)? fn $name:ident $(<$($param:ident),*>)?
for $(extern $abi:tt)? fn($($arg:ident: $arg_ty:ty),*) -> $ret_ty:ty; for $(extern $abi:tt)? fn($($arg:ident: $arg_ty:ty),*) -> $ret_ty:ty;
)+) => { )+) => {
$(pub const fn $name< $(pub(super) const fn $name<
$($($param,)*)? $($($param,)*)?
F: Fn($($arg_ty),*) -> $ret_ty + Copy F: Fn($($arg_ty),*) -> $ret_ty + Copy
>(f: F) -> $(extern $abi)? fn($($arg_ty),*) -> $ret_ty { >(f: F) -> $(extern $abi)? fn($($arg_ty),*) -> $ret_ty {

View file

@ -32,6 +32,7 @@
#![allow(internal_features)] #![allow(internal_features)]
#![deny(ffi_unwind_calls)] #![deny(ffi_unwind_calls)]
#![warn(rustdoc::unescaped_backticks)] #![warn(rustdoc::unescaped_backticks)]
#![warn(unreachable_pub)]
#[unstable(feature = "proc_macro_internals", issue = "27812")] #[unstable(feature = "proc_macro_internals", issue = "27812")]
#[doc(hidden)] #[doc(hidden)]