Skip to content

Commit 6d08821

Browse files
committed
dbg_macro: Debug-required test.
1 parent cbb81bd commit 6d08821

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`.
2+
3+
#![feature(dbg_macro)]
4+
5+
struct NotDebug;
6+
7+
fn main() {
8+
let _: NotDebug = dbg!(NotDebug);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0277]: `NotDebug` doesn't implement `std::fmt::Debug`
2+
--> $DIR/dbg-macro-requires-debug.rs:8:23
3+
|
4+
LL | let _: NotDebug = dbg!(NotDebug);
5+
| ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}`
6+
|
7+
= help: the trait `std::fmt::Debug` is not implemented for `NotDebug`
8+
= note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug`
9+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `&NotDebug`
10+
= note: required by `std::fmt::Debug::fmt`
11+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)