Commit Graph

5242 Commits

Author SHA1 Message Date
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
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
Yacin Tmimi
e44380b341 Version gate raw identifier use statement sorting
When useing `version=One` rustfmt will treat the leading `r#` as part of
the `UseSegment` used for sorting. When using `version=Two` rustfmt will
ignore the leading `r#` and only consider the name of the identifier
when sorting the `UseSegment`.
2022-06-15 20:06:04 -05:00
Yacin Tmimi
795efb2068 Add Version information to UseSegment
There are some proposed import sorting changes for raw identifier `r#`.
These changes constitute a breaking change, and need to be version
gagted. Before version gating those changes we add the version
information to the `UseSegment`.
2022-06-15 20:06:04 -05:00
Yacin Tmimi
5ae94cc6b8 Backport 3795
fix sorting of use statements with raw identifiers
2022-06-15 20:06:04 -05:00
Yacin Tmimi
1a6146e536 Pass --locked when installing rustfmt in integration tests
There was recently an issue where `cargo install` was installing a newer
version of a dependency than the one listed in our Cargo.toml. The newer
version added deprecation warnings that caused our continuous integration
tests to break.

As mentioned in the `cargo help install` docs, passing the `--locked`
flag should force cargo to use the `Cargo.lock` file included with
the repository.
2022-06-14 15:23:33 -05:00
Caleb Cartwright
d03a547cad Merge commit '7b73b60faca71d01d900e49831fcb84553e93019' into sync-rustfmt 2022-06-12 22:03:05 -05:00
Caleb Cartwright
7b73b60fac chore: prep v1.5.0 release 2022-06-12 21:41:15 -05:00
David Bar-On
7d34cfaf2c Dedup imports_granularity = "Item" (#4737)
* Fix for issue 4725 - dedup Item imports_granularity (2nd version)

* Use unique() instead of unique_by()
2022-06-11 19:57:47 -05:00
Urgau
5fa2727dde Remove useless conditional compilation 2022-06-09 22:24:27 -05:00
Caleb Cartwright
75786fb0b7
Merge pull request #5374 from calebcartwright/subtree-sync-2022-06-07
Subtree sync
2022-06-08 19:58:15 -05:00
Caleb Cartwright
aedb396063 chore: bump toolchain 2022-06-07 22:14:08 -05:00
Caleb Cartwright
1ac2ac0db6 Merge remote-tracking branch 'upstream/master' into subtree-sync-2022-06-07 2022-06-07 22:06:28 -05:00
Caleb Cartwright
64f1f57a48 fix: handle inner ignore attribute on stdin 2022-06-04 15:12:29 -05:00
Caleb Cartwright
79515f17ed feat: remove license_template_path config option 2022-05-30 08:56:09 -05:00
Caleb Cartwright
5e4296767f refactor: remove code for bad issue (e.g. todo/fixme) reporting 2022-05-30 08:56:09 -05:00
Caleb Cartwright
825561deb8 feat: remove report_fixme option 2022-05-30 08:56:09 -05:00
Caleb Cartwright
4c8db85939 feat: remove report_todo option 2022-05-30 08:56:09 -05:00
Caleb Cartwright
3e38399ed8 docs: clarify imports_granularity behavior with comments 2022-05-26 22:27:20 -05:00
Yacin Tmimi
73be264f9f Rephrase changelog entries to give more context 2022-05-26 21:51:07 -05:00
Yacin Tmimi
a5cfd4d145 Updated Unreleased CHANGELOG entries
from revision  v1.4.38..2d9bc460
2022-05-26 21:51:07 -05:00
Alexander Pozdneev
37b48ca4b2 Update Configurations.md
Co-authored-by: Yacin Tmimi <yacintmimi@gmail.com>
2022-05-23 09:52:20 -04:00
Alexander Pozdneev
0b6659cf02 Update Configurations.md 2022-05-23 09:52:20 -04:00
Jacob Pratt
9b697d0b90 Merge crate and restricted visibilities 2022-05-21 17:02:55 -04:00
Jacob Pratt
0d27f70743 Remove feature: crate visibility modifier 2022-05-21 14:22:06 -04:00
Jacob Pratt
241a6f6930 Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
ydah
86940d2652 Fix typo
This PR is fixes typo "avaiable" to "available".
2022-05-20 10:39:10 +09:00
David Lattimore
95837832f4 import_granularity: Don't normalize imports with comments 2022-05-18 21:08:30 -05:00
klensy
b507c60e1c fix rustfmt 2022-05-18 20:43:16 +03:00
Yacin Tmimi
b08b2daeb6 Add test for issue 3937
Closes 3937

It's unclear which change fixed the `format_code_in_doc_comments=true`
issue brought up in this issue, however I'm unable to reproduce the
error on the current master.

The added test cases should serve to prevent a regression.
2022-05-17 17:17:07 -05:00
Koichi ITO
8a4c05865b Use the traits added to the Rust 2021 Edition prelude
Follow up https://github.com/rust-lang/rust/pull/96861.

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html
2022-05-14 10:41:46 -05:00
Vadim Petrochenkov
f77fd90aff ast: Introduce some traits to get AST node properties generically
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
2022-05-11 12:43:27 +03:00
Yuki Okushi
8fcf113743 Rollup merge of #96543 - nnethercote:rm-make_token_stream-hacks, r=Aaron1011
Remove hacks in `make_token_stream`.

`make_tokenstream` has three commented hacks, and a comment at the top
referring to #67062. These hacks have no observable effect, at least as judged
by running the test suite. The hacks were added in #82608, with an explanation
[here](https://github.com/rust-lang/rust/pull/82608#issuecomment-812877329). It
appears that one of the following is true: (a) they never did anything useful,
(b) they do something useful but we have no test coverage for them, or (c)
something has changed in the meantime that means they are no longer necessary.

This commit removes the hacks and the comments, in the hope that (b) is not
true.

r? `@Aaron1011`
2022-05-11 13:16:30 +09:00
Nicholas Nethercote
77f096453c Remove some unnecessary invisible delimiter checks.
These seem to have no useful effect... they don't seem useful from a
code inspection point of view, and they affect anything in the test
suite.
2022-05-11 10:14:49 +10:00
Josh Triplett
17003ce66b In the docs for hex_literal_case, show the default as a possible value 2022-05-09 19:45:02 -05:00
PSeitz
84fd4cdd02 Update CHANGELOG.md 2022-05-09 11:25:17 -04:00
Pascal Seitz
c65ba14d69 Fixes #5260
Fixes #5260 by checking if it is part of a type '::'
2022-05-08 13:22:35 -05:00