Commit Graph

167 Commits

Author SHA1 Message Date
Kevin Stenerson cd8bb50aea Trim the indentation on macros which heuristically appear to use block-style indentation (#3178) 2018-11-07 17:49:53 +09:00
Stéphane Campinas 5a2ebdddcc trim the start of a line when wrapping an item in preparation for formatting 2018-11-05 20:22:06 +01:00
Stéphane Campinas 2d718a3fc2 The method trim_left_preserve_layout didn't handle tabs properly.
This is fixed by taking the method macros::indent_macro_snippet which
essentially does the same: it indents a paragraph while preserving the
layout.
2018-10-30 20:24:03 +01:00
Stéphane Campinas 2f5d864c08 keep track of lines which formatting was disabled in order to prevent indentation which would cause code right-shifting 2018-10-24 12:11:11 +02:00
Stéphane Campinas 9c75a15f4c Fix handling of code that is annotated with rustfmt::skip.
A rustfmt::skip'ed block is indented although original lines are
returned. In order to resolve this, the leading whitespaces are trimmed
on each line while retaining the layout; this leaves the skipped code
to be indented as necessary by the caller.
2018-10-24 12:11:11 +02:00
Matthias Krüger b25f974c0d fix a few typos found via codespell. 2018-10-19 12:28:00 +02:00
Nick Cameron 4bb84f6002 Remove NLL feature
And do some refactoring in comments.rs

Closes #3107
2018-10-18 15:39:11 +13:00
Shotaro Yamada 6c964fd030 Reduce allocations 2018-10-15 23:59:08 +09:00
Daniele D'Orazio 075aa909cd try to fix comment bad wrapping (#3099) 2018-10-15 11:18:37 +09:00
Stéphane Campinas 8f7a0470b0 handle lines prefixed with a # inside code blocks 2018-10-13 09:57:43 +02:00
Seiichi Uchida b2de574848 Add format_doc_comments 2018-10-11 23:34:36 +09:00
Stéphane Campinas c0b7222e2d handle itemized items inside comments 2018-10-09 00:44:59 +02:00
Otavio Salvador 301ddd39db comment: Add documentation to is_doc_comment public method
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2018-09-28 10:01:07 -03:00
Stéphane Campinas 2bcc3a9302 do not format a code block in documentation if it is annotated with ignore or text (#3058) 2018-09-28 11:06:29 +09:00
Stéphane Campinas 5fdb6db136 Prevent right-shifting of block comments with bare lines.
Lines that didn't start with a comment sigil were returned unchanged in
comment::rewrite_comment. Then these unchanged lines were indented in
MacroBranch::rewrite.
2018-09-22 00:09:11 +02:00
Seiichi Uchida e2b9c66cc9 Cargo fmt 2018-09-19 23:22:26 +09:00
Stéphane Campinas c3edf6d3a1 Fix indent computation of a macro with braces.
The leading whitespace of a multine string was taken into account when
computing the `min_prefix_space_width`, even if that line couldn't be
trimmed. The consequence is it was always shifting the macro's content
to the right.
2018-09-18 00:01:51 +02:00
Nick Cameron f655671e12 Merge pull request #2983 from topecongiro/issue-2642
Handle raw string literals in CharClasses
2018-09-04 19:11:49 +12:00
Maximilian Roos 968affc3e0 final clippy changes 2018-09-01 16:32:38 -04:00
topecongiro 67480422b9 Handle raw string literal without any sharps 2018-08-31 10:49:39 +09:00
topecongiro 309be479b2 Handle raw string literals in CharClasses 2018-08-31 10:37:46 +09:00
Maximilian Roos df72570b58 set of clippy changes 2018-08-28 00:33:51 -04:00
cad97 04d804c365 Rename CodeMap/FileMap to SourceMap/SourceFile
#2946
2018-08-23 17:10:46 -04:00
Stéphane Campinas dd14d304ef discard trailing blank comments 2018-08-16 19:59:32 +02:00
Stéphane Campinas f23e6aaaf9 fix the identification of a block comment.
Block comments like below were not properly supported:

    /*
       something here but it doesn't start with a star
     */

because of the line that didn't start with a star.
2018-08-16 19:55:15 +02:00
Nick Cameron e4d560b914 Merge pull request #2897 from topecongiro/issue-2896
Ignore comment in wrap_str
2018-08-06 19:36:03 +12:00
Seiichi Uchida 2eeb366311 Ignore comment in wrap_str 2018-08-05 10:50:43 +09:00
Seiichi Uchida 2eca09e438 Fix parsing '#'-hiding of rustdoc 2018-08-05 08:44:20 +09:00
Nick Cameron 481e85cc58 formatting 2018-07-24 15:46:39 +12:00
Nick Cameron b085113cbe Trigger an internal error if we skip formatting due to a lost comment 2018-07-20 16:05:19 +12:00
Stéphane Campinas 86018133a0 removed unused max_width argument of rewrite_string function 2018-07-14 19:33:26 +02:00
Seiichi Uchida 604764abe1 Trim custom comment prefix even when we failed to format code block 2018-06-05 15:58:14 +09:00
Seiichi Uchida 1b4778d0bc Handle code block with indented escapce character 2018-06-05 15:57:49 +09:00
Seiichi Uchida a70213b009 Trim custom comment prefixes from code block without closing backticks 2018-06-05 15:57:03 +09:00
topecongiro 5d067f16e0 Format code block with sharp prefix
by hiding lines with a leading `#` behind a custom comment.
2018-05-23 23:30:07 +09:00
topecongiro f1974e2209 Handle code block in doc comment without rust prefix 2018-05-23 23:29:28 +09:00
Shotaro Yamada d1e2b80fb9 Use saturating_sub 2018-05-15 20:41:43 +09:00
Nick Cameron 51f566062f Update uses of rustfmt_skip to rustfmt::skip 2018-05-14 16:25:10 +12:00
topecongiro bd25c7d0f7 Cargo fmt 2018-05-08 06:25:48 +09:00
topecongiro 1f738ea208 Cargo fmt 2018-05-06 15:22:29 +09:00
topecongiro 43df7dcb0e Run cargo fmt with reorder_impl_items set to true 2018-04-30 16:24:01 +09:00
Nick Cameron b7ba6f70b1 Merge pull request #2576 from topecongiro/merge-imports
Use normalized form to format use items
2018-04-05 17:39:22 +12:00
Seiichi Uchida 89070a2244 Implement LineClasses 2018-04-05 12:52:43 +09:00
Seiichi Uchida f6c0a0f4ed Cargo fmt 2018-03-31 14:23:40 +09:00
Shotaro Yamada 4757321277 Don't index a string with chars().count() 2018-03-22 08:33:18 +09:00
Nick Cameron bcaeab7a5e Merge pull request #2527 from topecongiro/issue-2526
Check whether '\\'' is char literal or lifetime
2018-03-12 11:25:40 +13:00
Seiichi Uchida 86a427fe32 Check whether '\\'' is char literal or lifetime 2018-03-10 01:19:38 +09:00
Seiichi Uchida 484469899b Keep code block without correct backticks enclosing 2018-03-09 09:46:43 +09:00
topecongiro 93d454aed7 Only format code blocks in comments with rust syntax notation 2018-03-05 19:30:08 +09:00
Nick Cameron 39301ae5f2 Go back to a non-workspace structure
Kinda reverts https://github.com/rust-lang-nursery/rustfmt/pull/2419
2018-03-02 14:58:23 +13:00