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
+
1
8
//@ compile-flags: --crate-type lib
2
9
#![ deny( missing_debug_implementations) ]
3
10
#![ allow( unused) ]
@@ -10,7 +17,6 @@ pub enum A {} //~ ERROR type does not implement `Debug`
10
17
pub enum B { }
11
18
12
19
pub enum C { }
13
-
14
20
impl fmt:: Debug for C {
15
21
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
16
22
Ok ( ( ) )
@@ -23,15 +29,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug`
23
29
pub struct Bar ;
24
30
25
31
pub struct Baz ;
26
-
27
32
impl fmt:: Debug for Baz {
28
33
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
29
34
Ok ( ( ) )
30
35
}
31
36
}
32
37
38
+ // Private types should not trigger the lint
33
39
struct PrivateStruct ;
34
-
35
40
enum PrivateEnum { }
36
41
37
42
#[ derive( Debug ) ]
Original file line number Diff line number Diff line change 1
1
error: 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
3
3
|
4
4
LL | pub enum A {}
5
5
| ^^^^^^^^^^^^^
6
6
|
7
7
note: the lint level is defined here
8
- --> $DIR/missing_debug_impls .rs:2 :9
8
+ --> $DIR/missing-debug-implementations-lint .rs:6 :9
9
9
|
10
10
LL | #![deny(missing_debug_implementations)]
11
11
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
12
13
13
error: 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
15
15
|
16
16
LL | pub struct Foo;
17
17
| ^^^^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments