Skip to content

use def_path_str for missing_debug_impls message #68844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,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 @@ -611,9 +611,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