From ec658723ca6b95b4d5780918e8b2d51494b93d19 Mon Sep 17 00:00:00 2001 From: Robert Straw Date: Thu, 20 Mar 2014 08:54:22 -0500 Subject: [PATCH] Consume result in `wf!` macro, considering write errors to be fatal. --- src/codegen/branchify.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/codegen/branchify.rs b/src/codegen/branchify.rs index c003568b..c92fafdb 100644 --- a/src/codegen/branchify.rs +++ b/src/codegen/branchify.rs @@ -94,9 +94,14 @@ pub fn generate_branchified_method( macro_rules! wf(($($x:tt)*) => ({ let indentstr = " ".repeat(indent * 4); let s = format!($($x)*); - writer.write(indentstr.as_bytes()); - writer.write(s.as_bytes()); - writer.write(bytes!("\n")); + let result = writer.write(indentstr.as_bytes()) + .and(writer.write(s.as_bytes())) + .and(writer.write(bytes!("\n"))); + + match result { + Ok(_) => {}, + Err(e) => fail!("write error: {:s}", e.desc), + } })) fn r(writer: &mut BufferedWriter, branch: &ParseBranch, prefix: &str, indent: uint, read_call: &str,