Commit Graph

5558 Commits

Author SHA1 Message Date
Caleb Cartwright
23f48d9bb3 deps: bump proc-macro2 and toolchain 2023-07-01 02:05:29 -05:00
Maybe Waffle
aa691480c0 Implement become expression formatting in rustfmt 2023-07-01 02:05:29 -05:00
Yacin Tmimi
1de65a2711 wrap else to next line if let-else pattern is multi-lined
This rule wasn't explicity stated in the style guide so it was missed,
but luckily we caught it during testing.
2023-07-01 01:06:35 -05:00
Yacin Tmimi
7b4e8a6d31 update else_block_exceeds_width calculation in let-else rewrite
By reversing the logic I felt that the code became a clearer. Also,
added a comment to make it clear that we need to take the trailing
semicolon for the `let-else` statement into account.
2023-07-01 01:06:35 -05:00
Yacin Tmimi
fe8b72d98e implement single_line_let_else_max_width
This allows users to configure the maximum length of a single line
`let-else` statements. `let-else` statements that otherwise meet the
requirements to be formatted on a single line will have their divergent
`else` block formatted over multiple lines if they exceed this length.

**Note**: `single_line_let_else_max_widt` will be introduced as a stable
configuration option.
2023-07-01 01:06:35 -05:00
Nilstrieb
80bf3ea542 Rollup merge of #112790 - WaffleLapkin:syntactically, r=Nilstrieb
Syntactically accept `become` expressions (explicit tail calls experiment)

This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature.

cc `@scottmcm`
2023-06-21 07:37:02 +02:00
Yacin Tmimi
9386b32f5a wrap else { for long, single-lined initializer expressions
This helps to prevent max width errors.
2023-06-20 08:26:11 -05:00
Yacin Tmimi
e4a9892b7a Add additional test cases
These test cases try to cover various edge cases. For example, comments
around the else keyword and long, unbreakable, single-line initializer
expressions, and long patterns.
2023-06-20 08:26:11 -05:00
Yacin Tmimi
521f86bae5 Prevent single-line let-else if it would exceed max_width 2023-06-20 08:26:11 -05:00
Yacin Tmimi
00fef2d51d Implement wrapping rules to force else on a newline in let-else 2023-06-20 08:26:11 -05:00
Yacin Tmimi
7a3e4fca40 Implement let-else rewriting in terms of rewrite_let_else_block
`rewrite_let_else_block` gives us more control over allowing the `else`
block to be formatted on a single line than
`<ast::Block as Rewrite>::rewrite`.
2023-06-20 08:26:11 -05:00
Yacin Tmimi
8be748dbb7 Allow callers to determine if blocks can be formatted on a single line
This will make it easier to format the divergent blocks of `let-else`
statements since it'll be easier to prevent the block from being
formatted on a single line if the preconditions aren't met.
2023-06-20 08:26:11 -05:00
Yacin Tmimi
9316df0ca2 Initial pass at implementing let-else 2023-06-20 08:26:11 -05:00
Yacin Tmimi
75870c55b9 Extract logic for rewriting else keyword into function
The function properly handles recovering comments before and after the
`else` keyword, and properly handles how to write the else when users
configure `control_brace_style`.
2023-06-20 08:26:11 -05:00
Caleb Cartwright
ed3e96e3d1 Merge commit '3f7c366fc0464e01ddcaefbd70647cb3da4202be' into rustfmt-sync 2023-06-19 23:13:56 -05:00
Caleb Cartwright
3f7c366fc0 chore: release v1.5.3 2023-06-19 22:54:36 -05:00
Caleb Cartwright
ec8a4d41f1
Merge pull request #5788 from calebcartwright/subtree-sync-2023-06-19
sync subtree in prep for next release
2023-06-19 21:57:03 -05:00
Caleb Cartwright
0b17d7ea46 chore: address merge and bump toolchain 2023-06-19 21:29:15 -05:00
Caleb Cartwright
312a86b46b Merge remote-tracking branch 'upstream/master' into subtree-sync-2023-06-19 2023-06-19 20:56:20 -05:00
Lukasz Anforowicz
f4201ef2cb Handling of numbered markdown lists.
Fixes issue #5416
2023-06-19 20:50:01 -05:00
KaDiWa
66b9951dcd update some dependencies 2023-06-19 11:20:51 -05:00
Yacin Tmimi
2c30fa5a82 Adjust enum variant spans to exclude any explicit discriminant
Fixes 5686

For reference, explicit discriminants were proposed in [RFC-2363].

`ast::Variant` spans extend to include explicit discriminants when they
are present.

Now we'll adjust the span of enum variants to exclude any explicit
discriminant.

[RFC-2363]: https://rust-lang.github.io/rfcs/2363-arbitrary-enum-discriminant.html
2023-06-19 10:12:19 -05:00
Yacin Tmimi
ac2ebd3a78 Prevent ICE when calling parse_attribute without an attribute
Fixes 5729

`parse_attribute` will panic if the first token is not a `#`. To prevent
this we return early instead of trying to parse an invalid attribute.
2023-06-19 09:58:12 -05:00
Deadbeef
a463f231f5 remove derive_new dependency 2023-06-19 09:46:37 -05:00
Deadbeef
7d48be355a bump deps to new versions that use syn 2.0 2023-06-19 09:46:37 -05:00
Deadbeef
8d95c269ed update config_proc_macro to use syn 2.0 2023-06-19 09:46:37 -05:00
xxchan
c9ebd6ce26 doc: remove installing from source
also add "run from source" in contributing.md
2023-06-19 09:42:40 -05:00
Yacin Tmimi
0441cc21e3 Add release notes for closed PRs with release-notes label 2023-06-19 09:40:46 -05:00
Maybe Waffle
dc7dc3e74c Implement become expression formatting in rustfmt 2023-06-19 12:54:34 +00:00
Deadbeef
5f9de6bfc9 Recover comments between attrs and generic param
Fixes #5320.
2023-06-11 19:34:36 -05:00
Eric Huss
e903fcdaae Remove rustc-workspace-hack 2023-06-11 19:34:01 -05:00
Matthias Krüger
48e380fa40 Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkin
Make the BUG_REPORT_URL configurable by tools

This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy
the entire hook implementation.

I haven't changed clippy in case they want to make the change upstream instead of the subtree, but
I'm happy to do so here if the maintainers want - cc ````@rust-lang/clippy````

Fixes https://github.com/rust-lang/rust/issues/109486.
2023-05-06 13:30:04 +02:00
Michael Goulet
8ed5d5de3d Rustfmt support for negative bounds, test 2023-05-02 22:36:25 +00:00
Michael Goulet
8e330f9d5b Make tools happy 2023-05-02 22:36:24 +00:00
bors
ae213e228d Auto merge of #109128 - chenyukang:yukang/remove-type-ascription, r=estebank
Remove type ascription from parser and diagnostics

Mostly based on https://github.com/rust-lang/rust/pull/106826

Part of #101728

r? `@estebank`
2023-05-02 09:41:35 +00:00
jyn
34a71f67d1 Make the BUG_REPORT_URL configurable by tools
This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy
the entire hook implementation.

- Switch clippy to the new hook

  This also adds a `extra_info` callback so clippy can include its own version number, which differs
  from rustc's.

- Call `install_ice_hook` in rustfmt
2023-05-01 21:44:04 -05:00
bors
4351e50a9e Auto merge of #111036 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-05-01 11:13:49 +00:00
yukang
9d20134a78 remove rustfmt testcase for type ascription 2023-05-01 16:15:17 +08:00
yukang
a74d2d7440 fix tests 2023-05-01 16:15:17 +08:00
Ralf Jung
4eb1b520d5 Merge from rustc 2023-04-30 22:35:29 +02:00
Lukas Markeffsky
a44c7ea592 fix broken markdown 2023-04-27 13:44:17 -05:00
Michael Goulet
6b9c151686 Tweak await span 2023-04-27 17:18:11 +00:00
Ralf Jung
afe34c8443 Merge from rustc 2023-04-22 10:35:35 +02:00
DrMeepster
f4c9b4c26f rustfmt fmt 2023-04-21 08:59:30 -07:00
DrMeepster
ecfdec44df minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster
84385bff42 offset_of 2023-04-21 02:14:02 -07:00
Ben Kimock
f533800225 Merge from rustc 2023-04-10 07:55:57 -04:00
Oli Scherer
f1781396bf box a bunch of large types 2023-04-04 13:58:50 +00:00
Oli Scherer
3ecb9ed53c Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer
ced3cd8d40 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00