Commit Graph

5775 Commits

Author SHA1 Message Date
Michael Goulet
3ffacf75fe Make some matches exhaustive to avoid bugs, fix tools 2023-12-08 17:23:26 +00:00
Michael Goulet
6ebb66cea9 coro_kind -> coroutine_kind 2023-12-08 17:23:25 +00:00
bors
77bb46dedb Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errors
never_patterns: Parse match arms with no body

Never patterns are meant to signal unreachable cases, and thus don't take bodies:
```rust
let ptr: *const Option<!> = ...;
match *ptr {
    None => { foo(); }
    Some(!),
}
```
This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser).

~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit

r? `@compiler-errors`
2023-12-08 17:08:52 +00:00
Eric Holk
f114bb42ec Address code review feedback 2023-12-04 14:33:46 -08:00
Eric Holk
13d284d177 Option<CoroutineKind> 2023-12-04 13:03:37 -08:00
Eric Holk
97fdae1034 Merge Async and Gen into CoroutineKind 2023-12-04 12:48:01 -08:00
Nadrieril
a445ba8a9d Parse a pattern with no arm 2023-12-03 12:25:46 +01:00
Matthias Krüger
1ab7fc99af Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors
Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29 12:34:47 +01:00
Nadrieril
f2f243109b Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
Nicholas Nethercote
d84d8d2604 Rework ast::BinOpKind::to_string and ast::UnOp::to_string.
- Rename them both `as_str`, which is the typical name for a function
  that returns a `&str`. (`to_string` is appropriate for functions
  returning `String` or maybe `Cow<'a, str>`.)
- Change `UnOp::as_str` from an associated function (weird!) to a
  method.
- Avoid needless `self` dereferences.
2023-11-28 09:42:07 +11:00
Deadbeef
24ce52a199 Add Span to TraitBoundModifier 2023-11-24 14:32:05 +00:00
Nicholas Nethercote
c043d0169d Update itertools to 0.11.
Because the API for `with_position` improved in 0.11 and I want to use
it.
2023-11-22 08:13:21 +11:00
Dinu Blanovschi
494560cb57 fixes for rustfmt + ast visitor 2023-11-04 20:39:15 +01:00
Yacin Tmimi
37489e43b6 Update how LD_LIBRARY_PATH is set for rustfmt binaries in diff check
rustfmt currently has a runtime dependency on the sysroot. So when we
build a standalone rustfmt binary we need to set `LD_LIBRARY_PATH` so
each rustfmt binary knows where to find it's dependencies.

When running our Diff-Check job to test PRs for breaking changes it's
often the case that both the master rustfmt binary and the feature
branch binary have the same runtime dependencies so we only need to
set `LD_LIBRARY_PATH` once.

However, when running the diff-check job against a subtree sync PR that
assumption doesn't hold. The subtree sync PR bumps the required
toolchain used to build rustfmt and therefore the binary that gets built
for the subtree sync PR has a different runtime dependency than the
master rustfmt binary.

Now we set `LD_LIBRARY_PATH` twice to account for this potential
difference.
2023-11-01 20:21:47 -05:00
Yacin Tmimi
b446e8eee5 update diff-check logging
These changes mostly improve logging out the cargo version and version
of the two rustfmt binaries that are compiled. Some other minor logging
changes were made as well to add some whitespace to improve visual
clarity when looking at the logs in the GitHub Actions console.
2023-11-01 20:21:47 -05:00
GambitingMan
8d2c4157e6 Fixes comma added to comment in where-clause 2023-11-01 20:21:05 -05:00
Oli Scherer
a3be235fcc Add gen blocks to ast and do some broken ast lowering 2023-10-27 13:05:48 +00:00
GambitingMan
041f113159
Fixed error caused by combination of match_arm_blocks and control_brace_style
Fixes 5912

When `control_brace_style = "AlwaysNextLine"`, the code seems to always assume that `body_prefix` is `{`. This is however not the case when `match_arm_blocks = false`. This causes `block_sep` to introduce extra white space that causes the error.

The fix was to check if `body_prefix` is empty before matching on `ControlBraceStyle::AlwaysNextLine`.
2023-10-23 20:27:26 -04:00
bors
d5bf53b454 Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkov
report `unused_import` for empty reexports even it is pub

Fixes #116032

An easy fix. r? `@petrochenkov`

(Discovered this issue while reviewing #115993.)
2023-10-23 20:24:09 +00:00
Caleb Cartwright
04bd7201a9 Merge commit '81fe905ca83cffe84322f27ca43950b617861ff7' into rustfmt-sync 2023-10-22 20:21:44 -05:00
Yacin Tmimi
81fe905ca8 chore: prep v1.7.0 release
bumping from v1.6.0 -> v1.7.0 since we added support for let-chains
2023-10-22 20:18:45 -05:00
Yacin Tmimi
ff3ce6b53c Fix typos and remove merge conflict artifacts from the changelog 2023-10-22 20:18:45 -05:00
Yacin Tmimi
75c7d1daff Add outstanding changelog entries for the next release 2023-10-22 20:18:45 -05:00
Caleb Cartwright
0bb2acf50f
Merge pull request #5944 from calebcartwright/subtree-sync-2023-10-22
sync subtree
2023-10-22 14:07:55 -05:00
Caleb Cartwright
c2515dfa41 tests: fix let chain tests 2023-10-22 13:30:25 -05:00
Caleb Cartwright
75d84974f4 deps: bump bytecount version 2023-10-22 13:15:46 -05:00
Caleb Cartwright
746bf48ec4 chore: bump toolchain and apply minor updates 2023-10-22 12:59:03 -05:00
Caleb Cartwright
f35f25287f Merge remote-tracking branch 'upstream/master' into subtree-sync-2023-10-22 2023-10-22 12:45:06 -05:00
bohan
4335c28677 use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
Oli Scherer
7a20da333b Rename lots of files that had generator in their name 2023-10-20 21:14:02 +00:00
Oli Scherer
4b5ef37e21 Rename lots of files that had generator in their name 2023-10-20 21:14:02 +00:00
Oli Scherer
1b9dd4b4ad s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
0f739816c9 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Yacin Tmimi
547577fa5d implement sinlge line let-chain rules
for now, let-chains can only be formatted on a single line if the chain
consits of 2 expressions where the first is an identifier proceeded by
any number of unary operators and the second is a let-expr.
2023-10-10 20:13:50 -05:00
Cameron Steffen
457dc79a35 Add support for ExprKind::Let 2023-10-10 20:13:50 -05:00
Caleb Cartwright
2707103154 fix: adjust span derivation for const generics 2023-10-08 19:55:04 -04:00
Yacin Tmimi
268716b85e
Add CHANGELOG entries for the next release (#5932) 2023-10-08 17:53:01 -05:00
Michael Goulet
f867858755 Fix spans for comments in rustfmt 2023-10-04 21:09:54 +00:00
Michael Goulet
8ac561afef Fix spans for comments in rustfmt 2023-10-04 21:09:54 +00:00
cui fliter
d7669b4ffb Fix broken links
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-02 11:38:23 -04:00
GambitingMan
a1fabbf386
Bugfix/comment duplication (#5913)
* Fix #5871

* Only idempotence test is necessary

* Update src/expr.rs

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

---------

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2023-09-20 14:29:02 -05:00
Ed Page
da7f67810f
feat(cargo): Style --help like cargo nightly (#5908)
* chore: Update clap
* refactor(cargo): Update style of derive
* feat(cargo): Style help like cargo nightly
2023-09-11 22:12:58 -04:00
pan93412
18737ddc72
Prefer light_rewrite_comment if it is not a doccomment (#5536)
Fixes 5533, 5568, 5907

Prevent `format_code_in_doc_comments=true` from affecting how non-doc comments are formatted.


---------

Co-authored-by: Yacin Tmimi <yacintmimi@gmail.com>
2023-09-11 14:15:59 -04:00
Matthew Jasper
e0d90ccd45 Update tools and fulldeps tests 2023-09-11 15:51:19 +00:00
Matthew Jasper
b8e3cb0377 Update tools and fulldeps tests 2023-09-11 15:51:19 +00:00
Linda_pp
262feb3337
Fix checking if newline is needed before else in let-else statement
Fixes 5901

Take leading attributes and comments into consideration when determining if we need to wrap the `else` keyword onto the next line.
2023-09-08 21:05:07 -04:00
Camille GILLOT
45e19aa80c Use relative positions inside a SourceFile. 2023-09-03 12:56:10 +00:00
Camille GILLOT
96e583fd52 Use relative positions inside a SourceFile. 2023-09-03 12:56:10 +00:00
Robert Sammelson
b6367235eb Improve tests for #5852 2023-08-30 23:55:13 -04:00
David Bar-On
c7c57f8a16 Fix issue with extra semicolon when import comment preceeds semicolon 2023-08-30 23:55:13 -04:00