From c95fa8cbe22d782cd7bc007dfe06aba9ceddff78 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Thu, 7 Jun 2018 12:33:33 +0900 Subject: [PATCH] Return None when the formatting of macro failed in format_snippet --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index a8f09e4843d5..8d4cbb51b5a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -689,6 +689,7 @@ fn format_snippet(snippet: &str, config: &Config) -> Option { config.set().hide_parse_errors(true); match format_input(input, &config, Some(&mut out)) { // `format_input()` returns an empty string on parsing error. + Ok((summary, _)) if summary.has_macro_formatting_failure() => None, Ok(..) if out.is_empty() && !snippet.is_empty() => None, Ok(..) => String::from_utf8(out).ok(), Err(..) => None,