From db8b21ad482691866b310be6c8eb155f17dde5b4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 5 Nov 2020 21:28:34 -0800 Subject: [PATCH 1/2] Fix stray spacing of code blocks containing injected main --- src/renderer/html_handlebars/hbs_renderer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 918ec29e5e..debe86c447 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -837,7 +837,7 @@ fn add_playground_pre( let (attrs, code) = partition_source(code); format!( - "\n# #![allow(unused)]\n{}#fn main() {{\n{}#}}", + "# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code ) .into() @@ -961,7 +961,7 @@ mod tests { fn add_playground() { let inputs = [ ("x()", - "
\n#![allow(unused)]\nfn main() {\nx()\n}\n
"), + "
#![allow(unused)]\nfn main() {\nx()\n}\n
"), ("fn main() {}", "
fn main() {}\n
"), ("let s = \"foo\n # bar\n\";", @@ -991,7 +991,7 @@ mod tests { fn add_playground_edition2015() { let inputs = [ ("x()", - "
\n#![allow(unused)]\nfn main() {\nx()\n}\n
"), + "
#![allow(unused)]\nfn main() {\nx()\n}\n
"), ("fn main() {}", "
fn main() {}\n
"), ("fn main() {}", @@ -1015,7 +1015,7 @@ mod tests { fn add_playground_edition2018() { let inputs = [ ("x()", - "
\n#![allow(unused)]\nfn main() {\nx()\n}\n
"), + "
#![allow(unused)]\nfn main() {\nx()\n}\n
"), ("fn main() {}", "
fn main() {}\n
"), ("fn main() {}", From 9b0d1062c9af3c586f3c4ed48a74279e0073fefe Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 5 Nov 2020 21:45:28 -0800 Subject: [PATCH 2/2] Format with rustfmt --- src/renderer/html_handlebars/hbs_renderer.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index debe86c447..5f8f92218c 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -836,11 +836,8 @@ fn add_playground_pre( // we need to inject our own main let (attrs, code) = partition_source(code); - format!( - "# #![allow(unused)]\n{}#fn main() {{\n{}#}}", - attrs, code - ) - .into() + format!("# #![allow(unused)]\n{}#fn main() {{\n{}#}}", attrs, code) + .into() }; hide_lines(&content) }