Esteban Kuber
f99469d7c4
Change how the fn params span is calculated
...
Use the available Generics span field to avoid issues with `T: Fn()` bounds.
This is necessary to land #85346 .
2021-11-24 20:02:16 +00:00
Caleb Cartwright
f99e3582bd
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
2021-11-07 20:37:34 -06:00
Vadim Petrochenkov
bf3c52f355
ast: Fix naming conventions in AST structures
...
TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn
All `*Kind`s in AST are supposed to be enums.
Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.
Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07 21:38:17 +08:00
Caleb Cartwright
051e2b40c9
fix doc issue in rustfmt
2021-10-21 17:22:54 -05:00
Caleb Cartwright
2b41b6d022
Merge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree
2021-10-20 00:11:59 -05:00
Manish Goregaokar
52e1a529f2
Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco
...
Revert anon union parsing
Revert PR #84571 and #85515 , which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.
Fix #88583 .
2021-09-15 14:56:58 -07:00
bors
8743472386
Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
...
Encode spans relative to the enclosing item
The aim of this PR is to avoid recomputing queries when code is moved without modification.
MCP at https://github.com/rust-lang/compiler-team/issues/443
This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.
Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
depends on the span's absolute byte position.
With this scheme, I believe the dependency tracking to be accurate.
For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.
2021-09-11 23:35:28 +00:00
Camille GILLOT
127ec9a8c9
Keep a parent LocalDefId in SpanData.
2021-09-10 20:17:33 +02:00
Fabian Wolff
e014277b07
Ignore automatically derived impls of Clone
and Debug
in dead code analysis
2021-09-09 19:49:07 +02:00
Felix S. Klock II
d647ebfb4a
Revert "Allow formatting Anonymous{Struct, Union}
declarations"
...
This reverts commit 64acb7d921
.
2021-09-09 09:14:16 -04:00
bors
6271dedd8d
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
...
Fix #88256 remove duplicated diagnostics
Fix #88256
2021-09-06 00:14:41 +00:00
yukang
1674eea8ad
Fix #88256 , remove duplicated diagnostic
2021-09-04 19:26:25 +08:00
Esteban Kuber
48b8e4577a
Detect bare blocks with type ascription that were meant to be a struct
literal
...
Address part of #34255 .
Potential improvement: silence the other knock down errors in
`issue-34255-1.rs`.
2021-09-03 14:43:04 +00:00
Cameron Steffen
a603756cc5
Temporary fix rustfmt for let-else
2021-08-30 20:18:41 -05:00
Deadbeef
076916fe94
Introduce ~const
...
- [x] Removed `?const` and change uses of `?const`
- [x] Added `~const` to the AST. It is gated behind const_trait_impl.
- [x] Validate `~const` in ast_validation.
- [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and
`ConstIfConst` allowing future extensions)
- [ ] Adjust trait selection and pre-existing code to use `BoundConstness`.
- [ ] Optional steps (*for this PR, obviously*)
- [ ] Fix #88155
- [ ] Do something with constness bounds in chalk
2021-08-27 05:07:37 +00:00
Frank Steffahn
9bc0dbeb64
Fix typos “an”→“a” and a few different ones that appeared in the same search
2021-08-22 18:15:49 +02:00
Frank Steffahn
25ebc35f97
Fix more “a”/“an” typos
2021-08-22 16:35:29 +02:00
bors
e1dac88cfe
Auto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum
...
Document private items for rustfmt
This is possible now that https://github.com/rust-lang/rust/pull/73936 has been merged.
2021-08-17 04:18:55 +00:00
Joshua Nelson
7769ed0484
Document private items for rustfmt
...
This is possible now that rustdoc allows passing
`--document-private-items` more than once.
2021-08-16 01:46:56 +00:00
Caio
64bf8dfa33
Introduce hir::ExprKind::Let - Take 2
2021-08-15 16:18:26 -03:00
Caleb Cartwright
e4b8714c09
Merge commit '4236289b75ee55c78538c749512cdbeea5e1c332' into update-rustfmt
2021-07-25 22:57:19 -05:00
Camille GILLOT
277feac1f9
Use LocalExpnId where possible.
2021-07-17 19:41:02 +02:00
Guillaume Gomez
abf449ffa6
Rework SESSION_GLOBALS API to prevent overwriting it
2021-07-08 16:16:28 +02:00
Joshua Nelson
33acc960f7
Document rustfmt on nightly-rustc
...
The recursion_limit attribute avoids the following error:
```
error[E0275]: overflow evaluating the requirement `std::ptr::Unique<rustc_ast::Pat>: std::marker::Send`
|
= help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`rustfmt_nightly`)
```
2021-07-01 19:39:47 -04:00
Yuki Okushi
0b8a26f507
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
...
rustfmt: load nested out-of-line mods correctly
This should address https://github.com/rust-lang/rustfmt/issues/4874
r? `@Mark-Simulacrum`
Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
2021-06-22 00:00:41 +09:00
Caleb Cartwright
2608f2c63b
fix(rustfmt): load nested out-of-line mods correctly
2021-06-17 22:35:19 -05:00
Yuki Okushi
1e2258ffa9
Use AttrVec
for Arm
, FieldDef
, and Variant
2021-06-17 08:04:54 +09:00
Ryan Levick
58c63cf8de
Add support for using qualified paths with structs in expression and pattern
...
position.
2021-06-10 13:18:41 +02:00
jedel1043
e243be6ada
Allow formatting Anonymous{Struct, Union}
declarations
2021-05-16 22:13:38 -05:00
Andy Wang
ef31361766
Rename RealFileName::Named
to LocalPath
2021-05-12 22:12:43 -05:00
Andy Wang
e4b5621b0e
Only deal with LocalPath in conversion
2021-05-12 22:12:43 -05:00
Andy Wang
8526acee21
Rename span_to_string to span_to_diagnostic_string
2021-05-12 22:12:43 -05:00
Caleb Cartwright
f87414729f
fix: backport changes for latest rustc api comaptibility
2021-05-02 10:37:43 -05:00
Yuki Okushi
ddb224a173
Upgrade annotate-snippets
to 0.8 ( #4762 )
2021-04-22 08:33:36 -05:00
ChinYing-Li
dac2423f3f
Recognize when a block comment has been ended inside a string literal ( #4312 )
2021-04-21 21:30:42 -05:00
Caleb Cartwright
78b0728887
refactor: remove panics on misconfigured widths
2021-04-21 21:27:50 -05:00
Caleb Cartwright
a168d92f9a
tests: augment heuristics tests
2021-04-21 21:27:50 -05:00
Caleb Cartwright
1bcc1f8df5
refactor: apply heuristic config changes in lib
2021-04-21 21:27:50 -05:00
Caleb Cartwright
ea1611c06e
feat(config): expose all width heurstic options
2021-04-21 21:27:50 -05:00
Joshua Nelson
943b97c3ae
Fix errors when parallel_compiler
is enabled
2021-04-21 21:17:36 -05:00
Joshua Nelson
61ee1089f0
Use rustc_private
instead of crates.io dependencies
...
- Update rust-toolchain to also install `rustc-dev` component
2021-04-21 21:17:36 -05:00
Caleb Cartwright
c32f2ec015
chore: fmt and cleanup
2021-04-02 23:21:06 -05:00
Caleb Cartwright
4948911608
deps: apply rustc-ap-* v712 changes
2021-04-02 23:21:06 -05:00
Caleb Cartwright
4c617e8fb3
deps: apply rustc module loading changes
2021-04-02 23:21:06 -05:00
Caleb Cartwright
a1dc57ace1
chore: apply AST HasAttrs->AstLike changes
2021-04-02 23:21:06 -05:00
Caleb Cartwright
612e8d5b9b
refactor: apply rustc mod parsing changes
2021-04-02 23:21:06 -05:00
Caleb Cartwright
2c6339571b
chore: apply pattern parsing changes
2021-04-02 23:21:06 -05:00
Caleb Cartwright
cbd83b8083
chore: add span creation util function
2021-04-02 23:21:06 -05:00
Yuki Okushi
ca4e9f47b9
Fix a legacy_derive_helpers
warning
2021-03-18 23:34:32 -05:00
Joshua Nelson
c3a5111106
Fix some clippy warnings
...
This commit can be replicated with
`cargo clippy --fix -Z unstable-options && cargo +nightly-2021-02-10 fmt`.
2021-02-18 20:20:29 -06:00
David Bar-On
432e09e89f
Add the use of rewrite_assign_rhs_with_comments to 1.x
2021-02-17 20:47:20 -06:00
David Bar-On
4b0ed96f2e
Fix for issue 4603 about extra macro body indentation (third version)
2021-02-17 20:19:27 -06:00
Joshua Nelson
6170948820
Fix warnings
...
- Fix nightly warning about `format!`
- Remove unused functions and fields
2021-02-17 20:14:46 -06:00
Caleb Cartwright
9ed75111e2
deps: apply rustc-ap v705 changes to itemkind variants
2021-02-07 12:46:43 -06:00
Caleb Cartwright
58ac85b58e
deps: bump rustc-ap crates to v701.0.0
2021-02-03 21:05:15 -06:00
Caleb Cartwright
b8f318c303
fix: don't insert trailing comma on struct lit rest in mac def
2021-01-28 22:01:50 -06:00
Caleb Cartwright
c13d2452c0
chore: backport some empty block check fixes
2021-01-27 20:58:42 -06:00
Caleb Cartwright
bd4dc36c4e
refactor: cleanup block check for statements
2021-01-27 20:58:42 -06:00
vallentin
3e61326716
Fixed semicolon getting moved into comment ( fixes #4646 )
2021-01-27 20:58:42 -06:00
Michael Morgan
384ba68d64
Add imports_granularity="Item".
...
This option splits all imports into their own `use` statement.
2021-01-27 20:58:42 -06:00
Sean Klein
5e14f760c5
fix: Avoid incorrect global 'cfg_if' Symbol interning
...
Fixes #4656
2021-01-27 19:26:58 -06:00
Ayaz Hafiz
f8deed3a3a
Include const generic type bounds in their spans
...
Closes #4310
2021-01-27 18:50:03 -06:00
Seiichi Uchida
c0fede355c
Use the span after generics and where clause ( #4208 )
2021-01-27 18:50:03 -06:00
hafiz
269584634a
Include constness in impl blocks ( #4215 )
...
Closes #4084
2021-01-27 18:50:03 -06:00
Geoffry Song
0d60a616ab
Disable deprecated_option_merge_imports tests on non-nightly
2021-01-17 11:48:47 -06:00
Geoffry Song
71863753bd
Rename merge_imports
to imports_granularity
and add a Module
option.
...
This renames the existing `true`/`false` options to `Crate`/`Never`, then adds a
new `Module` option which causes imports to be grouped together by their
originating module.
2021-01-17 11:48:47 -06:00
Caleb Cartwright
c4d551cdf5
refactor: remove unneeded clone
2021-01-16 11:17:23 -06:00
Caleb Cartwright
b30cb24286
fix: indentation issue on generic bounds
2021-01-16 11:17:23 -06:00
Caleb Cartwright
3571c5d6f7
fix: maintain redundant semis on items in statement pos
2021-01-09 12:11:52 -06:00
Mara Bos
5bb17a0d36
Account for new ast::GenericParamKind::Const::default in rust_ast.
2021-01-09 12:11:52 -06:00
Mara Bos
4644418556
Fixes for new rustc changes.
2021-01-09 12:11:52 -06:00
Mara Bos
398d2f96c3
Add support for edition 2021.
2021-01-09 12:11:52 -06:00
Seiichi Uchida
0d022d08d8
Format error and typeof types ( #4416 )
...
* Add a test for #4357
* Format error and typeof types
2020-12-20 12:05:05 -06:00
Stéphane Campinas
c536d80dc1
Fix rewrite of closures with a return type
...
If the closure's body fits in a line, the block is removed but it is
necessary if the closure has a return type.
2020-12-20 12:05:05 -06:00
Caleb Cartwright
4cfb9ef8f4
fix: don't strip nonexistent comma in derive
2020-12-20 12:05:05 -06:00
David Tolnay
96ee060529
Preserve polarity on negative non-trait impl
2020-11-30 23:24:36 -06:00
WhizSid
7d9ee7558e
Comment between typebounds ( #4474 )
...
* Test cases and get spans
* Fixed type bounds
* Fixed issue of test cases
* Fixed first test case issue
* Removed unwanted whitespaces
* Removed tmp files
2020-11-29 13:26:58 -06:00
Caleb Cartwright
823c4f820a
fix: backport some imports for cherry-picked commit
2020-11-29 13:26:58 -06:00
WhizSid
b7c38c9d50
Fixed comment dropped between & and type issue ( #4482 )
...
* Fixed comment dropped between & and type issue
* Reduced nesting levels and avoided duplications
* Removed extra allocations
2020-11-29 13:26:58 -06:00
WhizSid
6455e9de0e
Fixed 'Comment removed between type name and =' issue ( #4448 )
...
* Fixed Comment removed between type name and = issue
* Fixed where clause issue and pass the full span
* has_where condition inline
* Fixed indentation error on where clause
* Removed tmp file
2020-11-29 13:26:58 -06:00
Caleb Cartwright
ea712f1a2c
fix: apply rustc-ap updates to backported commit
2020-11-29 13:26:58 -06:00
hafiz
5e7fb45533
Pick up comments between visibility modifier and item name ( #4239 )
...
* Pick up comments between visibility modifier and item name
I don't think this hurts to fix. #2781 , which surfaced this issue, has
a number of comments relating to similar but slightly different issues
(i.e. dropped comments in other places). I can mark #2781 as closed and
then will open new issues for the comments that are not already resolved
or tracked.
Closes #2781
* fixup! Pick up comments between visibility modifier and item name
* fixup! Pick up comments between visibility modifier and item name
2020-11-29 13:26:58 -06:00
Caleb Cartwright
fb7e604538
tests: backport an additional test case
2020-11-29 13:26:58 -06:00
Adam H. Leventhal
3df383aa3c
fixes #4115 , #4029 , #3898
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
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
Ayaz Hafiz
5ffccbb627
Properly format function signature in extern blocks
...
Closes #4288
And we get to drop a method, which I think is a win :)
2020-11-28 21:59:30 -06:00
Caleb Cartwright
48d30a4f71
chore: run rustfmt against source
2020-11-28 17:41:21 -06:00
Caleb Cartwright
4d9fa00fd5
feat: support underscore expressions
2020-11-28 17:41:21 -06:00
Caleb Cartwright
5c0673c371
refactor: update cfg_if attr parsing
2020-11-28 17:41:21 -06:00
Caleb Cartwright
4f32ce8434
feat: support struct/slice destructuring
2020-11-28 17:41:21 -06:00
Caleb Cartwright
5b216029b5
deps: minor rustc_ast changes for v691
2020-11-28 17:41:21 -06:00
Caleb Cartwright
581da523db
deps: bump rustc-ap to v687
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
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
ce13ff15c3
Correctly create artificial span for formatting closure body
...
This commit partially reverts #3934 , opting to create a span that covers
the entire body of a closure when formatting a closure body with a
block-formatting strategy, rather than having the block-formatting code
determine if the visitor pointer should be rewound. The problem with
rewinding the visitor pointer is it may be incorrect for other (i.e.
non-artificial) AST nodes, as in the case of #4382 .
Closes #4382
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
Caleb Cartwright
ae6b40e2f9
fix: remove ignored depr attribute which now errors
2020-11-05 20:45:11 -06:00
Caleb Cartwright
1139e6e5cc
fix: remove comment from cherry-pick that v1.x doesn't handle
2020-11-05 20:45:11 -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
Caleb Cartwright
98975e1a64
tests: adjust some cherry-picekd tests
2020-11-02 18:31:51 -06:00
Caleb Cartwright
2b6226ce49
fix: resolve some parser related bugs
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
Caleb Cartwright
e131797b62
deps: bump rustc-ap to v686
2020-11-02 18:31:51 -06:00
Michael Müller
fa9d97499e
Fix overriding license header bug ( #4488 )
...
* Override header to None when path len = 0
* Add regression test
* Ensure nightly
2020-10-24 11:14:52 -05: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
Caleb Cartwright
31cef56779
feat: add initial support for ConstBlock expressions
2020-10-24 11:13:00 -05:00
Caleb Cartwright
c89638ae55
deps: update macro parsing
2020-10-24 11:13:00 -05:00
David Tolnay
14d53f75c9
Use rustfmt given by RUSTFMT env var ( #4419 )
2020-10-04 16:58:34 -05:00
Ayaz Hafiz
2a8ff209f6
fixup! Preserve and format type aliases in extern blocks
2020-10-01 19:12:22 -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
d6a220b70a
feat: support config. of leading match arm pipe
2020-09-24 09:43:31 -05:00
David Tolnay
8635a5ca44
deps: bump rustc-ap to v679
2020-09-23 00:45:18 -05:00
Caleb Cartwright
9ba373f822
deps: bump rustc-ap to v678
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
aa11c27490
chore: run rustfmt
2020-09-04 19:01:18 -05:00
Caleb Cartwright
637ddfb6da
deps: bump rustc-ap to v673
2020-09-04 19:01:18 -05:00
Caleb Cartwright
e4617e0e61
deps: bump rustc-ap to v672
2020-09-04 19:01:18 -05:00
Caleb Cartwright
a17803127f
fix: inverted span on attrs within closure
2020-08-09 14:32:34 -05:00
Caleb Cartwright
bf359c6ebc
chore: backport 8157a3f0afe978d3e953420577f8344db7e905bf
2020-07-15 09:19:21 -05:00
Caleb Cartwright
391cd3e324
deps: bump rustc-ap to v669
2020-07-14 21:36:24 -05:00
Caleb Cartwright
b243075d75
deps: bump rustc-ap-* to v668
2020-07-09 23:15:08 -05:00
Caleb Cartwright
da18032ba4
deps: bump rustc-ap* to v666
2020-06-27 13:15:54 -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
David Tolnay
bc9a0b2974
Switch to std::error::Error for errors ( #3948 )
2020-06-11 20:23:24 -05:00
Caleb Cartwright
b28fd5f91c
deps: apply upstream rustc-* changes
2020-06-11 13:22:37 -05:00
topecongiro
08776ef3b4
Support module-level rustfmt::skip in sub-modules
2020-06-08 10:42:43 +09:00
Seiichi Uchida
577ef8136f
Update rustc-ap-* crates to 659.0.0 for rustfmt-1.4.15 ( #4184 )
2020-05-19 17:31:28 +09: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
9714a140c9
refactor: use ast::attr:HasAttrs
2020-03-30 13:11:00 -05:00
Caleb Cartwright
ac2d5b85a5
deps: bump rustc-ap* to v651
2020-03-30 12:02:39 -05: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
537d746e08
fix: use correct ForeignItem span
2020-03-27 22:00:00 -05:00
Caleb Cartwright
bea7209d0a
chore: fix src formatting
2020-03-27 21:53:40 -05:00
Caleb Cartwright
9b0ed57af6
refactor: parse & mod resolver for rustc-ap v650
2020-03-27 21:33:34 -05:00
Caleb Cartwright
bd5dff4012
refactor: backport syntux mod
2020-03-26 21:25:34 -05:00
Caleb Cartwright
9699c96cf1
deps: bump to rustc v647
2020-03-26 17:20:24 -05:00
Caleb Cartwright
7a76ec062d
deps: bump to rustc v644
2020-03-26 15:26:58 -05:00
Caleb Cartwright
760bb29feb
chore: fix compile warnings
2020-02-08 22:54:37 -06:00
Caleb Cartwright
e72f307f15
fix: backport parse bug fix
...
Backport the fix for the parser bug where the messages from
fatal/non-recoverable parser errors were being silently eaten by
rustfmt.
2020-02-08 22:47:48 -06: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
Chris Emerson
99f9f576d4
Return an error if --check
or --emit json
are used with stdin. ( #3875 )
2019-10-25 15:05:24 +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
Caleb Cartwright
3a073f177c
fix: handling of newline_style conflicts ( #3850 )
2019-10-19 17:15:13 +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
a5d16df9a4
feat: use offline by default with cargo fmt ( #3830 )
2019-10-19 16:35:33 +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
Caleb Cartwright
207a58f365
fix panic on closure with empty block expr ( #3846 )
2019-10-08 11:00:31 +09:00
Caleb Cartwright
6dcbc5d78e
fix: handle block comments with trailing line comments ( #3842 )
2019-10-08 10:12:21 +09:00
Stéphane Campinas
8073244420
improve detection of URL inside a string that is being rewritten. ( #3809 )
2019-10-07 16:43:50 +09:00
Stéphane Campinas
160c3aafc5
handle hard tabs when formatting trailing comments ( #3836 )
2019-10-07 16:40:27 +09:00
Caleb Cartwright
ba4bf03d84
don't fail on recoverable parser errors in ignored files ( #3782 )
2019-10-07 10:24:08 +09:00
Caleb Cartwright
ed697c9347
fix: support raw prefix identifiers in statics
2019-10-05 12:34:48 -05:00
Seiichi Uchida
383306e5fe
Update rustc-ap-* crates to 606.0.0 ( #3835 )
2019-10-05 23:40:24 +09:00
Stéphane Campinas
fb01dc857c
do not force comments to be indented with a comment trailing a line of code ( #3833 )
2019-10-05 00:22:01 +09:00
rChaser53
7926851bb0
stop to strip 'impl' from impl trait type alias ( #3816 )
2019-10-04 11:25:16 +09:00
Matthew Pomes
e28ae8b4a3
Init Logger for unit tests ( #3829 )
...
Add `init_log()` function which attempts to init logger, and
ignores failure. The function is called at the beginning of
every test, and will fail if the logger is already initialized.
The logger must be initialized in every test, becuase cargo runs
the tests in parallel, with no garentees about the order and time
each starts.
2019-10-04 11:24:33 +09:00
Stéphane Campinas
dbd8936391
fix rust code in comment with a line containing only a hash sign ( #3818 )
2019-10-02 23:58:25 +09:00
Caleb Cartwright
f4bc494153
add --offline mode fallback to cargo fmt ( #3813 )
2019-10-02 23:56:20 +09:00
Caleb Cartwright
7c9c0d1a39
fix: merge_imports handling of ::{self}
2019-09-26 20:02:41 -05:00
Caleb Cartwright
9c2b375ba9
refactor to use param naming where appropriate ( #3803 )
2019-09-24 09:25:19 +09:00
Caleb Cartwright
3bb266180e
fix: handling of empty str for license template path ( #3804 )
2019-09-24 09:24:05 +09:00
Caleb Cartwright
6b0a447150
feat: support parameter attributes ( #3793 )
2019-09-20 16:11:52 +09:00
rChaser53
4449250539
fix the error with long string in raw string ( #3800 )
2019-09-18 22:39:27 +09:00
Shotaro Yamada
ca78653d61
Use Cell instead of RefCell ( #3798 )
2019-09-18 22:37:08 +09:00
rChaser53
789a097a71
fix internal error when using rustfmt::skip with newline on stmt ( #3785 )
2019-09-15 23:45:46 +09:00
Caleb Cartwright
dfe87fe946
fix: async expression indentation ( #3789 )
2019-09-11 09:55:18 +09:00
Seiichi Uchida
ceca01465a
Update deps ( #3788 )
2019-09-08 23:33:21 +09:00
Seiichi Uchida
5baba86fe5
Update rustc-ap-* crates to 581.0.0 ( #3783 )
2019-09-06 22:41:03 +09:00
rChaser53
1ded995ee7
fix 'left behind trailing whitespace' ( #3761 )
2019-09-05 19:38:00 +09:00
Seiichi Uchida
783948fcbb
Fix handling of match arm's rewrite ( #3775 )
2019-09-05 11:15:46 +09:00
CreepySkeleton
e81ec20af0
Add --config command line option ( #3767 )
2019-09-05 11:15:19 +09:00
Valentine Valyaeff
15a28f79b8
Another fix for merge_imports
( #3769 )
2019-09-04 23:02:10 +09:00
Andrey
950b288d6f
do not remove discriminant value if exists ( #3771 ) ( #3772 )
2019-09-04 23:01:04 +09:00
rChaser53
2bf67b6e5c
fix TrailingWhitespace when using line breaks in macros arguments ( #3768 )
2019-09-04 23:00:26 +09:00
Caleb Cartwright
ad5d9fba9b
fix formatting mods inside cfg_if macro ( #3763 )
2019-09-02 18:36:51 +09:00
Seiichi Uchida
deb329a6bb
Forbid adding or removing a block from match arms inside macro calls ( #3756 )
2019-08-28 20:50:41 +09:00
rChaser53
a09ca681de
fix the bug removing attrs ( #3760 )
2019-08-28 20:50:02 +09:00
Valentine Valyaeff
ef00f74ce3
Merge imports fix ( #3753 )
2019-08-27 11:23:55 +09:00
Caleb Cartwright
c26c0e5abf
feat: add support for --message-format option ( #3752 )
2019-08-27 09:27:32 +09:00
Caleb Cartwright
9792ff0529
Fix line numbers in checkstyle output ( #3694 )
2019-08-19 11:11:35 +09:00
Caleb Cartwright
62432fe31b
add new flag to list names of misformatted files ( #3747 )
2019-08-19 11:04:40 +09:00
Seiichi Uchida
73847d3986
Take the inner macro_use attr into acocunt while reordering ( #3749 )
2019-08-19 10:56:32 +09:00
Seiichi Uchida
1643d726ef
Use correct indent when formatting complex fn type ( #3731 )
2019-08-16 11:15:28 +09:00
Caleb Cartwright
dfd27663dc
add json emit mode ( #3735 )
2019-08-16 11:14:53 +09:00
Caleb Cartwright
541d9a8659
tests: fix failing default config unit test ( #3743 )
2019-08-14 08:02:30 +09:00
Seiichi Uchida
4871d6467a
Use the correct BytePos for the opening brace position ( #3742 )
2019-08-13 23:21:55 +09:00
Caleb Cartwright
ac150d016b
fix: remove trailing space with empty dyn macro arg ( #3737 )
2019-08-11 12:49:14 +09:00
topecongiro
0462008de8
Release 1.4.4
2019-08-06 11:14:12 +09:00
Seiichi Uchida
c0cb5eb535
Fix broken tuple pattern ( #3729 )
2019-08-06 11:09:45 +09:00
Caleb Cartwright
afc8fbd701
fix: issue with --all when workspace member also exists in dep tree ( #3726 )
2019-08-06 00:33:59 +09:00
topecongiro
3adfb08afe
Release 1.4.3
2019-08-03 00:01:59 +09:00
Igor Matuszewski
62a32e7b83
Fix most recenty nightly breakage due to removed await! support ( #3722 )
2019-08-02 23:54:39 +09:00
rChaser53
3b7a518144
fix underscore in slice patterns are removed ( #3719 )
2019-07-31 23:55:58 +09:00
topecongiro
aeb3496f31
Release v1.4.2
2019-07-31 11:10:49 +09:00
topecongiro
9e960e7d6a
Release v1.4.1
2019-07-30 14:39:07 +09:00
rChaser53
fe05e88831
fix to build with rustc 1.38.0-nightly ( 4560cb830
2019-07-28) ( #3712 )
2019-07-30 14:32:38 +09:00
topecongiro
365461349d
Release 1.4.0
2019-07-29 05:58:18 +09:00
Seiichi Uchida
983a92c872
Update rustc-ap-* crates to 541.0.0 ( #3707 )
2019-07-29 05:52:45 +09:00
Seiichi Uchida
b004329782
Simplify code around visit_fn ( #3698 )
2019-07-21 13:26:41 +09:00
Seiichi Uchida
c0e616bc1d
Implement closing-block procedure without relying on missed_span module ( #3691 )
2019-07-17 23:07:12 +09:00
Michele d'Amico
76e2ba25bd
#3665 : Implemented ( #3689 )
2019-07-17 09:40:33 +09:00
Seiichi Uchida
66c27c9161
Add #[ignore] to test that runs external process ( #3690 )
2019-07-16 19:36:23 +09:00
topecongiro
65931cd09d
Release 1.3.3
2019-07-15 22:47:10 +09:00
Seiichi Uchida
89940e541f
Fix bugs related to file-lines ( #3684 )
2019-07-15 22:41:56 +09:00
Stéphane Campinas
6487422b3e
fix print-config minimal option ( #3687 )
2019-07-15 20:58:54 +09:00
calebcartwright
6f67f07752
refactor: simplify manifest_path option checks
2019-07-14 09:56:07 -05:00
calebcartwright
aef8e93514
Merge remote-tracking branch 'upstream/master' into accept-manifest-path
2019-07-14 09:30:11 -05:00
rChaser53
71289e1d23
fix 'extra comma inserted due to comment' ( #3677 )
2019-07-14 22:16:47 +09:00
Eric Huss
e55fc6be3b
Fix using --help, --verbose, etc. ( #3620 )
2019-07-14 10:25:53 +09:00
Ruben Schmidmeister
37695b3c45
Extract configuration snippet tests into own module ( #3667 )
...
* Extract configuration snippet tests into own module
* Move helper function outside of test function
2019-07-14 10:22:18 +09:00
calebcartwright
17cbbd8cbc
feat: add --manifest-path support to cargo fmt
2019-07-12 20:59:29 -05:00
topecongiro
679c8d5f10
Release 1.3.2
2019-07-06 14:22:30 +09:00
Seiichi Uchida
3200af9785
Do not consider macro-origin await as chain item ( #3671 )
2019-07-06 14:17:53 +09:00
Caleb Cartwright
ff49b80628
fix: handling of --all when dep name and dir name differ ( #3664 )
2019-07-06 14:17:35 +09:00
topecongiro
44149d6ba4
Release 1.3.1
2019-06-30 13:20:32 +09:00
Stéphane Campinas
1f06a8b361
fix extraction of missing comments when rewriting an empty where clause ( #3663 )
2019-06-30 12:19:24 +09:00
calebcartwright
731f7d5200
fix: handling of associated type bounds
2019-06-28 16:15:42 -05:00
Nikhil Benesch
e0e2f0db53
Don't panic on license check errors ( #3655 )
...
Without this case, an ErrorKind::LicenseCheck results in a panic:
thread 'main' panicked at 'internal error: entered unreachable code', src/tools/rustfmt/src/formatting.rs:320:18
N.B.: errors of this type are only raised when the configuration file
contains `license_tempate_path = "TEMPLATE_FILE"`.
2019-06-26 10:51:11 +09:00
Caleb Cartwright
c955b5908e
fix: run in sub dirs/workspace member dirs ( #3652 )
2019-06-25 23:15:33 +09:00
rChaser53
9986b9d011
fix internal error for long closure types ( #3653 )
2019-06-25 23:14:19 +09:00
Nootan Ghimire
561653326d
Add newline after help text ( #3650 )
2019-06-25 11:44:14 +09:00
rChaser53
26d370e9e5
remove unreachable!() ( #3646 )
2019-06-23 16:24:40 +09:00
rChaser53
5b0ce0ed12
avoid not to truncate necessary chars ( #3640 )
2019-06-23 14:32:14 +09:00
Seiichi Uchida
1d19a08ed4
Format the last expression-statement as expression ( #3631 )
2019-06-17 08:53:39 +09:00
Stéphane Campinas
84c2356590
handle unicode chars in closures ( #3632 )
...
The `NotUnicode` branch was unecessarily put on a new line, although it
was within max width:
```diff
fn baz() {
let our_error_b = result_b_from_func.or_else(|e| match e {
NotPresent => Err(e).chain_err(|| "env var wasn't provided"),
- NotUnicode(_) => Err(e).chain_err(|| "env var was very very very borkæ–‡å—化ã"),
+ NotUnicode(_) => {
+ Err(e).chain_err(|| "env var was very very very borkæ–‡å—化ã")
+ }
});
}
```
2019-06-17 08:53:17 +09:00
Caleb Cartwright
944fc57e10
tests: ensure min number of system/idempotent tests ran ( #3629 )
2019-06-16 23:47:22 +09:00
Seiichi Uchida
a4eab17d7c
Fix is_subpath
2019-06-14 19:16:17 +09:00
Ruben Schmidmeister
dbac28b4b4
Use trait to abstract emit modes ( #3616 )
2019-06-13 06:59:20 +09:00