Commit graph

78 commits

Author SHA1 Message Date
Nick Cameron
fd774dbba3
Merge pull request #2485 from topecongiro/attr
Add `attr` modules and allow `#[name = value]` to exceed max width
2018-02-25 12:47:32 +13:00
Nick Cameron
4d3b73e075
Merge pull request #2483 from topecongiro/error-on-unknown-config-name-in-configurations
Error on outdated Configurations.md
2018-02-25 12:46:07 +13:00
topecongiro
75cf0be87b Add a test for #2479 2018-02-23 23:18:54 +09:00
topecongiro
0d8636f229 Allow meta item's value to exceed max width 2018-02-23 23:15:29 +09:00
topecongiro
b17c522650 Add doc comment to rewrite_first_group_attrs 2018-02-23 22:58:46 +09:00
topecongiro
eea5dcac46 Add a test for #2414
Closes #2414.
2018-02-23 22:53:16 +09:00
topecongiro
391ed68ad4 Move type punctuation tests under config dir 2018-02-23 22:53:16 +09:00
topecongiro
e2e653bc8f Remove unused tests 2018-02-23 22:53:16 +09:00
topecongiro
94188f5a28 Remove unused tests 2018-02-23 22:53:16 +09:00
topecongiro
871a18ac13 Mention that doc.rs is a part of multiple.rs 2018-02-23 22:53:16 +09:00
topecongiro
128925dcb4 Use visual indent style in where-clause.rs 2018-02-23 22:53:16 +09:00
topecongiro
758c54e9d5 Update big-impl tests
big-impl.rs and big-impl-rfc.rs is identical. One of them should use visual
indent style, and their file name should reflect that.
2018-02-23 22:53:16 +09:00
topecongiro
ecfb9c9526 Move items-related stuffs to item mod from visitor mod
Move `rewrite_extern_crate`, is_mod_decl`, `is_use_item` and `is_extern_crate`.
2018-02-23 22:37:10 +09:00
topecongiro
a8852fd787 Move filter_inline_attrs() to attr mod from visitor mod 2018-02-23 22:32:39 +09:00
topecongiro
529fed0c34 Add attr module 2018-02-23 22:30:05 +09:00
topecongiro
5f49587a2c Update configuration tests
This commit adds following functionalities to `configuration_snippet_tests`:

1. Error if there is an unknown configuration option in Configuration.md.
2. Error if there are multiple guides for the same configuration option in
   Configuration.md.
3. Error if an user-facing configuration option does not have its guide in
   Configuration.md.

We will be able to catch outdated Configuration.md. Should prevent issues
like #2459.
2018-02-23 21:54:59 +09:00
Nick Cameron
cc2c7433e2
Merge pull request #2480 from topecongiro/issue-2476
Avoid drifting macro body which is unformattable
2018-02-23 13:39:56 +13:00
topecongiro
8531d70c77 Cargo clippy 2018-02-23 09:07:35 +09:00
topecongiro
9cdac82d42 Cargo fmt and update a test 2018-02-23 08:14:22 +09:00
topecongiro
5ccc23f920 Call wrap_str to make sure that the formatting macro body worked 2018-02-23 08:13:57 +09:00
topecongiro
cb0097f7d8 Use multiple lines for function calls with 0 arg which exceeds max width
e.g.

foo(
)
2018-02-23 08:12:48 +09:00
topecongiro
c5a8878f7e Continue formatting function calls even if it does not fit in a single line
We may be able to format it using multiple lines.
2018-02-23 08:11:10 +09:00
topecongiro
093633ecb7 Update tests for #2438 and #2476 2018-02-23 08:10:17 +09:00
David Alber
f11e76989b Removing ignore attribute 2018-02-20 18:48:07 -08:00
topecongiro
b4c85d1bcb Return the original snippet if the attribute contains invalid syntax
This allows us to keep formatting the macro def with attributes that become
invalid syntax when the `$` is replaced with `z`, e.g. `#[doc = $expr]`.
2018-02-20 14:48:46 +09:00
Nick Cameron
be79f5e433
Merge pull request #2468 from topecongiro/perf
Apply optimization suggested by perf
2018-02-19 18:42:47 +13:00
topecongiro
37f82a0c95 Skip formatting macro_rules! that are not using {} 2018-02-19 14:08:33 +09:00
topecongiro
36e8eb6893 Use push-approach over format! in rewrite_segment 2018-02-19 12:55:12 +09:00
topecongiro
57f182cd10 Clean up 2018-02-19 12:55:12 +09:00
topecongiro
125e7124e7 Use Indent::to_string_with_newline to avoid unnecessary allocation 2018-02-19 12:55:12 +09:00
topecongiro
9d47e7370e Use SnippetProvider to implement SpanUtils over CodeMap
`SnippetProvider::span_to_snippet` avoids allocating a `String` so it is more
efficient than `CodeMap::span_to_snippet`.
2018-02-19 12:55:12 +09:00
topecongiro
f0519c8001 Avoid running lookup_line_range when file_lines are not specified 2018-02-19 12:52:40 +09:00
topecongiro
bd813251f1 Avoid allocating small strings in combine_strs_with_missing_comments 2018-02-19 12:52:40 +09:00
topecongiro
61c6c591e4 Avoid using pretty printer if possible
Setting a pretty printer adds noticeable overhead.

We can replace the usage in `ast:Lifetime::rewrite` by simply converting `Ident`
to string.
We can do the same thing for a macro path as long as it is not nested, which
should hold for most cases.
2018-02-19 12:52:40 +09:00
topecongiro
d7d9850c42 Do not inspect code for issues or todos when not required 2018-02-19 12:52:40 +09:00
topecongiro
80bf3da17d Use debug_assert_eq! to avoid comparing PathBuf on release
Comparing `PathBuf` adds noticeable overhead, avoid it in release build.
2018-02-19 12:52:40 +09:00
topecongiro
15c7e1c52a Replace lookup_char_pos with lookup_line
`lookup_char_pos` wastes time on fetching unused information. We only need a
`FileMap` and line numbers, so `lookup_line` is enough.
2018-02-19 12:52:40 +09:00
Nick Cameron
383e7e9955
Merge pull request #2465 from karyon/fix_2346
Fix #2346: empty comments should not have any trailing space added
2018-02-19 11:45:49 +13:00
Nick Cameron
25f2dffc1c
Merge pull request #2461 from topecongiro/reorder-mod
Refactoring: add `reorder` modules
2018-02-19 09:13:52 +13:00
Johannes Linke
8e36d54202 Fix #2346: empty comments should not have any trailing space added 2018-02-18 12:50:10 +01:00
topecongiro
ea3c01e337 Format a match arm with the beginning vertical bar 2018-02-18 10:31:11 +09:00
Seiichi Uchida
c32eb1fe34 Add TODO 2018-02-18 03:00:59 +09:00
Seiichi Uchida
333e3e1247 Get rid of macro 2018-02-18 02:59:54 +09:00
Seiichi Uchida
a915916f24 Rename fns 2018-02-18 02:06:29 +09:00
topecongiro
e992c09e1f Get rid of format_imports 2018-02-18 01:38:31 +09:00
topecongiro
8427b80f57 Move reorder-related stuffs in visitor mod to reorder mod 2018-02-18 01:38:31 +09:00
topecongiro
eb9cafb440 Move rewrite_mod to the items module 2018-02-18 01:38:31 +09:00
topecongiro
e8636afab2 Add a reorder module 2018-02-18 01:38:31 +09:00
Seiichi Uchida
2bee88870f
Merge pull request #2421 from brotzeit/clippy
apply some clippy suggestions
2018-02-17 16:14:39 +09:00
Christopher Armstrong
bd0facd4ce only wrap on trailing comments, allow /* */ comments in-line 2018-02-16 21:52:08 -06:00