]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #33512 - birkenfeld:issue-25944, r=sanxiyn
authorbors <bors@rust-lang.org>
Wed, 11 May 2016 03:14:46 +0000 (20:14 -0700)
committerbors <bors@rust-lang.org>
Wed, 11 May 2016 03:14:46 +0000 (20:14 -0700)
rustdoc: remove artificial indentation of doctest code

The indentation makes the examples look nicer when printed (when is this done?), but breaks tests using multi-line string literals.

Fixes: #25944
src/doc/book/strings.md
src/librustdoc/test.rs
src/test/rustdoc/issue-25944.rs [new file with mode: 0644]

index f5ebceedd363a9c77fb071788638253fee0a2f84..008644ec9a3e2821d68cfd9dad94319fbbb001cb 100644 (file)
@@ -32,7 +32,7 @@ include the newline and the leading spaces:
 let s = "foo
     bar";
 
-assert_eq!("foo\n        bar", s);
+assert_eq!("foo\n    bar", s);
 ```
 
 The second, with a `\`, trims the spaces and the newline:
index fc548924e296426f05a7d31216903604c7aaee19..3e1f3a414ffc33210c5b195a17b5b43dc09c3c6f 100644 (file)
@@ -341,7 +341,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, dont_insert_main: bool,
         prog.push_str(&everything_else);
     } else {
         prog.push_str("fn main() {\n    ");
-        prog.push_str(&everything_else.replace("\n", "\n    "));
+        prog.push_str(&everything_else);
         prog = prog.trim().into();
         prog.push_str("\n}");
     }
diff --git a/src/test/rustdoc/issue-25944.rs b/src/test/rustdoc/issue-25944.rs
new file mode 100644 (file)
index 0000000..c22ecb4
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags:--test
+
+/// ```
+/// let a = r#"
+/// foo
+/// bar"#;
+/// let b = "\nfoo\nbar";
+/// assert_eq!(a, b);
+/// ```
+pub fn main() {
+}