From df5c8fa4b04db978397529c248b8743fbbf7743e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 25 Jul 2017 22:58:18 +0200 Subject: [PATCH 1/2] Remove unneeded variable from example Apparently doctests swallow *all* of their output, including compiler warnings, by default. --- src/lua.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua.rs b/src/lua.rs index f244f37..32d1504 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -207,7 +207,6 @@ impl<'lua> String<'lua> { /// # use rlua::{Lua, String}; /// # fn main() { /// let lua = Lua::new(); - /// let globals = lua.globals(); /// /// let non_utf8: String = lua.eval(r#" "test\xff" "#, None).unwrap(); /// assert!(non_utf8.to_str().is_err()); // oh no :( From 4e52544bd1989884b2ac6c42ab785c45167e1d6b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 25 Jul 2017 23:41:58 +0200 Subject: [PATCH 2/2] Deny warnings in doc tests This magical attribute is grossly underdocumented, but it works. And it's literally the only thing that makes this work the way I want it to. --- src/lib.rs | 3 +++ src/lua.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2a36825..f8c3543 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +// Deny warnings inside doc tests / examples +#![doc(test(attr(deny(warnings))))] + #[cfg_attr(test, macro_use)] extern crate hlist_macro; diff --git a/src/lua.rs b/src/lua.rs index 32d1504..a7beb0d 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -436,6 +436,7 @@ impl<'lua> Table<'lua> { /// /// for pair in globals.pairs::() { /// let (key, value) = pair?; + /// # let _ = (key, value); // used /// // ... /// } /// # Ok(())