Commit Graph

1717 Commits

Author SHA1 Message Date
Adam H. Leventhal
c7359945a4 tests 2020-11-29 13:26:58 -06:00
hafiz
c77c6a405d Compare code block line indentation with config whitespace (#4166)
Previously the indetation of a line was compared with the configured
number of spaces per tab, which could cause lines that were formatted
with hard tabs not to be recognized as indented ("\t".len() < "    ".len()).

Closes #4152
2020-11-29 13:26:58 -06:00
David Tolnay
e7ecdc1664 Remove async fn from extern block tests 2020-11-28 21:59:30 -06:00
Ayaz Hafiz
3bf67c175d Don't drop blocks on foreign functions
A code like

```rust
extern "C" {
    fn f() {
        fn g() {}
    }
}
```

is incorrect and does not compile. Today rustfmt formats this in a way
that is correct:

```rust
extern "C" {
    fn f();
}
```

But this loses information, and doesn't have to be done because we know
the content of the block if it is present. During development I don't
think rustfmt should drop the block in this context.

Closes #4313
2020-11-28 21:59:30 -06:00
topecongiro
8e46225547 Add a test 2020-11-28 21:59:30 -06:00
Caleb Cartwright
4d9fa00fd5 feat: support underscore expressions 2020-11-28 17:41:21 -06:00
Caleb Cartwright
4f32ce8434 feat: support struct/slice destructuring 2020-11-28 17:41:21 -06:00
meiomorphism
003786228d fix: don't force a newline after an empty where clause
Fixes #4547.
2020-11-25 21:32:46 -06:00
Matt
073cc3891f Option to create groups for std, external crates, and other imports
Backport of 17d90ca.
2020-11-18 21:37:42 -06:00
Caleb Cartwright
89f38304a7 fix: don't drop leading comments in extern 2020-11-16 15:48:20 -06:00
Caleb Cartwright
eed826f8a7 tests: attributed comment-only blocks 2020-11-14 11:50:28 -06:00
WhizSid
faf97a67d6 Fixed 'Incorrect comment indent inside if/else' issue. (#4459)
* Added test cases

* Fixed if condition comment issue

* Fixed extern C issue

* Removed previous test case

* Removed tmp file

* honor the authors intent

* Changed the file name to its original name

* Removed extra whitespace
2020-11-14 11:50:28 -06:00
Ayaz Hafiz
dd32de74ce fixup! Correctly create artificial span for formatting closure body 2020-11-14 11:50:28 -06:00
Caleb Cartwright
a613c57521 feat: don't insert semi in macro_rules arm body 2020-11-11 18:26:13 -06:00
Aaron Hill
46ab14437e Don't flatten a block containing a single macro call
We no longer flatten a block that looks like this:

```rust
match val {
    pat => { macro_call!() }
}
```

Currently, rust ignores trailing semicolons in macro expansion in
expression position (see https://github.com/rust-lang/rust/issues/33953)

If this is changed, flattening a block with a macro call may break the
user's code - the trailing semicolon will no longer parse if the macro
call occurs immediately on the right-hand side of the match arm
(e.g. `pat => macro_call!()`)
2020-11-05 20:45:11 -06:00
Caleb Cartwright
15854e5fd3 feat: v2 support for nested tuples w/o spaces 2020-11-02 18:31:51 -06:00
Scott McMurray
278e8da33b Add some basic tests for try{} expressions
They failed to parse in rustfmt on me in https://github.com/rust-lang/rust/pull/77877, which looks like it's since been fixed, but I figured I'd send in some tests anyway.
2020-11-02 18:31:51 -06:00
Caleb Cartwright
86a41bc80b tests: add test for panic on new_parser_from_file 2020-11-02 18:31:51 -06:00
Caleb Cartwright
9faba4539b fix(parser): better unclosed delims handling 2020-11-02 18:31:51 -06:00
hafiz
6a7824787e Preserve comments in empty statements (#4180)
* Preserve comments in empty statements

Closes #4018

* fixup! Preserve comments in empty statements
2020-10-24 11:13:00 -05:00
Ayaz Hafiz
e70343a5f5 Correctly indent skipped-over code
Closes #4398
2020-10-24 11:13:00 -05:00
Ayaz Hafiz
92ab76cfa7 fixup! Preserve and format type aliases in extern blocks 2020-10-01 19:12:22 -05:00
Ayaz Hafiz
a9b0b057eb fixup! Preserve and format type aliases in extern blocks 2020-10-01 19:12:22 -05:00
Ayaz Hafiz
a15800a327 Preserve and format type aliases in extern blocks
Previously, non-trivial type aliases in extern blocks were dropped by
rustfmt because only the type alias name would be passed to a rewritter.
This commit fixes that by passing all type information (generics,
bounds, and assignments) to a type alias rewritter, and consolidates
`rewrite_type_alias` and `rewrite_associated_type` as one function.
2020-10-01 19:12:22 -05:00
Caleb Cartwright
4908ee19c3 tests: add tests for leading pipe config 2020-09-24 09:43:31 -05:00
David Tolnay
146578c480 Add regression test for unsafe mods 2020-09-23 00:45:18 -05:00
Caleb Cartwright
62dc7c5c6b fix: inner attribute formatting 2020-09-04 19:01:18 -05:00
mahkoh
89b7f5f382 Fix module resolution in inner modules with paths (#4194) 2020-09-04 19:01:18 -05:00
Caleb Cartwright
48f6c32ec1 tests: add system tests for inverted span issue 2020-08-09 14:32:34 -05:00
Caleb Cartwright
bf359c6ebc chore: backport 8157a3f0afe978d3e953420577f8344db7e905bf 2020-07-15 09:19:21 -05:00
Seiichi Uchida
a36e7c7981 Use correct span for match arms with the leading pipe and attributes (#3975) 2020-06-27 12:55:15 -05:00
Caleb Cartwright
796d6eafa4 fix: backport fix for #4079 2020-06-11 23:29:51 -05:00
Caleb Cartwright
5db7152962 fix: backport fix for #4020 2020-06-11 23:17:38 -05:00
Caleb Cartwright
ce1a3efff0 fix: backport fix for submod parser errors 2020-06-11 21:49:40 -05:00
Caleb Cartwright
dead3a807d fix: backport mod resolution error handling 2020-06-11 21:11:18 -05:00
Caleb Cartwright
c1267303bc
fix: formatting arbitrary extern abi (#4089) 2020-03-31 15:30:26 +09:00
Caleb Cartwright
00e199c974
backport new syntax to rustfmt 1.x (#4105)
* feat: support raw reference operator

* feat: support const opt-out syntax

* feat: support half open range syntax
2020-03-31 15:28:01 +09:00
Caleb Cartwright
b173b42354 refactor: rename libsyntax --> rustc_ast 2020-03-27 22:29:12 -05:00
Caleb Cartwright
c1a66e1e22 fix: unreachable err on Fn with None block 2020-03-27 22:13:46 -05:00
Caleb Cartwright
c60416ed21 deps: update rustc-ap to v642.0.0 2020-02-08 22:21:37 -06:00
Seiichi Uchida
731f15551b
Do not add block around async closure (#3946) 2019-12-03 08:47:25 +09:00
Seiichi Uchida
69cf48344b
fix handling of nested comments in patterns and ControlFlows (#3869) 2019-10-25 15:04:33 +09:00
rChaser53
233497aceb fix Unparsable code when formmating (#3883) 2019-10-24 22:16:56 +09:00
Rui
69c7dbcd50 Try to solve issue3456. (#3556) 2019-10-19 18:19:47 +09:00
Stéphane Campinas
5327c3633f handle field attributes when aligning a struct's fields (#3513) 2019-10-19 16:56:32 +09:00
Caleb Cartwright
fd6e960648 fix: comments between lhs and rhs 2019-10-17 20:13:11 -05:00
Caleb Cartwright
28be77915f fix: nested comments in control flow condition pat 2019-10-17 19:58:08 -05:00
Stéphane Campinas
a15e97f1e9 do not indent impl generics (#3856) 2019-10-11 18:19:44 +09:00
Caleb Cartwright
8210cc1c13 fix: handle lhs unary in range expression (#3855) 2019-10-11 18:15:04 +09:00
rChaser53
396a2af181 fix to swallow attribute on brace expression (#3848) 2019-10-10 10:35:34 +09:00