Skip to content
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 Debug Implementations #31869

Closed
57 tasks
seanmonstar opened this issue Feb 24, 2016 · 16 comments
Closed
57 tasks

Missing Debug Implementations #31869

seanmonstar opened this issue Feb 24, 2016 · 16 comments

Comments

@seanmonstar
Copy link
Contributor

seanmonstar commented Feb 24, 2016

The missing_debug_implementations will detect any public type that does not implement Debug. Usually all public types should implement Debug, even if it doesn't share all the internals in its formatting. This allows users to derive(Debug) on their types when they contain a type from std.

I ran the lint against crates that have types exported in std, and I've grouped the results below. I think the eventual goal should be to add #![deny(missing_debug_implementations)] to each crate. Any exceptions should be tagged #[allow(missing_debug_implementations)], though hopefully those should be very few.


collections

  • src/libcollections/binary_heap.rs:672 pub struct Iter<'a, T: 'a>
  • src/libcollections/binary_heap.rs:712 pub struct IntoIter<T>
  • src/libcollections/binary_heap.rs:744 pub struct Drain<'a, T: 'a>
  • src/libcollections/btree/map.rs:188 pub struct Iter<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:195 pub struct IterMut<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:202 pub struct IntoIter<K, V>
  • src/libcollections/btree/map.rs:210 pub struct Keys<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:216 pub struct Values<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:221 pub struct Range<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:227 pub struct RangeMut<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:237 pub enum Entry<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:253 pub struct VacantEntry<'a, K: 'a, V: 'a>
  • src/libcollections/btree/map.rs:264 pub struct OccupiedEntry<'a, K: 'a, V: 'a>
  • src/libcollections/btree/set.rs:49 pub struct Iter<'a, T: 'a>
  • src/libcollections/btree/set.rs:55 pub struct IntoIter<T>
  • src/libcollections/btree/set.rs:60 pub struct Range<'a, T: 'a>
  • src/libcollections/btree/set.rs:66 pub struct Difference<'a, T: 'a>
  • src/libcollections/btree/set.rs:73 pub struct SymmetricDifference<'a, T: 'a>
  • src/libcollections/btree/set.rs:80 pub struct Intersection<'a, T: 'a>
  • src/libcollections/btree/set.rs:87 pub struct Union<'a, T: 'a>
  • src/libcollections/enum_set.rs:218 pub struct Iter<E>
  • src/libcollections/linked_list.rs:59 pub struct Iter<'a, T: 'a>
  • src/libcollections/linked_list.rs:79 pub struct IterMut<'a, T: 'a>
  • src/libcollections/linked_list.rs:89 pub struct IntoIter<T>
  • src/libcollections/linked_list.rs:1052 pub struct FrontPlace<'a, T: 'a>
  • src/libcollections/linked_list.rs:1096 pub struct BackPlace<'a, T: 'a>
  • src/libcollections/str.rs:120 pub struct Utf16Units<'a>
  • src/libcollections/string.rs:1852 pub struct Drain<'a>
  • src/libcollections/vec.rs:1551 pub struct IntoIter<T>
  • src/libcollections/vec.rs:1649 pub struct Drain<'a, T: 'a>
  • src/libcollections/vec_deque.rs:1739 pub struct Iter<'a, T: 'a>
  • src/libcollections/vec_deque.rs:1795 pub struct IterMut<'a, T: 'a>
  • src/libcollections/vec_deque.rs:1848 pub struct IntoIter<T>
  • src/libcollections/vec_deque.rs:1881 pub struct Drain<'a, T: 'a>

rand

  • src/librand/distributions/range.rs:32 pub struct Range<X>
  • src/librand/distributions/gamma.rs:42 pub struct Gamma
  • src/librand/distributions/gamma.rs:180 pub struct ChiSquared
  • src/librand/distributions/gamma.rs:228 pub struct FisherF
  • src/librand/distributions/gamma.rs:263 pub struct StudentT
  • src/librand/distributions/normal.rs:32 pub struct StandardNormal(pub f64);
  • src/librand/distributions/normal.rs:80 pub struct Normal
  • src/librand/distributions/normal.rs:118 pub struct LogNormal
  • src/librand/distributions/exponential.rs:33 pub struct Exp1(pub f64);
  • src/librand/distributions/exponential.rs:62 pub struct Exp
  • src/librand/distributions/mod.rs:57 pub struct RandSample<Sup>
  • src/librand/distributions/mod.rs:80 pub struct Weighted<T>
  • src/librand/distributions/mod.rs:96 pub struct WeightedChoice<'a, T: 'a>
  • src/librand/isaac.rs:38 pub struct IsaacRng
  • src/librand/isaac.rs:316 pub struct Isaac64Rng
  • src/librand/chacha.rs:29 pub struct ChaChaRng
  • src/librand/reseeding.rs:22 pub struct ReseedingRng<R, Rsdr>
  • src/librand/reseeding.rs:107 pub struct ReseedWithDefault;
  • src/librand/lib.rs:282 pub struct Generator<'a, T, R: 'a>
  • src/librand/lib.rs:298 pub struct AsciiGenerator<'a, R: 'a>
  • src/librand/lib.rs:334 pub struct XorShiftRng
  • src/librand/lib.rs:420 pub struct Open01<F>(pub F);
  • src/librand/lib.rs:428 pub struct Closed01<F>(pub F);
@nagisa
Copy link
Member

nagisa commented Feb 24, 2016

What sense it makes to implement Debug for iterators? These can’t really show any useful state.

@seanmonstar
Copy link
Contributor Author

If it truly doesn't make sense to implement for an iterator, it can be marked #[allow]. Others have suggested useful state they would like see, such as @bluss.

@bluss
Copy link
Member

bluss commented Feb 24, 2016

Any value that can end up being part of a user's data structure should have Debug. The slice iterator is the simplest example, but I don't think we can find a good excuse for any iterator.

@GuillaumeGomez
Copy link
Member

I'll work on this a bit then.

bors added a commit that referenced this issue Mar 21, 2016
libcore: add Debug implementations to most missing types

Also adds `#![deny(missing_debug_implementations)]` to the core crate.

cc #31869
@frewsxcv
Copy link
Member

@seanmonstar Did you automatically generate the list above? If so, could you regenerate it to see what the current state of things is?

@seanmonstar
Copy link
Contributor Author

@frewsxcv it was generated by setting #![warn(missing_debug_implementations)] in each of those crates, building, and then cleaning up the warning list.

@frewsxcv
Copy link
Member

What sense it makes to implement Debug for iterators? These can’t really show any useful state.

From what I've seen, it is not uncommon for structures to have fields that are iterator structures. For me an end user, it's annoying that I can't just print the debug representation or derive Debug because one libstd structure (which the end user has no control over) doesn't implement Debug.

@frewsxcv
Copy link
Member

These can’t really show any useful state.

For me, I don't really care if most Debug representations just display the name of the structure. That's plenty more helpful than not implementing Debug at all.

@frewsxcv
Copy link
Member

Opened a PR for libstd: #38006

frewsxcv added a commit to frewsxcv/rust that referenced this issue Dec 18, 2016
Part of rust-lang#31869.

Also turn on the `missing_debug_implementations` lint at the crate
level.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 20, 2016
Implement `fmt::Debug` for all structures in libstd.

Part of rust-lang#31869.

Also turn on the `missing_debug_implementations` lint at the crate
level.
@solson
Copy link
Member

solson commented Jan 11, 2017

Is this done, then, with @frewsxcv's PR merged?

@frewsxcv
Copy link
Member

I don't think this is done. My PR only addressed libstd. IIRC libcore also has #![deny(missing_debug_implementations)] enabled. I don't think this can be said about other crates containing stable interfaces like libcollections.

@GuillaumeGomez
Copy link
Member

Oh damn, forgot this issue. We should try to sync efforts on this. I'll work on libcollections.

@abonander
Copy link
Contributor

Related: rust-random/rand#130

bors added a commit that referenced this issue Jan 21, 2017
Add missing Debug implementation for librand structs

Part of #31869.
@frewsxcv
Copy link
Member

This should be done after #39002 merges I think.

@frewsxcv
Copy link
Member

Thanks for your pull requests @GuillaumeGomez :)

bors added a commit that referenced this issue Feb 7, 2017
Add Debug implementations for libcollection structs

Part of #31869.
@frewsxcv
Copy link
Member

frewsxcv commented Feb 7, 2017

Since #39002 has merged, this should be done. thanks everyone!

@frewsxcv frewsxcv closed this as completed Feb 7, 2017
cuviper pushed a commit to cuviper/rayon that referenced this issue Mar 28, 2017
Part of rust-lang/rust#31869.

Also turn on the `missing_debug_implementations` lint at the crate
level.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 23, 2017
Add missing Debug impls to std_unicode

Also adds `#![deny(missing_debug_implementations)]` so they don't get missed again.

cc rust-lang#31869
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants