Skip to content

Commit

Permalink
Rollup merge of rust-lang#68844 - euclio:debug-impl-def-path, r=petro…
Browse files Browse the repository at this point in the history
…chenkov

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`.
  • Loading branch information
Dylan-DPC committed Feb 6, 2020
2 parents 226a8e2 + c0a110f commit 16e4e8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
declare_lint! {
MISSING_DEBUG_IMPLEMENTATIONS,
Allow,
"detects missing implementations of fmt::Debug"
"detects missing implementations of Debug"
}

#[derive(Default)]
Expand Down Expand Up @@ -599,9 +599,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
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)
),
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/missing_debug_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -17,7 +17,7 @@ impl fmt::Debug for C {
}
}

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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/missing_debug_impls.stderr
Original file line number Diff line number Diff line change
@@ -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 {}
Expand All @@ -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;
Expand Down

0 comments on commit 16e4e8f

Please sign in to comment.