Commit Graph

5577 Commits

Author SHA1 Message Date
Nicholas Nethercote
e97825ed5e Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
David Wood
edb616df33 errors: move translation logic into module
Just moving code around so that triagebot can ping relevant parties when
translation logic is modified.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-15 12:26:35 +01:00
Yacin Tmimi
949da529d7 Add GitHub Action to test master rustfmt formatting vs a feature branch
This new action is intended to help us maintainers determine when feature
branches cause breaking formatting changes by running rustfmt (master)
and the feature branch on various rust repositories.

Over time I expect the list of checked projects to increase.

With this action in place we can more easily test that a new feature or
bug fix doesn't introduce breaking changes. Although this action needs to
be manually triggered right now, we might consider adding it to our CI
runs in the future.
2022-08-12 20:41:38 -05:00
Camille GILLOT
76be14b5ca Do not consider method call receiver as an argument in AST. 2022-08-10 18:34:54 +02:00
David Bar-On
ea017d7f84
Backport PR #4730 (#5390)
* Backport PR #4730 that fix issue #4689

* Test files for each Verion One and Two

* Simplify per review comment - use defer and matches!

* Changes per reviewer comments for reducing indentations
2022-08-09 09:30:49 -04:00
alex-semenyuk
a67d909627 Fix some clippy issues 2022-08-08 11:52:33 -04:00
Caleb Cartwright
e041c20eed
Merge pull request #5487 from calebcartwright/subtree-sync-2022-08-06
Sync subtree
2022-08-06 20:51:58 -05:00
Caleb Cartwright
c78ef92add chore: fix another config unreachable-pub 2022-08-06 20:29:46 -05:00
Caleb Cartwright
437de8d17f chore: disable unreachable pub lint on config items 2022-08-06 19:59:52 -05:00
Caleb Cartwright
5a1ef3c7bc chore: bump toolchain 2022-08-06 19:48:55 -05:00
Caleb Cartwright
a392dd10cd Merge remote-tracking branch 'upstream/master' into subtree-sync-2022-08-06 2022-08-06 19:07:02 -05:00
alexey semenyuk
662702eb54
Fix typos (#5486)
* Fix typos

* Fix typos
2022-08-06 18:53:03 -05:00
Caleb Cartwright
23ef4b7ac4 refactor(chains): encapsulate shared code, prep for overflows 2022-08-01 13:50:04 -05:00
Tom Milligan
3fa81c6dbf [review] use extend trait, enum for skip context 2022-07-31 11:31:39 -05:00
Tom Milligan
7cc126180f feat: nicer skip context for macro/attribute 2022-07-31 11:31:39 -05:00
Nicholas Nethercote
af72f7a17f Remove TreeAndSpacing.
A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.
2022-07-29 15:52:15 +10:00
Yacin Tmimi
a7801aac27 Add test for issue 3987
Closes 3987

It's unclear which commit resolved this issue, but it can no longer be
reproduced.
2022-07-28 19:13:10 -05:00
aizpurua23a
7432422008 Update Configurations.md to point to dirs 4.0 docs 2022-07-27 13:33:50 -04:00
Martin Juarez
ed77962d24 Improvements: Adding tests for the issue-4643. 2022-07-26 13:06:10 -04:00
Yacin Tmimi
a451a39dec Add test for issue 4350
Closes 4350

Its unclear which commit resolved this, but the original issue is no
longer reproducible.
2022-07-25 20:11:32 -05:00
Yacin Tmimi
c19b14539b test for issue 3164
Closes 3164

Show that when `error_on_line_overflow=true` is set in the rustfmt.toml
that an error message is written to stderr.
2022-07-22 17:57:07 -05:00
Yacin Tmimi
4c78c738ba Add tests for 3245 and 3561
Closes 3245
Closes 3561

These issues were originally linked in issue 3672 and as was mentioned
in PR 3706, it's unclear which commit resolved the issue but the issue
can no longer be reproduced.
2022-07-20 21:37:12 -05:00
Yacin Tmimi
f2c31ba04d Add tests for issue 2534
Closes 2534

The behavior described in the original issue can no longer be
reproduced. The tests show that to be the case regardless of if
`format_macro_matchers` is `true` or `false`.
2022-07-19 17:07:01 -05:00
Yacin Tmimi
05332b8c50 Add test for issue 3033
Closes 3033

The issue is no longer reproducible.
2022-07-19 17:00:37 -05:00
Jorge Martin Juarez
a7bf009034
Fix/comments inside trait generics gets duplicated (#5446)
* Bugfix: Now slash/start comments aren't duplicated on trait parameters.

* Removing unnecesary comment.

* Improvements: Improving the BytePos offset.

* Improvements: Improving the description of the test cases.
2022-07-17 21:39:25 -04:00
Urgau
85fdf8ecec Remove useless conditional compilation - 2 2022-07-17 19:09:23 -05:00
waynewaynetsai
dde28314da docs: fix duplicated names example 2022-07-17 13:27:44 -04:00
Yacin Tmimi
0cb294f05c Deprecate and Rename fn_args_layout -> fn_params_layout
fn_args_layout is now deprecated.

This option was renamed to better communicate that it affects the layout
of parameters in function signatures and not the layout of arguments in
function calls.

Because the `fn_args_layout` is a stable option the renamed option is
also stable, however users who set `fn_args_layout` will get a warning
message letting them know that the option has been renamed.
2022-07-12 19:33:53 -05:00
Tom Milligan
c240f3a6b3
feat: add skip_macro_invocations option (#5347)
* feat: add skip_macro_names option

* [review] update configuration documentation

* [review] fix docstring

* [feat] implement wildcard macro invocation skip

* commit missed files

* [review] test override skip macro names

* [review] skip_macro_names -> skip_macro_invocations

* [review] expand doc configuration

* [review] add lots more tests

* [review] add use alias test examples

* [review] add link to standard macro behaviour
2022-07-12 19:31:19 -05:00
Maybe Waffle
f026688c2a Add rustfmt test for formatting for<> before closures 2022-07-12 21:00:13 +04:00
Maybe Waffle
2964d0a533 implement rustfmt formatting for for<> closure binders 2022-07-12 21:00:13 +04:00
Yacin Tmimi
2403f827bf Add test case for issue 1306 which was resolved
Closes 1306

It's unclear when the issue was fixed, but it cannot be reproduced.
2022-07-09 19:59:09 -05:00
Caleb Cartwright
35f4c55bf4 refactor: remove some unnecessary clones 2022-07-05 08:51:36 -04:00
Nixon Enraght-Moony
45f4f6ccf7 ast: Add span to Extern 2022-07-02 23:30:03 +01:00
Tom Milligan
2ae63f0018 config_type: add unstable_variant attribute 2022-06-30 22:25:39 -05:00
Yacin Tmimi
b3d4fb448c Allow #[ignore] tests to run in rustfmt's test suite
There are some tests in the rustfmt test suite that are ignored by
default. I believe these tests are ignored because they have caused
issues with the the `rust-lang/rust` test suite.

However, we recently experienced an issue (5395) that would have been
avoided had these tests been running.

With the introduction of the new `#[rustfmt_only_ci_test]` attribute
macro we can run these tests when the `RUSTFMT_CI` environment variable
is set, which will presumably only be set during rustfmts CI runs.
When the environment variable is not set the `#[rustfmt_only_ci_test]`
will be replaced with an `#[ignore]`.
2022-06-29 18:55:02 -05:00
Caleb Cartwright
ac595dd57a Merge commit 'c4416f20dcaec5d93077f72470e83e150fb923b1' into sync-rustfmt 2022-06-22 22:14:32 -05:00
Caleb Cartwright
c4416f20dc chore: prep v1.5.1 release 2022-06-22 21:55:51 -05:00
Caleb Cartwright
224f1c938f
Merge pull request #5405 from calebcartwright/subtree-sync-2022-06-22
Subtree sync 2022 06 22
2022-06-22 20:57:46 -05:00
Caleb Cartwright
dc2d86dec3 chore: bump toolchain 2022-06-22 19:36:53 -05:00
Caleb Cartwright
778e1b1a76 Revert "Memoize format_expr"
This reverts commit a37d3ab0e1.
2022-06-22 19:29:38 -05:00
Caleb Cartwright
f43c96688d Merge remote-tracking branch 'upstream/master' into subtree-sync-2022-06-22 2022-06-22 19:28:27 -05:00
Yacin Tmimi
08105e80b7 Fix issue where cargo fmt --version would not display version info
Fixes 5395

In PR 5239 we switched from using `structopt` to `clap`. It seems that
the default behavior for `clap` is to override the `--version` flag,
which prevented our custom version display code from running.

The fix as outlined in https://github.com/clap-rs/clap/issues/3405 was
to set `#[clap(global_setting(AppSettings::NoAutoVersion))]` to prevent
clap from setting its own default behavior for the `--version` flag.
2022-06-22 17:47:00 -05:00
Yacin Tmimi
a187091568 Add idempotency test for issue 5399 2022-06-22 17:45:42 -05:00
Yacin Tmimi
0156575a32 Revert "Memoize format_expr"
Fixes 5399

Memoizing expressions lead to cases where rustfmt's stability guarantees
were violated.

This reverts commit a37d3ab0e1.
2022-06-22 17:45:42 -05:00
Tom Milligan
2c8b3bef2b
ci: include config_proc_macro crate in ci (#5389)
* config_proc_macro: fix failing doctests

* ci: include config_proc_macro crate in ci

* [review] working native windows ci

* [fix] add --locked file for ci

* [fix] quoting of cmd variables
2022-06-21 10:23:13 -05:00
Yacin Tmimi
3de1a095e0 Set package.metadata.rust-analyzer.rustc_private=true in Cargo.toml
By setting this value in the Cargo.toml rust-analyzer understands that
rustfmt uses compiler-internals using `extern crate`.

This is a universal step that all developers will need to take in order to
get better type hints and code completion suggestions for
compiler-internals in their editor.

**Note**: users will also need to install the `rustc-dev` component via
`rustup` and add the following to their rust-analyzer configuration:

```json
{
    "rust-analyzer.rustcSource": "discover",
    "rust-analyzer.updates.channel": "nightly"
}
```
2022-06-17 19:34:24 -05:00
sec65
33c60740d3
Add width for codeblocks in comments (#5372)
* add doc_comment_code_block_width configuration

* updated config docu

* Updated docu and changed tests to config folder
2022-06-16 22:15:16 -05:00
Matthias Krüger
ac2b7a261c Rollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, r=wesleywiser,flip1995
Support lint expectations for `--force-warn` lints (RFC 2383)

Rustc has a `--force-warn` flag, which overrides lint level attributes and forces the diagnostics to always be warn. This means, that for lint expectations, the diagnostic can't be suppressed as usual. This also means that the expectation would not be fulfilled, even if a lint had been triggered in the expected scope.

This PR now also tracks the expectation ID in the `ForceWarn` level. I've also made some minor adjustments, to possibly catch more bugs and make the whole implementation more robust.

This will probably conflict with https://github.com/rust-lang/rust/pull/97718. That PR should ideally be reviewed and merged first. The conflict itself will be trivial to fix.

---

r? `@wesleywiser`

cc: `@flip1995` since you've helped with the initial review and also discussed this topic with me. 🙃

Follow-up of: https://github.com/rust-lang/rust/pull/87835

Issue: https://github.com/rust-lang/rust/issues/85549

Yeah, and that's it.
2022-06-16 09:10:20 +02:00
xFrednet
76cbc1dae3 Support lint expectations for --force-warn lints (RFC 2383) 2022-06-16 08:16:43 +02:00