From 1d265fd143e06166568234a30bc2d369dea4c876 Mon Sep 17 00:00:00 2001 From: Mike English Date: Sat, 18 Apr 2020 00:10:08 -0400 Subject: [PATCH] Broaden scope of suppressed warnings for listings without a main fn At present, code listings without a main function will be wrapped in one and annotated with an allow lint check attribute provided by the following [code][]: ``` format!( "\n# #![allow(unused_variables)]\n{}#fn main() {{\n{}#}}", attrs, code ) ``` A broader lint check attribute such as `#![allow(unused)]` seems like it might better fit the apparent intent of this code. Addresses: https://github.com/rust-lang/mdBook/issues/1192 [code]: https://github.com/rust-lang/mdBook/blob/769cc0a7c14fe133fc5eb223f435473730d0086e/src/renderer/html_handlebars/hbs_renderer.rs#L635-L638 --- src/renderer/html_handlebars/hbs_renderer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 05afbdec..e0d3fd4b 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -633,7 +633,7 @@ fn add_playpen_pre(html: &str, playpen_config: &Playpen) -> String { let (attrs, code) = partition_source(code); format!( - "\n# #![allow(unused_variables)]\n{}#fn main() {{\n{}#}}", + "\n# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code ) .into() @@ -756,7 +756,7 @@ mod tests { fn add_playpen() { let inputs = [ ("x()", - "
\n#![allow(unused_variables)]\nfn main() {\nx()\n}\n
"), + "
\n#![allow(unused)]\nfn main() {\nx()\n}\n
"), ("fn main() {}", "
fn main() {}\n
"), ("let s = \"foo\n # bar\n\";",