]> git.lizzy.rs Git - rust.git/commitdiff
dbg_macro: Debug-required test.
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 18 Sep 2018 02:28:17 +0000 (04:28 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Thu, 20 Sep 2018 15:39:09 +0000 (17:39 +0200)
src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs [new file with mode: 0755]
src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr [new file with mode: 0644]

diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs
new file mode 100755 (executable)
index 0000000..8e6f3b2
--- /dev/null
@@ -0,0 +1,9 @@
+// Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`.
+
+#![feature(dbg_macro)]
+
+struct NotDebug;
+
+fn main() {
+    let _: NotDebug = dbg!(NotDebug);
+}
diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr
new file mode 100644 (file)
index 0000000..a3b6a17
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0277]: `NotDebug` doesn't implement `std::fmt::Debug`
+  --> $DIR/dbg-macro-requires-debug.rs:8:23
+   |
+LL |     let _: NotDebug = dbg!(NotDebug);
+   |                       ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}`
+   |
+   = help: the trait `std::fmt::Debug` is not implemented for `NotDebug`
+   = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug`
+   = note: required because of the requirements on the impl of `std::fmt::Debug` for `&NotDebug`
+   = note: required by `std::fmt::Debug::fmt`
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.