Commit Graph

3580 Commits

Author SHA1 Message Date
Seiichi Uchida
ca6fc67e60 Fix print_version 2018-03-17 12:16:15 +09:00
topecongiro
87180d9065 0.4.1 2018-03-16 08:58:25 +09:00
topecongiro
a03b3b7d6f Cargo update
Remove `rustc-ap-rustc_errors` from dependencies since it
is re-exported from `rustc-ap-syntax`.
2018-03-16 08:52:36 +09:00
Nick Cameron
c416246494
Merge pull request #2509 from topecongiro/issue-2493
Overflow the last rhs of a binary expression
2018-03-16 07:30:30 +13:00
Nick Cameron
65ce7bbb81
Merge pull request #2533 from topecongiro/rustc-ap-syntax
Update to the latest rustc-ap-syntax
2018-03-16 07:26:50 +13:00
Seiichi Uchida
eda626cfc9 Call syntax::with_globals before using a parser 2018-03-15 18:55:52 +09:00
Seiichi Uchida
a353294fe4 Cargo update
Update `rustc-ap-syntax` to `67.0.0`.
2018-03-15 18:55:31 +09:00
Seiichi Uchida
0dca70f290 Merge branch 'matthew-mcallister-attrib-block-expr' 2018-03-14 01:16:57 +09:00
Matthew McAllister
c5168405b0 Format attributes on block expressions 2018-03-14 01:16:19 +09:00
Seiichi Uchida
314c912303 Update CHANGELOG 2018-03-14 00:38:42 +09:00
Nick Cameron
a0e063a6e1
Merge pull request #2522 from topecongiro/ignore-config-option
Add ignore config option
2018-03-12 16:25:31 +13:00
Nick Cameron
047a52087e
Merge pull request #2528 from topecongiro/rfc/trait-impl-where
Implement RFC style for trait
2018-03-12 16:25:12 +13:00
topecongiro
3999d64f12 Simplify IgnoreList 2018-03-12 08:41:19 +09:00
Seiichi Uchida
182b46e0ed Simplify join_bounds() 2018-03-12 07:57:03 +09:00
Seiichi Uchida
ccd134ed75 Add a test for #2497
Closes #2497.
2018-03-12 07:54:12 +09:00
Seiichi Uchida
7917d6f94a Update tests
This is an unintentional side effect of this PR. Nonetheless the diff looks
harmless to me, and it is only relevant when `indent_style = Visual`.
So I think this is ok.
2018-03-12 07:54:12 +09:00
Seiichi Uchida
b077297179 Modify the placement of the opening brace of trait
Put the opening brace on the next line if

1. putting it one the current line exceeds max width.
2. trait bounds uses multiple lines.
2018-03-12 07:54:12 +09:00
Seiichi Uchida
f56039c7e5 Use rewrite_assign_rhs for rewriting bounds 2018-03-12 07:54:12 +09:00
Seiichi Uchida
8f7a90fbef Add rewrite_assign_rhs_with
It is like `rewrite_assign_rhs` but lets us force to put the rhs on the next
line if it uses multiple lines.

This lets us avoid duplicating logic for choosing whether to put stuff on the
same line or the next line.
2018-03-12 07:48:31 +09:00
Seiichi Uchida
c7d7091772 Update tests for traits with long bounds
The colon should be next to the ident instead of on the next line.
2018-03-12 07:48:31 +09:00
Seiichi Uchida
f1d29ff580 Update tests for braces on trait
Test that the opening brace of trait with long name or bounds with multiple
lines will be put on the next line.
2018-03-12 07:48:31 +09:00
Nick Cameron
f5ebcd922e
Merge pull request #2513 from rtsuk/master
Restore cargo fmt behavior in workspaces
2018-03-12 11:26:12 +13: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
Nick Cameron
af5d3cc87b
Merge pull request #2524 from topecongiro/issue-2523
Do not unindent code block in comments with unformattable macro
2018-03-12 11:21:09 +13:00
Nick Cameron
124f03b1fc
Merge pull request #2516 from topecongiro/issue-2510
Make rewrite_call_inner more generic
2018-03-12 11:18:14 +13:00
Seiichi Uchida
fcce0b932a
Merge pull request #2529 from dlukes/feat/enable-doctests
Enable doctests
2018-03-10 21:24:35 +09:00
David Lukes
a41947cd7d Enable doctests
Doctests were disabled globally because up until #2456, they were just
formatting examples which were not supposed to compile. Now that there
is one runnable doctest, I disabled the other ones individually (by
adding the ignore directive).

I also added some empty lines around the code blocks to avoid the
following warning and instead ignore the code blocks cleanly:

WARNING: ... Code block is not currently run as a test, but will in
future versions of rustdoc. Please ensure this code block is a runnable
test, or use the `ignore` directive.

See rust-lang/rust#28712 for further details.
2018-03-10 09:57:01 +01:00
Seiichi Uchida
e68bd9ebd1
Merge pull request #2525 from Eijebong/dedup
Dedupe syn/quote
2018-03-10 11:53:15 +09:00
Seiichi Uchida
86a427fe32 Check whether '\\'' is char literal or lifetime 2018-03-10 01:19:38 +09:00
Seiichi Uchida
9905c569ba Add a test for #2526 2018-03-10 01:19:26 +09:00
Bastien Orivel
a1dd6bd930 Dedupe syn/quote 2018-03-09 16:12:22 +01:00
Rob Tsuk
a1f9796788 Specify required version of cargo_metadata 2018-03-09 07:40:39 -07:00
Rob Tsuk
ba10a4c48d Canonicalise the paths 2018-03-09 07:24:40 -07:00
Rob Tsuk
53dcb0d09d Restore cargo fmt behavior in workspaces
Previously, cargo fmt  invoked without parameters would
only format the crate in the current directory, even if
the crate was part of a workspace. This patch restores
that behavior.
2018-03-09 07:24:40 -07:00
topecongiro
2188b464b0 Format macro call with item arguments 2018-03-09 17:17:55 +09:00
topecongiro
eaab592cb8 Avoid unindenting code block in comment with unformattable macro
`format_code_block` formats the given `code_snippet` by enclosing it inside
`fn main` block. Previously we did not add indentation to the `code_snippet`
before formatting it. This works fine as long as we can format the given
`code_snippet`, but when the code block has unformattable macro, they gets
unindented. This commit fixes it by adding proper indentation before formatting
the `code_snippet`.

For example, when formatting the following code block,

```rust
some_macro!(pub fn foo() {
    println!("Don't unindent me!");
});
```

previously we enclosed it like this:

```rust
fn main() {
some_macro!(pub fn foo() {
    println!("Don't unindent me!");
});
}
```

with this PR, we will enclose it like this:

```rust
fn main() {
    some_macro!(pub fn foo() {
        println!("Don't unindent me!");
    });
}
```

Closes #2523.
2018-03-09 17:10:20 +09:00
topecongiro
c3e76bc02c Add a test for #2523 2018-03-09 17:09:56 +09:00
Seiichi Uchida
6ba7c34433 Use Option<SeparatorTactic> over bool to control trailing comma 2018-03-09 14:07:43 +09:00
Seiichi Uchida
e9f5382757 Add a test for #2510
Closes #2510.
2018-03-09 14:07:43 +09:00
Seiichi Uchida
466caa77bb Make INDENT_BUFFER longer
Avoid panicking when indent whose width is 80 called `to_string()`.
2018-03-09 14:07:43 +09:00
Seiichi Uchida
88a3c60f63 Update tests 2018-03-09 14:07:43 +09:00
Seiichi Uchida
2a99d9704f Use overflow::rewrite_with_angle_brackets to rewrite generics 2018-03-09 14:07:43 +09:00
Seiichi Uchida
ae629abc41 Add overflow module
This commit adds `overflow` module. This module provides two APIs.
`rewrite_with_parens` is basically the same as `rewrite_call_inner`.
`rewrite_with_angle_brackets` is used for rewriting generics and types.
2018-03-09 14:07:43 +09:00
Seiichi Uchida
8943c376bc Use RefCell for RewriteContext fields 2018-03-09 14:07:05 +09:00
Seiichi Uchida
84ad70c151 Add ignore config option
For example, with the following config file, rustfmt will ignore `src/types.rs`,
`src/foo/bar.rs` and every file under `examples/` directory.

```toml
[ignore]
files = [
    "src/types.rs",
    "src/foo/bar.rs",
]
directories = [
    "examples",
]
```
2018-03-09 13:37:52 +09:00
Nick Cameron
dc2f1429e7
Merge pull request #2521 from topecongiro/issue-2520
Fix bugs when rewriting doc comments with code block
2018-03-09 15:18:53 +13:00
Nick Cameron
58fb47a8ca
Merge pull request #2519 from topecongiro/nested-parens
Remove nested parens
2018-03-09 15:16:30 +13:00
Nick Cameron
5f99ebe628
Merge pull request #2518 from topecongiro/issue-2491
Disallow combining parens and brackets in impl
2018-03-09 15:15:21 +13:00
Nick Cameron
1780d68761 Catch panics in the parser before they crash rustfmt
Closes #753
2018-03-09 14:59:52 +13:00
Seiichi Uchida
484469899b Keep code block without correct backticks enclosing 2018-03-09 09:46:43 +09:00