Commit Graph

5775 Commits

Author SHA1 Message Date
Trivikram Kamat
182a20378b ci: bump actions/checkout to v4 2024-09-09 12:21:05 -04:00
cui fliter
91b2c17ffb
Add missing backtick in comment (#6317)
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-09 11:23:15 -04:00
ding-young
d720a7ef77 impl rewrite_result for ast::Expr 2024-09-05 02:25:45 -04:00
ding-young
b40c3cc388 impl rewrite_result for ForeignItem 2024-09-05 02:02:40 -04:00
ding-young
2639370905 impl rewrite_result for TraitAliasBounds, WherePredicate 2024-09-05 02:02:40 -04:00
Mattias Wallin
1a70f40d7f Avoid allocation in ChainItemKind::is_tup_field_access 2024-09-03 18:48:41 -04:00
Yacin Tmimi
06e16449d2 Add test cases for issue 4381
This was one of the original issues filed against rustfmt that discussed
using a natural sort order instead of a lexicographical order. At the
time it was closed, but now that we're supporting version-sorting in
`style_edition=2024` I thought it would be good to add a test case.
2024-09-03 15:21:36 -04:00
Yacin Tmimi
ae59ee755a sort rustfmt imports
The version-sort algorithm makes changes to the sort order of imports,
and we're updating them here for the self tests.
2024-09-03 15:21:36 -04:00
Yacin Tmimi
296417260c use version-sort when reordering imports using style_edition=2024 2024-09-03 15:21:36 -04:00
Yacin Tmimi
1681c91a35 implement version-sorting algorithm for rust identifiers
The algorithm is described in the [style guide] and was introduced in
`r-l/rust 115046`.

[style guide]: https://doc.rust-lang.org/nightly/style-guide/#sorting
2024-09-03 15:21:36 -04:00
Mattias Wallin
5d30ce6844 Avoid allocating intermediate strings in determine_operation 2024-09-02 22:42:53 -04:00
Mattias Wallin
9d407bfd1b Avoid allocating intermediate strings in ItemizedBlock::trimmed_block_as_string 2024-09-02 22:42:53 -04:00
Mattias Wallin
40909b4331 Fix test_editions_2015_2018_2021_identical
Was comparing unit type.
2024-09-01 11:00:56 -04:00
ding-young
35b3889c77 impl rewrite_result for ControlFlow, Stmt, update rewrite_index 2024-09-01 10:15:00 -04:00
ding-young
193051438d update rewrite_assignment to return RewriteResult 2024-09-01 09:07:21 -04:00
Caleb Cartwright
46cb7d3220 refactor: improve mapping of legacy 'version' to 'style_edition' 2024-08-27 20:49:15 -05:00
Caleb Cartwright
065258659d feat: implement 2024 Style Edition for expr overflows 2024-08-27 20:49:15 -05:00
Caleb Cartwright
0c6515cacc feat: support style edition differing defaults in config loading 2024-08-27 20:49:15 -05:00
Caleb Cartwright
c0c3dc7a25 refactor: include edition & style edition in CliOptions 2024-08-27 20:49:15 -05:00
Caleb Cartwright
53d5ccd5e9 refactor: use style edition when loading from partial config 2024-08-27 20:49:15 -05:00
beetrees
5ee4d3b532 Remove outdated comment from mac.yml 2024-08-26 15:31:28 -04:00
ding-young
6f5e99b7b5 update macro rewrite functions to return RewriteResult 2024-08-25 09:23:04 -04:00
Yacin Tmimi
448906160d
Merge pull request #6285 from ytmimi/subtree-push-nightly-2024-08-17
subtree-push nightly-2024-08-17
2024-08-19 19:04:27 -04:00
Yacin Tmimi
d34fca4f01 bump toolchain to nightly-2024-08-17 2024-08-17 14:38:27 -04:00
Yacin Tmimi
6bcadd6aa4 Merge remote-tracking branch 'upstream/master' into subtree-push-nightly-2024-08-17 2024-08-17 14:36:42 -04:00
ding-young
fbe04244f8 update rewrite_chain to return RewriteResult 2024-08-15 12:32:26 -04:00
Lukasz Anforowicz
caaa612a0b Ensure that fn config_path returns canonicalized paths.
This commit ensures that `fn config_path` in `rustfmt/src/config/mod.rs`
always returns canonicalized paths.  This is achieved by canonicalizing
both: 1) paths received via `CliOptions` (after checking if the path
exists) as well as 2) paths returned via `get_toml_path` (canonicalizing
within `fn get_toml_path`).

Fixes https://github.com/rust-lang/rustfmt/issues/6178
2024-08-14 15:02:38 -04:00
ding-young
68dc912b99 update rewrite functions in imports.rs 2024-08-14 12:36:26 -04:00
Nicholas Nethercote
7b2299a2d2 Use impl PartialEq<TokenKind> for Token more.
This lets us compare a `Token` with a `TokenKind`. It's used a lot, but
can be used even more, avoiding the need for some `.kind` uses.
2024-08-14 16:37:09 +10:00
John Kåre Alsaker
57af02c9c4 Link std statically in rustc_driver 2024-08-11 04:16:53 +02:00
ding-young
40f5075269 impl rewrite_result for Pat, TuplePatField
- also update rewrite_unary_*** to return RewriteResult
2024-08-05 07:53:46 -06:00
David Tolnay
88944668fe Print empty commit info without trailing hyphen 2024-08-04 12:44:32 -06:00
David Tolnay
15c75fec4f Check exit status of git commands spawned by build script 2024-08-04 12:44:32 -06:00
David Tolnay
17c5869dff Print a deterministic length of commit hash in --version 2024-08-04 08:00:40 -06:00
benluiwj
a1361bd0d5 Run check-diff tests in ci 2024-08-03 05:17:27 -06:00
benluiwj
63d50dd1d7 Add cd and git clone functionality to check-diff crate
Included unit tests for the new functionality as well.
2024-08-03 05:17:27 -06:00
ding-young
b8a5b211ef impl rewrite_result for ChainItem 2024-08-03 04:43:03 -06:00
ding-young
3d468e2d92 update combine_strs_with_missing_comments 2024-08-03 04:43:03 -06:00
ding-young
5325b9e98c modify rewrite_literal 2024-08-03 04:43:03 -06:00
Jubilee Young
6159460963 rustfmt: Remove has_cpuid from test 2024-08-02 02:12:29 -07:00
Michael Goulet
90a86a78d2 Suppress must_use on eat calls in rustfmt 2024-07-30 10:10:36 -04:00
Caleb Cartwright
cf352a766f chore: apply review suggestions 2024-07-28 19:37:36 -05:00
Caleb Cartwright
d66ab31b53 tests: add new load_config tests 2024-07-28 19:37:36 -05:00
Caleb Cartwright
d65daa9c4f refactor: rebase with set_cli() behavior 2024-07-28 19:37:36 -05:00
Caleb Cartwright
7a5a936e79 docs: use StyleEdition in dev guide
s
2024-07-28 19:37:36 -05:00
Caleb Cartwright
aa8a53f687 refactor: switch idempotence/system tests to style_edition
Updates all the various files utilized in the system and
idempotence tests to directly use the corresponding
'style_edition' configuration as opposed to keeping
the original 'version' values and relying on the mapping.
2024-07-28 19:37:36 -05:00
Caleb Cartwright
e04e411852 tests: validate style_edition derivation
Adds a few tests that validate the various scenarios
of precendence, overrides, and defaults to ensure the
correct 'style_edition' value is selected even when
other options like 'edition' and/or 'version' are included.
2024-07-28 19:37:36 -05:00
Caleb Cartwright
b6c89fc657 feat: add --style-edition option to rustfmt binary 2024-07-28 19:37:36 -05:00
Caleb Cartwright
7c41e2bfba refactor: switch from 'version' to 'style_edition'
Updates the relevant formatting logic to utilize the
new 'style_edition' option directly instead of the now
deprecated 'version' option. 'version' has only been
soft deprecated and has auto mapping in place so there
should be zero formatting impact to current 'version' users.
2024-07-28 19:37:36 -05:00
Caleb Cartwright
c2c9be5b2d feat: implement Style Edition support
Adds the 'style_edition' configuration option along with
documentation, 'version' option deprecation, and mapping
of 'edition' and 'version' values for backwards compatibility
and adherence to the style evolution RFC
2024-07-28 19:37:36 -05:00