Skip to content

Commit

Permalink
warn on missing-debug-implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Oct 25, 2024
1 parent f726b8f commit a17b79a
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 68 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ edition = "2018"
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
missing-debug-implementations = "warn"

[lib]
name = "combine"
path = "src/lib.rs"
Expand Down
4 changes: 4 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl<R> ErrorInfo<'_, Self, R> for u8 {
}

/// Newtype which constructs an `Info::Token` through `ErrorInfo`
#[derive(Debug)]
pub struct Token<T>(pub T);

impl<T, R> From<Token<T>> for Info<T, R, &'static str> {
Expand All @@ -142,6 +143,7 @@ where
}

/// Newtype which constructs an `Info::Range` through `ErrorInfo`
#[derive(Debug)]
pub struct Range<R>(pub R);

impl<T, R> From<Range<R>> for Info<T, R, &'static str> {
Expand All @@ -162,6 +164,7 @@ where

/// Newtype which constructs an `Info::Static` through `ErrorInfo`
/// A plain `&'static str` can also be used, this exists for consistency.
#[derive(Debug)]
pub struct Static(&'static str);

impl<T, R, F> From<Static> for Info<T, R, F>
Expand All @@ -181,6 +184,7 @@ impl<'s, T, R> ErrorInfo<'s, T, R> for Static {
}

/// Newtype which constructs an `Info::Format` through `ErrorInfo`
#[derive(Debug)]
pub struct Format<F>(pub F)
where
F: fmt::Display;
Expand Down
1 change: 1 addition & 0 deletions src/future_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::lib::pin::Pin;
use crate::lib::task::{Context, Poll};

// Replace usage of this with std::future::poll_fn once it stabilizes
#[derive(Debug)]
pub struct PollFn<F> {
f: F,
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
clippy::inline_always,
clippy::type_complexity,
clippy::too_many_arguments,
clippy::match_like_matches_macro
clippy::match_like_matches_macro,
)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
Expand Down Expand Up @@ -427,6 +427,7 @@ macro_rules! combine_parser_impl {
) => {

$(#[$derive])*
#[allow(missing_debug_implementations)]
$struct_vis struct $type_name<$($type_params)*>
where <$input_type as $crate::stream::StreamOnce>::Error:
$crate::error::ParseError<
Expand Down
7 changes: 4 additions & 3 deletions src/parser/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ macro_rules! tuple_choice_parser {
macro_rules! tuple_choice_parser_inner {
($partial_state: ident; $($id: ident)+) => {
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub enum $partial_state<$($id),+> {
Peek,
$(
Expand Down Expand Up @@ -350,7 +351,7 @@ array_choice_parser!(
30 31 32
);

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Choice<P>(P);

impl<Input, P> Parser<Input> for Choice<P>
Expand Down Expand Up @@ -557,7 +558,7 @@ where
Choice(ps)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Or<P1, P2>(Choice<(P1, P2)>);
impl<Input, O, P1, P2> Parser<Input> for Or<P1, P2>
where
Expand Down Expand Up @@ -630,7 +631,7 @@ where
Or(choice((p1, p2)))
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Optional<P>(P);
impl<Input, P> Parser<Input> for Optional<P>
where
Expand Down
38 changes: 22 additions & 16 deletions src/parser/combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use alloc::{boxed::Box, string::String, vec::Vec};
#[cfg(feature = "alloc")]
use crate::lib::any::Any;

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct NotFollowedBy<P>(P);
impl<Input, O, P> Parser<Input> for NotFollowedBy<P>
where
Expand Down Expand Up @@ -86,7 +86,7 @@ where
* TODO :: Rename `Try` to `Attempt`
* Because this is public, it's name cannot be changed without also making a breaking change.
*/
#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Try<P>(P);
impl<Input, O, P> Parser<Input> for Try<P>
where
Expand Down Expand Up @@ -164,7 +164,7 @@ where
Try(p)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct LookAhead<P>(P);

impl<Input, O, P> Parser<Input> for LookAhead<P>
Expand Down Expand Up @@ -211,7 +211,7 @@ where
LookAhead(p)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Map<P, F>(P, F);
impl<Input, A, B, P, F> Parser<Input> for Map<P, F>
where
Expand Down Expand Up @@ -256,7 +256,7 @@ where
Map(p, f)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct MapInput<P, F>(P, F);
impl<Input, A, B, P, F> Parser<Input> for MapInput<P, F>
where
Expand Down Expand Up @@ -301,7 +301,7 @@ where
MapInput(p, f)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct FlatMap<P, F>(P, F);
impl<Input, A, B, P, F> Parser<Input> for FlatMap<P, F>
where
Expand Down Expand Up @@ -352,7 +352,7 @@ where
FlatMap(p, f)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct AndThen<P, F>(P, F);
impl<Input, P, F, O, E> Parser<Input> for AndThen<P, F>
where
Expand Down Expand Up @@ -423,7 +423,7 @@ where
AndThen(p, f)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Recognize<F, P>(P, PhantomData<fn() -> F>);

impl<F, P> Recognize<F, P> {
Expand Down Expand Up @@ -548,6 +548,7 @@ where
Recognize(parser, PhantomData)
}

#[derive(Debug)]
pub enum Either<L, R> {
Left(L),
Right(R),
Expand Down Expand Up @@ -629,6 +630,7 @@ where
}
}

#[derive(Debug)]
pub struct NoPartial<P>(P);

impl<Input, P> Parser<Input> for NoPartial<P>
Expand Down Expand Up @@ -672,7 +674,7 @@ where
NoPartial(p)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Ignore<P>(P);
impl<Input, P> Parser<Input> for Ignore<P>
where
Expand Down Expand Up @@ -718,11 +720,12 @@ where

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[derive(Default)]
#[derive(Debug, Default)]
pub struct AnyPartialState(Option<Box<dyn Any>>);

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[derive(Debug)]
pub struct AnyPartialStateParser<P>(P);

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -821,11 +824,12 @@ where

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[derive(Default)]
#[derive(Debug, Default)]
pub struct AnySendPartialState(Option<Box<dyn Any + Send>>);

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[derive(Debug)]
pub struct AnySendPartialStateParser<P>(P);

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -924,11 +928,12 @@ where

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[derive(Default)]
#[derive(Debug, Default)]
pub struct AnySendSyncPartialState(Option<Box<dyn Any + Send + Sync>>);

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[derive(Debug)]
pub struct AnySendSyncPartialStateParser<P>(P);

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -1023,7 +1028,7 @@ where
AnySendSyncPartialStateParser(p)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Lazy<P>(P);
impl<Input, O, P, R> Parser<Input> for Lazy<P>
where
Expand Down Expand Up @@ -1094,7 +1099,7 @@ where
Lazy(p)
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Factory<P, R>(P, Option<R>);

impl<P, R> Factory<P, R> {
Expand Down Expand Up @@ -1285,7 +1290,7 @@ where [
}
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Opaque<F, Input, O, S>(F, PhantomData<fn(&mut Input, &mut S) -> O>);
impl<Input, F, O, S> Parser<Input> for Opaque<F, Input, O, S>
where
Expand Down Expand Up @@ -1421,6 +1426,7 @@ macro_rules! opaque {
};
}

#[derive(Debug)]
pub struct InputConverter<InputInner, P, C>
where
InputInner: Stream,
Expand Down Expand Up @@ -1508,7 +1514,7 @@ where
}
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Spanned<P>(P);
impl<Input, P, Q> Parser<Input> for Spanned<P>
where
Expand Down
8 changes: 4 additions & 4 deletions src/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
Parser, Stream, StreamOnce,
};

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Unexpected<I, T, E>(E, PhantomData<fn(I) -> (I, T)>)
where
I: Stream;
Expand Down Expand Up @@ -92,7 +92,7 @@ where
Unexpected(message, PhantomData)
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Message<P, S>(P, S);
impl<Input, P, S> Parser<Input> for Message<P, S>
where
Expand Down Expand Up @@ -149,7 +149,7 @@ where
Message(p, msg)
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Expected<P, S>(P, S);
impl<Input, P, S> Parser<Input> for Expected<P, S>
where
Expand Down Expand Up @@ -195,7 +195,7 @@ where
Expected(p, info)
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Silent<P>(P);
impl<Input, P> Parser<Input> for Silent<P>
where
Expand Down
4 changes: 2 additions & 2 deletions src/parser/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<'a, Input: Stream, O> Parser<Input>
}
}

#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct FnParser<Input, F>(F, PhantomData<fn(Input) -> Input>);

/// Wraps a function, turning it into a parser.
Expand Down Expand Up @@ -93,7 +93,7 @@ where
}
}

#[derive(Copy)]
#[derive(Debug, Copy)]
pub struct EnvParser<E, Input, T>
where
Input: Stream,
Expand Down
4 changes: 2 additions & 2 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ pub trait ParseMode: Copy {

/// Internal API. May break without a semver bump
#[doc(hidden)]
#[derive(Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct FirstMode;
impl ParseMode for FirstMode {
#[inline]
Expand All @@ -1173,7 +1173,7 @@ impl ParseMode for FirstMode {

/// Internal API. May break without a semver bump
#[doc(hidden)]
#[derive(Copy, Clone, Default)]
#[derive(Debug, Copy, Clone, Default)]
pub struct PartialMode {
pub first: bool,
}
Expand Down
Loading

0 comments on commit a17b79a

Please sign in to comment.