]> git.lizzy.rs Git - rust.git/commitdiff
Use the last line's width for indent width in rewriting missed span
authorSeiichi Uchida <seuchida@gmail.com>
Tue, 5 Sep 2017 07:51:54 +0000 (16:51 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Tue, 5 Sep 2017 07:54:02 +0000 (16:54 +0900)
to fix unindented comments

src/missed_spans.rs
tests/source/comment.rs
tests/source/comment4.rs
tests/target/comment.rs
tests/target/comment4.rs

index 301e1583029c8d3ef4b28e86bcba7e138c3b2688..5e350cf41b40b05e6186f564ad3c04ffe47b7f63 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use Shape;
+use {Indent, Shape};
 use comment::{rewrite_comment, CodeCharKind, CommentCodeSlices};
 use config::WriteMode;
 use syntax::codemap::{BytePos, Pos, Span};
@@ -169,11 +169,12 @@ fn replace_chars(string: &str) -> String {
                         self.config.comment_width(),
                         self.config.max_width() - self.block_indent.width(),
                     );
+                    let comment_indent = Indent::from_width(self.config, self.buffer.cur_offset());
 
                     self.buffer.push_str(&rewrite_comment(
                         subslice,
                         false,
-                        Shape::legacy(comment_width, self.block_indent),
+                        Shape::legacy(comment_width, comment_indent),
                         self.config,
                     ).unwrap());
 
index 61d7fc454aa7dc7fbaad6a0dcee13103a1c4e9a8..e8ddaf959a63cdb5d799b2c40bdab766e8b882a1 100644 (file)
@@ -9,7 +9,6 @@ fn test() {
 // comment
         // comment2
 
-    // FIXME(1275)
     code(); /* leave this comment alone!
              * ok? */
 
index 0ae5cf4c3f689ed15012df4d6bb1a607b1c88606..ff1445378d7b60da62ceeb5c42e0a463b691d78f 100644 (file)
@@ -5,7 +5,6 @@ fn test() {
 // comment
         // comment2
 
-    // FIXME(1275)
     code(); /* leave this comment alone!
              * ok? */
 
index 168fb28edb99e0ebb099bb22c1aa8b1e3d9a81d2..f6de70a16ad31cbf8d10359eb7ccbf8ab6cf68db 100644 (file)
@@ -9,9 +9,8 @@ fn test() {
     // comment
     // comment2
 
-    // FIXME(1275)
     code(); // leave this comment alone!
-    // ok?
+            // ok?
 
     // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a
     // diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
@@ -33,7 +32,7 @@ fn test() {
     //                           .unwrap());
 
     funk(); // dontchangeme
-    // or me
+            // or me
 
     // #1388
     const EXCEPTION_PATHS: &'static [&'static str] = &[
index 2916f083ca0fcb5f3f0150e8dae195fd0a5f1b29..e07abf74a81bc70651bbb7111f7c064821bb9840 100644 (file)
@@ -5,9 +5,8 @@ fn test() {
     // comment
     // comment2
 
-    // FIXME(1275)
     code(); /* leave this comment alone!
-     * ok? */
+             * ok? */
 
     /* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a
      * diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
@@ -28,7 +27,7 @@ fn test() {
     //                           .unwrap());
 
     funk(); //dontchangeme
-    // or me
+            // or me
 }
 
 /// test123