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/hir_ty/src/diagnostics/decl_check/case_conv.rs | 6 +++--- crates/hir_ty/src/diagnostics/expr.rs | 15 ++++----------- crates/hir_ty/src/diagnostics/unsafe_check.rs | 8 ++++---- 3 files changed, 11 insertions(+), 18 deletions(-) (limited to 'crates/hir_ty/src/diagnostics') diff --git a/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs b/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs index b0144a289..14e4d92f0 100644 --- a/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs +++ b/crates/hir_ty/src/diagnostics/decl_check/case_conv.rs @@ -6,7 +6,7 @@ /// Converts an identifier to an UpperCamelCase form. /// Returns `None` if the string is already is UpperCamelCase. -pub fn to_camel_case(ident: &str) -> Option { +pub(crate) fn to_camel_case(ident: &str) -> Option { if is_camel_case(ident) { return None; } @@ -59,7 +59,7 @@ pub fn to_camel_case(ident: &str) -> Option { /// Converts an identifier to a lower_snake_case form. /// Returns `None` if the string is already in lower_snake_case. -pub fn to_lower_snake_case(ident: &str) -> Option { +pub(crate) fn to_lower_snake_case(ident: &str) -> Option { if is_lower_snake_case(ident) { return None; } else if is_upper_snake_case(ident) { @@ -71,7 +71,7 @@ pub fn to_lower_snake_case(ident: &str) -> Option { /// Converts an identifier to an UPPER_SNAKE_CASE form. /// Returns `None` if the string is already is UPPER_SNAKE_CASE. -pub fn to_upper_snake_case(ident: &str) -> Option { +pub(crate) fn to_upper_snake_case(ident: &str) -> Option { if is_upper_snake_case(ident) { return None; } else if is_lower_snake_case(ident) { diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 278a4b947..434b19354 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -17,17 +17,10 @@ use crate::{ ApplicationTy, InferenceResult, Ty, TypeCtor, }; -pub use hir_def::{ - body::{ - scope::{ExprScopes, ScopeEntry, ScopeId}, - Body, BodySourceMap, ExprPtr, ExprSource, PatPtr, PatSource, - }, - expr::{ - ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, - MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, UnaryOp, - }, - src::HasSource, - LocalFieldId, Lookup, VariantId, +pub(crate) use hir_def::{ + body::{Body, BodySourceMap}, + expr::{Expr, ExprId, MatchArm, Pat, PatId}, + LocalFieldId, VariantId, }; pub(super) struct ExprValidator<'a, 'b: 'a> { diff --git a/crates/hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs index 2da9688ca..6dc862826 100644 --- a/crates/hir_ty/src/diagnostics/unsafe_check.rs +++ b/crates/hir_ty/src/diagnostics/unsafe_check.rs @@ -59,12 +59,12 @@ impl<'a, 'b> UnsafeValidator<'a, 'b> { } } -pub struct UnsafeExpr { - pub expr: ExprId, - pub inside_unsafe_block: bool, +pub(crate) struct UnsafeExpr { + pub(crate) expr: ExprId, + pub(crate) inside_unsafe_block: bool, } -pub fn unsafe_expressions( +pub(crate) fn unsafe_expressions( db: &dyn HirDatabase, infer: &InferenceResult, def: DefWithBodyId, -- cgit v1.2.3