-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing fmt::Debug impls for public structs and enums #735
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but like the other PR, my sense is that some of these impls aren't needed to pass the lint? Or does the lint apply to internal types too?
The reason why I'm being a stickler about this is that I'd rather not add impls for things that we don't need because they likely increase compile times. And the compile times for this crate are already pretty poor.
src/re_trait.rs
Outdated
.field("last_match", &self.last_match) | ||
.finish() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect you're writing out this impl because Matches
is generic and doesn't require its type parameters to impl Debug
? The RegularExpression
trait is an internal construct, so adding a requirement to impl Debug
seems fine to me. (For both Self
and for its Text
associated type.) Then you should be able to derive Debug
impls here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also made the same change to CaptureMatches
.
src/exec.rs
Outdated
@@ -97,6 +99,7 @@ struct ExecReadOnly { | |||
/// Facilitates the construction of an executor by exposing various knobs | |||
/// to control how a regex is executed and what kinds of resources it's | |||
/// permitted to use. | |||
#[derive(Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this Debug
impl necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExecBuilder
is public via the internal
module which "exists to support suspicious activity".
I'll remove the debug impl and allow the lint.
src/compile.rs
Outdated
@@ -25,6 +26,7 @@ struct Patch { | |||
|
|||
/// A compiler translates a regular expression AST to a sequence of | |||
/// instructions. The sequence of instructions represents an NFA. | |||
#[derive(Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this Debug
impl necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler
is public via the internal module which "exists to support suspicious activity".
I'll remove the debug impl and allow the lint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha right. Yeah, it's technically public, but is doc(hidden)
and not a stable part of the API. I'm hoping to remove that quirk in the move to regex-automata
.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, I meant to "request changes."
@BurntSushi I've made the requested changes. I squashed these into the commit for the For types that are only public via the hidden |
rebase incoming. |
For reference, the other PR is #734. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, LGTM, thanks!
Whoops looks like I accidentally didn't split out the iterator traits bits from Thanks for merging. Would it be possible to get these two PRs packaged into a release soon? |
Yeah I saw that, but that's okay. No biggie. I'll try to do a release in the next couple days. Please ping me again if it doesn't happen. |
hi @BurntSushi following up with a friendly ping for a release. |
@lopopolo OK, |
Thank you! |
rust-lang/regex#735 added missing `fmt::Debug` impls for public structs and enums, which `spinoso-regexp` requires to impl `fmt::Debug` on its own iterator types. This change does not use these `fmt::Debug` impls, just updated the minimum dependency version.
The Rust API guidelines advise that all public types implement common
std
traits for interoperability, of whichfmt::Debug
is one.This PR adds
fmt::Debug
implementations for all public types inregex
andregex-syntax
crates. This PR also adds#![warn(missing_debug_implementations)]
tolib.rs
in each crate.This PR also opportunistically implements
Clone
on iterators that wrapslice::Iter
.Context: I'm building an implementation of Ruby
Regexp
on top of theregex
crate, and having all public types implementfmt::Debug
will allow me to#[derive(Debug)]
on types that wrap e.g. iterators in this crate.