Disallow unreachable_pub (#4314)
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::shared_traits::AsFormat;
|
||||
use crate::trivia::{Relationship, TriviaKind};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Block<'a> {
|
||||
pub(crate) struct Block<'a> {
|
||||
body: &'a Body,
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ impl Format<ASTFormatContext> for Block<'_> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn block(body: &Body) -> Block {
|
||||
pub(crate) fn block(body: &Body) -> Block {
|
||||
Block { body }
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Statements<'a> {
|
||||
pub(crate) struct Statements<'a> {
|
||||
suite: &'a [Stmt],
|
||||
}
|
||||
|
||||
@@ -61,12 +61,12 @@ impl Format<ASTFormatContext> for Statements<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn statements(suite: &[Stmt]) -> Statements {
|
||||
pub(crate) fn statements(suite: &[Stmt]) -> Statements {
|
||||
Statements { suite }
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct Literal {
|
||||
pub(crate) struct Literal {
|
||||
range: TextRange,
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ impl Format<ASTFormatContext> for Literal {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn literal(range: TextRange) -> Literal {
|
||||
pub(crate) const fn literal(range: TextRange) -> Literal {
|
||||
Literal { range }
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::format::builders::literal;
|
||||
use crate::trivia::TriviaKind;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LeadingComments<'a, T> {
|
||||
pub(crate) struct LeadingComments<'a, T> {
|
||||
item: &'a Attributed<T>,
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ impl<T> Format<ASTFormatContext> for LeadingComments<'_, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn leading_comments<T>(item: &Attributed<T>) -> LeadingComments<'_, T> {
|
||||
pub(crate) const fn leading_comments<T>(item: &Attributed<T>) -> LeadingComments<'_, T> {
|
||||
LeadingComments { item }
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TrailingComments<'a, T> {
|
||||
pub(crate) struct TrailingComments<'a, T> {
|
||||
item: &'a Attributed<T>,
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ impl<T> Format<ASTFormatContext> for TrailingComments<'_, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn trailing_comments<T>(item: &Attributed<T>) -> TrailingComments<'_, T> {
|
||||
pub(crate) const fn trailing_comments<T>(item: &Attributed<T>) -> TrailingComments<'_, T> {
|
||||
TrailingComments { item }
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EndOfLineComments<'a, T> {
|
||||
pub(crate) struct EndOfLineComments<'a, T> {
|
||||
item: &'a Attributed<T>,
|
||||
}
|
||||
|
||||
@@ -88,12 +88,12 @@ impl<T> Format<ASTFormatContext> for EndOfLineComments<'_, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn end_of_line_comments<T>(item: &Attributed<T>) -> EndOfLineComments<'_, T> {
|
||||
pub(crate) const fn end_of_line_comments<T>(item: &Attributed<T>) -> EndOfLineComments<'_, T> {
|
||||
EndOfLineComments { item }
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DanglingComments<'a, T> {
|
||||
pub(crate) struct DanglingComments<'a, T> {
|
||||
item: &'a Attributed<T>,
|
||||
}
|
||||
|
||||
@@ -113,6 +113,6 @@ impl<T> Format<ASTFormatContext> for DanglingComments<'_, T> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn dangling_comments<T>(item: &Attributed<T>) -> DanglingComments<'_, T> {
|
||||
pub(crate) const fn dangling_comments<T>(item: &Attributed<T>) -> DanglingComments<'_, T> {
|
||||
DanglingComments { item }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::cst::{Expr, ExprKind, UnaryOpKind};
|
||||
|
||||
pub fn is_self_closing(expr: &Expr) -> bool {
|
||||
pub(crate) fn is_self_closing(expr: &Expr) -> bool {
|
||||
match &expr.node {
|
||||
ExprKind::Tuple { .. }
|
||||
| ExprKind::List { .. }
|
||||
@@ -53,7 +53,7 @@ pub fn is_self_closing(expr: &Expr) -> bool {
|
||||
|
||||
/// Return `true` if an [`Expr`] adheres to Black's definition of a non-complex
|
||||
/// expression, in the context of a slice operation.
|
||||
pub fn is_simple_slice(expr: &Expr) -> bool {
|
||||
pub(crate) fn is_simple_slice(expr: &Expr) -> bool {
|
||||
match &expr.node {
|
||||
ExprKind::UnaryOp { op, operand } => {
|
||||
if matches!(op.node, UnaryOpKind::Not) {
|
||||
@@ -70,7 +70,7 @@ pub fn is_simple_slice(expr: &Expr) -> bool {
|
||||
|
||||
/// Return `true` if an [`Expr`] adheres to Black's definition of a non-complex
|
||||
/// expression, in the context of a power operation.
|
||||
pub fn is_simple_power(expr: &Expr) -> bool {
|
||||
pub(crate) fn is_simple_power(expr: &Expr) -> bool {
|
||||
match &expr.node {
|
||||
ExprKind::UnaryOp { op, operand } => {
|
||||
if matches!(op.node, UnaryOpKind::Not) {
|
||||
|
||||
@@ -2,7 +2,7 @@ mod alias;
|
||||
mod arg;
|
||||
mod arguments;
|
||||
mod bool_op;
|
||||
pub mod builders;
|
||||
pub(crate) mod builders;
|
||||
mod cmp_op;
|
||||
mod comments;
|
||||
mod comprehension;
|
||||
|
||||
@@ -64,7 +64,7 @@ const fn float_atom(range: TextRange) -> FloatAtom {
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct FloatLiteral {
|
||||
pub(crate) struct FloatLiteral {
|
||||
range: TextRange,
|
||||
}
|
||||
|
||||
@@ -109,12 +109,12 @@ impl Format<ASTFormatContext> for FloatLiteral {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn float_literal(range: TextRange) -> FloatLiteral {
|
||||
pub(crate) const fn float_literal(range: TextRange) -> FloatLiteral {
|
||||
FloatLiteral { range }
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct IntLiteral {
|
||||
pub(crate) struct IntLiteral {
|
||||
range: TextRange,
|
||||
}
|
||||
|
||||
@@ -156,12 +156,12 @@ impl Format<ASTFormatContext> for IntLiteral {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn int_literal(range: TextRange) -> IntLiteral {
|
||||
pub(crate) const fn int_literal(range: TextRange) -> IntLiteral {
|
||||
IntLiteral { range }
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct ComplexLiteral {
|
||||
pub(crate) struct ComplexLiteral {
|
||||
range: TextRange,
|
||||
}
|
||||
|
||||
@@ -190,6 +190,6 @@ impl Format<ASTFormatContext> for ComplexLiteral {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn complex_literal(range: TextRange) -> ComplexLiteral {
|
||||
pub(crate) const fn complex_literal(range: TextRange) -> ComplexLiteral {
|
||||
ComplexLiteral { range }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::context::ASTFormatContext;
|
||||
use crate::cst::Expr;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
pub struct StringLiteralPart {
|
||||
pub(crate) struct StringLiteralPart {
|
||||
range: TextRange,
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ impl Format<ASTFormatContext> for StringLiteralPart {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn string_literal_part(range: TextRange) -> StringLiteralPart {
|
||||
pub(crate) const fn string_literal_part(range: TextRange) -> StringLiteralPart {
|
||||
StringLiteralPart { range }
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct StringLiteral<'a> {
|
||||
pub(crate) struct StringLiteral<'a> {
|
||||
expr: &'a Expr,
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ impl Format<ASTFormatContext> for StringLiteral<'_> {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn string_literal(expr: &Expr) -> StringLiteral {
|
||||
pub(crate) const fn string_literal(expr: &Expr) -> StringLiteral {
|
||||
StringLiteral { expr }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user