about summary refs log tree commit diff
path: root/src/libfmt_macros
diff options
context:
space:
mode:
authorEsteban Küber <esteban@commure.com>2018-07-19 18:53:26 -0700
committerEsteban Küber <esteban@commure.com>2018-07-19 23:18:07 -0700
commit154dee2dccd45f929b0a3d2ce2d45739513f77c8 (patch)
tree4170231db8b43d3c03f074eb1521ec7f010c2720 /src/libfmt_macros
parenta47653214f8f8561196acf25b8898e7148f1c052 (diff)
downloadrust-154dee2dccd45f929b0a3d2ce2d45739513f77c8.tar.gz
rust-154dee2dccd45f929b0a3d2ce2d45739513f77c8.zip
rework println
Diffstat (limited to 'src/libfmt_macros')
-rw-r--r--src/libfmt_macros/lib.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index 51c3efb41ad..ee590bc3b5e 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -273,7 +273,11 @@ impl<'a> Parser<'a> {
             }
         } else {
             let msg = format!("expected `{:?}` but string was terminated", c);
-            let pos = self.input.len() + 1; // point at closing `"`
+            // point at closing `"`, unless the last char is `\n` to account for `println`
+            let pos = match self.input.chars().last() {
+                Some('\n') => self.input.len(),
+                _ => self.input.len() + 1,
+            };
             if c == '}' {
                 self.err_with_note(msg,
                                    format!("expected `{:?}`", c),