about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-09-18 04:28:17 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2018-09-20 17:39:09 +0200
commit6d0882127120df865debd02a08e4f7642739c58e (patch)
treeb3d5adfa25ac886d48817f51810d89b77267665c
parentcbb81bd8569a59cc4672d7ea1d504d5ee85531a5 (diff)
downloadrust-6d0882127120df865debd02a08e4f7642739c58e.tar.gz
rust-6d0882127120df865debd02a08e4f7642739c58e.zip
dbg_macro: Debug-required test.
-rwxr-xr-xsrc/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs9
-rw-r--r--src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr15
2 files changed, 24 insertions, 0 deletions
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
index 00000000000..8e6f3b226fc
--- /dev/null
+++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs
@@ -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
index 00000000000..a3b6a1761b9
--- /dev/null
+++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr
@@ -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`.