From b6101184537b1165cfdd5fc473e04ad4c5b7bffa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Nov 2020 13:13:32 +0100 Subject: Deny unreachable-pub It's very useful when `pub` is equivalent to "this is crate's public API", let's enforce this! Ideally, we should enforce it for local `cargo test`, and only during CI, but that needs https://github.com/rust-lang/cargo/issues/5034. --- crates/proc_macro_api/src/process.rs | 8 ++++---- crates/proc_macro_api/src/rpc.rs | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'crates/proc_macro_api') diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index 51ffcaa78..907cb3db7 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs @@ -30,7 +30,7 @@ pub(crate) struct ProcMacroProcessThread { } impl ProcMacroProcessSrv { - pub fn run( + pub(crate) fn run( process_path: PathBuf, args: impl IntoIterator>, ) -> io::Result<(ProcMacroProcessThread, ProcMacroProcessSrv)> { @@ -48,7 +48,7 @@ impl ProcMacroProcessSrv { Ok((thread, srv)) } - pub fn find_proc_macros( + pub(crate) fn find_proc_macros( &self, dylib_path: &Path, ) -> Result, tt::ExpansionError> { @@ -58,7 +58,7 @@ impl ProcMacroProcessSrv { Ok(result.macros) } - pub fn custom_derive( + pub(crate) fn custom_derive( &self, dylib_path: &Path, subtree: &Subtree, @@ -75,7 +75,7 @@ impl ProcMacroProcessSrv { Ok(result.expansion) } - pub fn send_task(&self, req: Request) -> Result + pub(crate) fn send_task(&self, req: Request) -> Result where R: TryFrom, { diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs index 47624163e..203109ca4 100644 --- a/crates/proc_macro_api/src/rpc.rs +++ b/crates/proc_macro_api/src/rpc.rs @@ -75,18 +75,18 @@ struct TokenIdDef(u32); #[serde(remote = "Delimiter")] struct DelimiterDef { #[serde(with = "TokenIdDef")] - pub id: TokenId, + id: TokenId, #[serde(with = "DelimiterKindDef")] - pub kind: DelimiterKind, + kind: DelimiterKind, } #[derive(Serialize, Deserialize)] #[serde(remote = "Subtree")] struct SubtreeDef { #[serde(default, with = "opt_delimiter_def")] - pub delimiter: Option, + delimiter: Option, #[serde(with = "vec_token_tree")] - pub token_trees: Vec, + token_trees: Vec, } #[derive(Serialize, Deserialize)] @@ -112,19 +112,19 @@ enum LeafDef { #[derive(Serialize, Deserialize)] #[serde(remote = "Literal")] struct LiteralDef { - pub text: SmolStr, + text: SmolStr, #[serde(with = "TokenIdDef")] - pub id: TokenId, + id: TokenId, } #[derive(Serialize, Deserialize)] #[serde(remote = "Punct")] struct PunctDef { - pub char: char, + char: char, #[serde(with = "SpacingDef")] - pub spacing: Spacing, + spacing: Spacing, #[serde(with = "TokenIdDef")] - pub id: TokenId, + id: TokenId, } #[derive(Serialize, Deserialize)] @@ -137,16 +137,16 @@ enum SpacingDef { #[derive(Serialize, Deserialize)] #[serde(remote = "Ident")] struct IdentDef { - pub text: SmolStr, + text: SmolStr, #[serde(with = "TokenIdDef")] - pub id: TokenId, + id: TokenId, } mod opt_delimiter_def { use super::{Delimiter, DelimiterDef}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; - pub fn serialize(value: &Option, serializer: S) -> Result + pub(super) fn serialize(value: &Option, serializer: S) -> Result where S: Serializer, { @@ -155,7 +155,7 @@ mod opt_delimiter_def { value.as_ref().map(Helper).serialize(serializer) } - pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + pub(super) fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { @@ -170,7 +170,7 @@ mod opt_subtree_def { use super::{Subtree, SubtreeDef}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; - pub fn serialize(value: &Option, serializer: S) -> Result + pub(super) fn serialize(value: &Option, serializer: S) -> Result where S: Serializer, { @@ -179,7 +179,7 @@ mod opt_subtree_def { value.as_ref().map(Helper).serialize(serializer) } - pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + pub(super) fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { @@ -194,7 +194,7 @@ mod vec_token_tree { use super::{TokenTree, TokenTreeDef}; use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; - pub fn serialize(value: &Vec, serializer: S) -> Result + pub(super) fn serialize(value: &Vec, serializer: S) -> Result where S: Serializer, { @@ -209,7 +209,7 @@ mod vec_token_tree { seq.end() } - pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + pub(super) fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { -- cgit v1.2.3