File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 1+ //! Test the `missing_debug_implementations` lint that warns about public types without Debug.
2+ //!
3+ //! This lint helps enforce the convention that public types should implement Debug
4+ //! for better debugging experience, as recommended by RFC 504.
5+ //!
6+ //! See https://github.com/rust-lang/rust/issues/20855
7+
18//@ compile-flags: --crate-type lib
29#![ deny( missing_debug_implementations) ]
310#![ allow( unused) ]
@@ -10,7 +17,6 @@ pub enum A {} //~ ERROR type does not implement `Debug`
1017pub enum B { }
1118
1219pub enum C { }
13-
1420impl fmt:: Debug for C {
1521 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1622 Ok ( ( ) )
@@ -23,15 +29,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug`
2329pub struct Bar ;
2430
2531pub struct Baz ;
26-
2732impl fmt:: Debug for Baz {
2833 fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
2934 Ok ( ( ) )
3035 }
3136}
3237
38+ // Private types should not trigger the lint
3339struct PrivateStruct ;
34-
3540enum PrivateEnum { }
3641
3742#[ derive( Debug ) ]
Original file line number Diff line number Diff line change 11error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
2- --> $DIR/missing_debug_impls .rs:7 :1
2+ --> $DIR/missing-debug-implementations-lint .rs:11 :1
33 |
44LL | pub enum A {}
55 | ^^^^^^^^^^^^^
66 |
77note: the lint level is defined here
8- --> $DIR/missing_debug_impls .rs:2 :9
8+ --> $DIR/missing-debug-implementations-lint .rs:6 :9
99 |
1010LL | #![deny(missing_debug_implementations)]
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
1313error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
14- --> $DIR/missing_debug_impls .rs:20 :1
14+ --> $DIR/missing-debug-implementations-lint .rs:23 :1
1515 |
1616LL | pub struct Foo;
1717 | ^^^^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments