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`.
This commit is contained in:
Dylan DPC
2020-02-06 15:37:46 +01:00
committed by GitHub
3 changed files with 11 additions and 8 deletions
+7 -4
View File
@@ -555,7 +555,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
declare_lint! {
MISSING_DEBUG_IMPLEMENTATIONS,
Allow,
"detects missing implementations of fmt::Debug"
"detects missing implementations of Debug"
}
#[derive(Default)]
@@ -599,9 +599,12 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
cx.span_lint(
MISSING_DEBUG_IMPLEMENTATIONS,
item.span,
"type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` \
or a manual implementation",
)
&format!(
"type does not implement `{}`; consider adding `#[derive(Debug)]` \
or a manual implementation",
cx.tcx.def_path_str(debug)
),
);
}
}
}
+2 -2
View File
@@ -4,7 +4,7 @@
use std::fmt;
pub enum A {} //~ ERROR type does not implement `fmt::Debug`
pub enum A {} //~ ERROR type does not implement `std::fmt::Debug`
#[derive(Debug)]
pub enum B {}
@@ -17,7 +17,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
}
}
pub struct Foo; //~ ERROR type does not implement `fmt::Debug`
pub struct Foo; //~ ERROR type does not implement `std::fmt::Debug`
#[derive(Debug)]
pub struct Bar;
+2 -2
View File
@@ -1,4 +1,4 @@
error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
error: type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
--> $DIR/missing_debug_impls.rs:7:1
|
LL | pub enum A {}
@@ -10,7 +10,7 @@ note: the lint level is defined here
LL | #![deny(missing_debug_implementations)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: type does not implement `fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
error: type does not implement `std::fmt::Debug`; consider adding `#[derive(Debug)]` or a manual implementation
--> $DIR/missing_debug_impls.rs:20:1
|
LL | pub struct Foo;