Skip to content

Commit c0a110f

Browse files
committed
use def_path_str for missing_debug_impls message
The lint message will now use the full, correct path to the `Debug` trait, even in `no_std`.
1 parent c9290dc commit c0a110f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/librustc_lint/builtin.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
567567
declare_lint! {
568568
MISSING_DEBUG_IMPLEMENTATIONS,
569569
Allow,
570-
"detects missing implementations of fmt::Debug"
570+
"detects missing implementations of Debug"
571571
}
572572

573573
#[derive(Default)]
@@ -611,9 +611,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
611611
cx.span_lint(
612612
MISSING_DEBUG_IMPLEMENTATIONS,
613613
item.span,
614-
"type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` \
615-
or a manual implementation",
616-
)
614+
&format!(
615+
"type does not implement `{}`; consider adding `#[derive(Debug)]` \
616+
or a manual implementation",
617+
cx.tcx.def_path_str(debug)
618+
),
619+
);
617620
}
618621
}
619622
}

src/test/ui/missing_debug_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::fmt;
66

7-
pub enum A {} //~ ERROR type does not implement `fmt::Debug`
7+
pub enum A {} //~ ERROR type does not implement `std::fmt::Debug`
88

99
#[derive(Debug)]
1010
pub enum B {}
@@ -17,7 +17,7 @@ impl fmt::Debug for C {
1717
}
1818
}
1919

20-
pub struct Foo; //~ ERROR type does not implement `fmt::Debug`
20+
pub struct Foo; //~ ERROR type does not implement `std::fmt::Debug`
2121

2222
#[derive(Debug)]
2323
pub struct Bar;

src/test/ui/missing_debug_impls.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
1+
error: type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
22
--> $DIR/missing_debug_impls.rs:7:1
33
|
44
LL | pub enum A {}
@@ -10,7 +10,7 @@ note: the lint level is defined here
1010
LL | #![deny(missing_debug_implementations)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
13+
error: type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
1414
--> $DIR/missing_debug_impls.rs:20:1
1515
|
1616
LL | pub struct Foo;

0 commit comments

Comments
 (0)