Commit Graph

5335 Commits

Author SHA1 Message Date
Caleb Cartwright
62987562e2 refactor: extract final rustc_parse touchpoint from macros.rs 2021-12-21 10:55:39 -06:00
Caleb Cartwright
c8cf454173 refactor: move lazy_static parsing to parse mod 2021-12-21 10:55:39 -06:00
Caleb Cartwright
9ce5470a8c refactor: move macro arg parsing to parse mod 2021-12-21 10:55:39 -06:00
Caleb Cartwright
40b73d8fee refactor: rename syntux mod to parse 2021-12-21 10:55:39 -06:00
Caleb Cartwright
0346bc74a7
Merge pull request #5140 from calebcartwright/subtree-sync-2021-12-19
Subtree sync
2021-12-20 16:40:50 -06:00
Caleb Cartwright
b214938ff3 chore: bump toolchain 2021-12-20 11:58:27 -06:00
Caleb Cartwright
8bf82aeb83 Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-19 2021-12-19 15:22:45 -06:00
Nicholas Nethercote
122e1c3802 Remove unnecessary sigils around Ident::as_str() calls. 2021-12-15 17:32:42 +11:00
Nicholas Nethercote
3bb5f81d8d Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
Nicholas Nethercote
b4afb38f2f Remove SymbolStr.
By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15 13:30:26 +11:00
Yacin Tmimi
57ac92bf16 Prevent duplicate comma when formatting struct pattern with ".."
Fixes 5066

When a struct pattern that contained a ".." was formatted, it was
assumed that a trailing comma should always be added if the struct
fields weren't formatted vertically.

Now, a trailing comma is only added if not already included in the
reformatted struct fields.
2021-12-14 13:28:25 -06:00
Matthias Krüger
740fb57f5d clippy fixes 2021-12-13 20:36:12 -06:00
Yacin Tmimi
f40b1d9f1a Backport: Do not touch module with #![rustfmt::skip] (4297)
Although the implementation is slightly different than the original PR,
the general idea is the same. After collecting all modules we want to
exclude formatting those that contain the #![rustfmt::skip] attribute.
2021-12-07 18:45:00 -06:00
Caleb Cartwright
0167c5303f Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree 2021-12-02 21:35:30 -06:00
Caleb Cartwright
8da8371857
Merge pull request #5121 from calebcartwright/subtree-sync-2021-12-02
subtree sync
2021-12-02 21:29:47 -06:00
Caleb Cartwright
e305322557 Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02 2021-12-02 21:02:14 -06:00
Yacin Tmimi
ec46ffd981 Determine when new comment lines are needed for itemized blocks
Fixes 5088

Previously, rustfmt would add a new comment line anytime it reformatted
an itemized block within a comment when ``wrap_comments=true``. This
would lead to rustfmt adding empty comments with trailing whitespace.

Now, new comment lines are only added if the original comment spanned
multiple lines, if the comment needs to be wrapped, or if the comment
originally started with an empty comment line.
2021-12-01 18:31:10 -06:00
Yacin Tmimi
1f28683ffa Update nightly only test with #[nightly_only_test] attribute 2021-11-29 14:02:02 -06:00
Caleb Cartwright
0fc846f979 refactor: maintain more AST info when formatting a RHS 2021-11-28 23:25:06 -06:00
Yacin Tmimi
a21f1b6c2a Conditionally compile tests based on CFG_RELEASE_CHANNEL env var
Adds the ``nightly_only_test`` and ``stable_only_test`` attribute macros
that prevent or allow certain tests to compile on nightly and stable
respectively. This is achieved through conditionally outputting the
tests TokenStream.

If CFG_RELEASE_CHANNEL is not set, it's assumed that we're running in a
nightly environment.

To mark a test as nightly only:

    #[nightly_only_test]
    #[test]
    fn only_run_on_nightly() {
        ...
    }

To mark a test a stable only:

    #[stable_only_test]
    #[test]
    fn only_run_on_stable() {
        ...
    }
2021-11-27 17:36:18 -06:00
Yacin Tmimi
67fd9ec300 Run Windows, Linux, and Mac CI tests with nightly and stable channels 2021-11-27 13:19:02 -06:00
mujpao
ea042b90c9 Add more tests for comments in lists 2021-11-27 11:38:36 -06:00
Fabian Keller
243cec7a0b Update README.md 2021-11-26 16:47:45 -06:00
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
Dom
4389a4ce49 fix: do not wrap reference-style doc links
Prevents wrap_comments from incorrectly wrapping reference-style doc
links.
2021-11-23 16:17:52 -06:00
Johannes Linke
826eba8984
Add a few missing tracking issues in Configurations.md (#5084)
* Add a few missing tracking issues in Configurations.md

* fix: tracking issue for imports_granularity stabilization

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2021-11-19 19:22:50 -06:00
mujpao
196e676504 Preserve normalized comments after last list item 2021-11-19 19:18:17 -06:00
Caleb Cartwright
2c442ccf25 fix: correct some type alias issues 2021-11-18 13:43:37 -06:00
Caleb Cartwright
0023abfb2c tests: add cases for type alias issues 2021-11-18 13:43:37 -06:00
Caleb Cartwright
eee8f0419d refactor: cleanup duplicative Impl handling code 2021-11-17 13:57:25 -06:00
Wu Yu Wei
e6d1bf5acb Link tracking issues in Configurations.md (#4096)
# Conflicts:
#	Configurations.md
2021-11-08 19:04:57 -06:00
Caleb Cartwright
f99e3582bd Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync 2021-11-07 20:37:34 -06:00
Caleb Cartwright
ea199bacef
Merge pull request #5070 from calebcartwright/rustup-2021-11-s1
subtree sync
2021-11-07 19:40:15 -06:00
Caleb Cartwright
31bc54a9a8 chore: bump toolchain 2021-11-07 19:14:34 -06:00
Caleb Cartwright
4621915d25 Merge remote-tracking branch 'upstream/master' into rustup-2021-11-s1 2021-11-07 14:44:33 -06:00
Caleb Cartwright
e4472d3b07 refactor: dedupe associated item visitation 2021-11-07 08:12:58 -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
19c5c74951 refactor: dedupe & simplify ty alias formatting 2021-11-06 16:06:21 -05:00
mujpao
4d50e7c760 Put empty trait braces on same line if possible 2021-11-05 20:40:49 -05:00
Dmitry Murzin
9027db984b Update IntelliJ Integration (#4238) 2021-11-05 19:29:52 -05:00
Caleb Cartwright
a5f85058ac fix: handle external mods imported via external->inline load hierarchy 2021-11-04 18:35:38 -05:00
Caleb Cartwright
e75c4d7ee9 ci: drop appveyor 2021-11-03 21:39:08 -05:00
r00ster
bd86077c58 Remove grave accent that shouldn't be there 2021-11-02 21:28:24 -05:00
Peter Hall
c1eab154c9 Use a custom env var for log settings intead of default RUST_LOG
# Conflicts:
#	src/rustfmt/main.rs
2021-10-31 21:43:29 -05:00
Yacin Tmimi
5ce82e1513 Prevent trailing whitespace in where clause bound predicate
resolves 5012
resolves 4850

This behavior was noticed when using the ``trailing_comma = "Never"``
configuration option (5012).

This behavior was also noticed when using default configurations (4850).

rustfmt would add a trailing space to where clause bounds that had an
empty right hand side.

Now no trailing space is added to the end of these where clause bounds.
2021-10-30 23:07:34 -05:00
Jonathan
a4d7011c18 Document RUSTFMT environment variable (#4464)
* Document RUSTFMT env var

* Move documentation up

* Apply suggestions from code review

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>

* Fix accedental removal

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
# Conflicts:
#	README.md
2021-10-30 11:07:59 -05:00
chansuke
a24ed3c322 Fix MSRV 2021-10-30 11:07:59 -05:00
enterprisey
54b1e0bb15 README grammar fix (#3926)
Remove comma splice
2021-10-30 11:07:59 -05:00
Caleb Cartwright
ed5a0250d3 refactor: minor parser cleanup 2021-10-30 11:00:19 -05:00
Yacin Tmimi
bc46af9742 Retain trailing comments in module when using rustfmt::skip attribute
Resolves 5033

Trailing comments at the end of the root Module were removed because the
module span did not extend until the end of the file.

The root Module's span now encompasses the entire file, which ensures
that no comments are lost when using ``#![rustfmt::skip]``
2021-10-28 21:44:39 -05:00