Skip to content

Commit 16e4e8f

Browse files
authored
Rollup merge of #68844 - euclio:debug-impl-def-path, r=petrochenkov
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`.
2 parents 226a8e2 + c0a110f commit 16e4e8f

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
@@ -555,7 +555,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
555555
declare_lint! {
556556
MISSING_DEBUG_IMPLEMENTATIONS,
557557
Allow,
558-
"detects missing implementations of fmt::Debug"
558+
"detects missing implementations of Debug"
559559
}
560560

561561
#[derive(Default)]
@@ -599,9 +599,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
599599
cx.span_lint(
600600
MISSING_DEBUG_IMPLEMENTATIONS,
601601
item.span,
602-
"type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` \
603-
or a manual implementation",
604-
)
602+
&format!(
603+
"type does not implement `{}`; consider adding `#[derive(Debug)]` \
604+
or a manual implementation",
605+
cx.tcx.def_path_str(debug)
606+
),
607+
);
605608
}
606609
}
607610
}

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)