Commit Graph

5161 Commits

Author SHA1 Message Date
Patrick Walton
f0f449d6ed Wrap long array and slice patterns.
Closes #4530.
2021-10-04 20:41:17 -05:00
Ulyssa
e3203ef5e6 Add tests for binop_separator = Back 2021-09-28 22:20:34 -05:00
Yacin Tmimi
a5138b34d5 Prevent removal of qualified path for tuple struct inside macro
fixes 5005

This was very similar to 4964 and the fix was to extract and pass along
the qself of the ``PatKind::TupleStruct``
2021-09-27 17:49:10 -05:00
Lucas Kent
cb144c35e7 In Configurations.md demonstrate both cases for noop selections 2021-09-25 14:48:20 -05:00
Caleb Cartwright
4b9d637f58 refactor: simplify local dep lookups 2021-09-23 21:12:57 -05:00
Caleb Cartwright
7f6229b9aa tests: restructure and extend cargo-fmt tests 2021-09-23 21:12:57 -05:00
Caleb Cartwright
74df7b3265 deps: update cargo_metadata to include 'path' 2021-09-23 21:12:57 -05:00
Mark Rousskov
9060bc5583 Migrate to 2021 2021-09-20 22:21:42 -04:00
Ulyssa
dd445aba08 Trailing comma on match block goes missing when guard is on its own line 2021-09-20 20:05:52 -05:00
Caleb Cartwright
7aa69e5bc8 refactor: use iter workaround for contains() gap 2021-09-16 22:01:50 -05:00
Caleb Cartwright
17cb2b147e feat: add --check flag to cargo fmt (#3890) 2021-09-16 22:01:50 -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
Arjen Laarhoven
9d65b7dcd1 feat: upper- or lowercase hexadecimal literals 2021-09-14 21:22:26 -05:00
Seiichi Uchida
d4ffd1efa4 Support @generated marker to skip code formatting
This is a copy of #4296 with these changes:
* file is not reopened again to find if the file is generated
* first five lines are scanned for `@generated` marker instead of one
* no attempt is made to only search for marker in comments

`@generated` marker is used by certain tools to understand that the
file is generated, so it should be treated differently than a file
written by a human:
* linters should not be invoked on these files,
* diffs in these files are less important,
* and these files should not be reformatted.

This PR proposes builtin support for `@generated` marker.

I have not found a standard for a generated file marker, but:
* Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated)
* Phabricator tool which was spawned from Facebook internal tool
  [also understands `@generated` marker](https://git.io/JnVHa)
* Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP)

My personal story is that rust-protobuf project which I maintain
was broken twice because of incompatibilities/bugs in rustfmt marker
handling: [one](https://github.com/stepancheg/rust-protobuf/issues/493),
[two](https://github.com/stepancheg/rust-protobuf/issues/551).
(Also, rust-protobuf started generating `@generated` marker
[6 years ago](https://git.io/JnV5h)).

While rustfmt AST markers are useful to apply to a certain AST
elements, disable whole-file-at-once all-tools-at-once text level
marker might be easier to use and more reliable for generated code.
2021-09-14 21:22:26 -05:00
Laurențiu Nicola
67a59f6ee3 opts: rephrase wording for --all and -p 2021-09-13 18:57:31 -05: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
Nipunn Koorapati
b10ab51fed rustfmt doc code blocks with multiple comma-separated attributes
Added test covering this. Chose to treat the code block
as rust if and only if all of the comma-separated attributes
are rust-valid. Chose to allow/preserve whitespace around commas

Fixes #3158
2021-09-08 23:27:51 -05:00
Caleb Cartwright
a80688329c fix: handle param doc comments for macro scenarios 2021-09-08 19:27:31 -05:00
Caleb Cartwright
57548aa096 fix: resolve idempotency issue in extern body elements 2021-09-07 20:22:09 -05:00
Caleb Cartwright
3d8cd57c2f tests: add files for issue 4579 2021-09-06 18:14:13 -05:00
Stéphane Campinas
c2f0e99d85 try to write the parameter on a new line in case the attribute/parameter together are over max_width 2021-09-06 18:14:13 -05:00
Caleb Cartwright
a59cac29f4 fix: use correct spans for params with attrs 2021-09-06 18:14:13 -05:00
Caleb Cartwright
59063e8b40 fix: newline width calc in combine w/ comments (#4123) 2021-09-06 17:02:20 -05: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
Eric
ae5696a7c4 test: add test for #4322 2021-09-02 20:53:15 -05:00
Eric
bfc60466bd test: add test for #4954 2021-09-02 20:53:15 -05:00
Eric
33d1368674 test: add test for #4257 2021-09-02 20:53:15 -05:00
Eric
d19f69cd71 test: add missing source for #4943 2021-09-02 20:53:15 -05:00
Akiomi Kamakura
c71c68c43f Add <title> to docs 2021-09-01 21:59:58 -05:00
Yusuke Tanaka
ca9b050bbf Implement One option for imports_granularity (#4669)
This option merges all imports into a single `use` statement as long as
they have the same visibility.
2021-08-31 18:33:06 -05:00
Cameron Steffen
a603756cc5 Temporary fix rustfmt for let-else 2021-08-30 20:18:41 -05:00
Deadbeef
20ddab3def Fix rustfmt test 2021-08-27 11:53:03 +00: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
Ashvin Arsakularatne
e81c393663 fix: remove wrong reformatting of qualified paths in struct patterns 2021-08-25 21:18:41 -05:00
David Tolnay
fd6b025e8a Preserve visibility on trait items inside trait and impl 2021-08-22 12:06:18 -05:00
David Tolnay
c8bd550c8d Add test for visibility on a trait item (currently wrong) 2021-08-22 12:06:18 -05: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
David Bar-On
f7872887e9 Fix for version config option anchor 2021-08-17 21:55:26 -05:00
gunadhya
ec86cfd6ba Fix redirect issue
Signed-off-by: gunadhya <6939749+gunadhya@users.noreply.github.com>
2021-08-17 21:55:26 -05:00
gunadhya
042c2ec369 Added Updated default version to Rustfmt docs config 2021-08-17 21:55:26 -05:00
jdollar
3c36a0c0b7 Exluding v0.8.1 and v0.7 from the config dropdown
Older tags of the repo don't have the configuration.md file
that the docs/index.html file uses to display configuration options.
Removing them from the list since they don't apply to the use case of the
documentation page.
2021-08-17 21:55:26 -05:00
Ayaz Hafiz
5c7ac69393 Warn when rate limit is on docs page
Demo: https://5f0fad2f06c62143ac519413--festive-golick-afb5e0.netlify.app
2021-08-17 21:55:26 -05:00
Ayaz Hafiz
f5c782f321 fixup! Ensure that doc url hash IDs are scrolled to on page load 2021-08-17 21:55:26 -05:00
Ayaz Hafiz
bf47fc17a3 Ensure that doc url hash IDs are scrolled to on page load
I broke this a few weeks ago so I'll fix it

Demo: https://5f0fa445faca4aff5f580029--naughty-borg-09b903.netlify.app/?version=master&search=#brace_style
2021-08-17 21:55:26 -05:00