Commit graph

3669 commits

Author SHA1 Message Date
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
ding-young
6f5e99b7b5 update macro rewrite functions to return RewriteResult 2024-08-25 09:23:04 -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
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
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
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
Caleb Cartwright
d8ae6a99e6 tests: add a few for style edition config defaults 2024-07-27 17:35:10 -05:00
Caleb Cartwright
a23d3ccb84 refactor: track configs set from cli flags 2024-07-27 17:01:11 -05:00
ding-young
e21c1e220b refactor rewrite_array, pair, tuple, call 2024-07-26 03:53:21 -06:00
ding-young
1313d61842 modfiy ListItem to hold RewriteResult as the item field 2024-07-26 03:00:49 -06:00
ding-young
6ccf539b19 modify trait bound of itemize_list 2024-07-26 03:00:49 -06:00
ding-young
ea02de27ff refactor rewrite_match and impl rewrite_result for ArmWrapper 2024-07-17 20:51:42 -06:00
ding-young
babc2f9b8a modify rewrite_struct_lit, rewrite_struct_pat
- refactor rewrite_*** functions that call rewrite_path to return RewriteResult
- modify rewrite_aligned_item method of AlignedItem
2024-07-17 18:40:45 -06:00
ding-young
3cbc91e9d6 modify rewrite_path and impl rewrite_result for related AST nodes 2024-07-17 18:40:45 -06:00
Yacin Tmimi
7cdb426c05 Implement StyleEditionDefault for each config option
Makes internal changes to define each configuration in terms of the
`StyleEditionDefault` trait, and hard codes `StyleEdition::Edition2015`
anywhere the new `style_edition` is needed.

**Note** users are still unable to configure `style edition`.
2024-07-15 15:41:31 -06:00
ding-young
071ca7dc45 refactor rewrite_closure 2024-07-15 14:34:56 -06:00
ding-young
bb56224d2a refactor rewrite_block 2024-07-15 14:34:56 -06:00
ding-young
eed7e237bc rewrite_result for GenericBounds, GenericParam, SegmentParam 2024-07-06 09:17:32 -06:00
ding-young
f62d730e54 impl rewrite_result for AssocItemConstraintKind, GenericArg, GenericBound, Ty 2024-07-06 09:17:32 -06:00
ding-young
21afdb81f8 add Ext trait for converting Option->RewriteResult 2024-07-03 19:10:20 -06:00
ding-young
905ca5483b add rewrite_result method to Rewrite trait
impl rewrite_result for ast::Local, ast::FieldDef, ast::Param, ast::FnRetTy
2024-07-03 19:10:20 -06:00
hattizai
533b760f8d remove duplicate word 2024-07-02 07:52:22 -06:00
Michael Goulet
88f98c2929 Implement RTN support in rustfmt 2024-06-28 14:20:44 -04:00
Michael Goulet
51df533d06 Tighten spans for async blocks 2024-06-27 15:19:08 -04:00
Michael Goulet
c5284965bd Remove stray println from rustfmt 2024-06-25 18:05:52 -04:00
Michael Goulet
b5fa338f23 Merge remote-tracking branch 'origin/master' into sync-from-rust-2024-06-24 2024-06-24 23:02:45 -04:00
Matthias Krüger
514fe39e25 Rollup merge of #126888 - compiler-errors:oops-debug-printing, r=dtolnay
Remove stray println from rustfmt's `rewrite_static`

r? `@calebcartwright` `@ytmimi` -- though anyone should probably r+ this so it gets into nightly sooner than later, since it's obviously wrong.

This can just be fixed in-tree, since I don't think we want to wait until the next sync to fix this.

Fix https://github.com/rust-lang/rustfmt/issues/6210
Fix https://github.com/rust-lang/rust/issues/126887
2024-06-24 06:27:17 +02:00
Matthias Krüger
bd0a886b7e Rollup merge of #126754 - compiler-errors:use-rustfmt, r=calebcartwright
Implement `use<>` formatting in rustfmt

This PR implements formatting for precise-capturing `use<>` syntax as proposed in https://github.com/rust-lang/rust/pull/126753.

The syntax is implemented as-if the `use<>` bound were a trait bound but with the `use` keyword as its path segment identifier.

I opted to develop this in the rust-lang/rust tree since I'm not certain when the next rustfmt subtree sync is going to be, and I'd rather not block landing nightly support for `use<>` on something I have no control over. If ``@rust-lang/rustfmt`` would rather I move this PR over to that repository, then I would at least like to know when the next rustfmt->rust subtree sync is going to be, since stabilizing `precise_capturing` without formatting will be disruptive.

This implementation is otherwise rather straightforward.

Tracking:

- https://github.com/rust-lang/rust/issues/123432
2024-06-24 06:27:14 +02:00
Michael Goulet
22aac496cc Remove stray println from rustfmt 2024-06-23 22:27:41 -04:00
Matthias Krüger
8f8a463cbd Rollup merge of #126851 - nnethercote:NtExprKind-NtPatKind, r=compiler-errors
Rework pattern and expression nonterminal kinds.

Some tweaks to `NonterminalKind` that will assist with #124141. Details in the individual commits.

r? compiler-errors
cc ```@eholk```
2024-06-23 22:39:01 +02:00
Michael Goulet
10277c97c2 Implement use<> formatting in rustfmt 2024-06-23 10:57:10 -04:00