]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoSearch for struct body span after any generic arguments
Yacin Tmimi [Sun, 20 Mar 2022 17:21:44 +0000 (13:21 -0400)]
Search for struct body span after any generic arguments

Fixes 5273

Previously, rustfmt searched for the start of a struct body after the
opening `{`. In most cases this works just fine, but const values can
also be defined between `{ }`, which lead to issues when rewriting the
struct body.

Now, rustfmt will search for the `{` after the generic argument list to
guarantee that the `{` it finds is the start of the struct body.

2 years agoMerge pull request #5268 from calebcartwright/subtree-sync-2022-03-16
Caleb Cartwright [Fri, 18 Mar 2022 00:08:54 +0000 (19:08 -0500)]
Merge pull request #5268 from calebcartwright/subtree-sync-2022-03-16

subtree sync

2 years agochore: bump toolchain
Caleb Cartwright [Thu, 17 Mar 2022 03:26:15 +0000 (22:26 -0500)]
chore: bump toolchain

2 years agoMerge remote-tracking branch 'upstream/master' into subtree-sync-2022-03-16
Caleb Cartwright [Thu, 17 Mar 2022 02:55:15 +0000 (21:55 -0500)]
Merge remote-tracking branch 'upstream/master' into subtree-sync-2022-03-16

2 years agochore: add utility function for relative span positions
Caleb Cartwright [Thu, 10 Mar 2022 02:53:51 +0000 (20:53 -0600)]
chore: add utility function for relative span positions

2 years agoAdd test to verify tracking issue links
Yacin Tmimi [Sat, 12 Mar 2022 06:16:08 +0000 (01:16 -0500)]
Add test to verify tracking issue links

Now, tracking issue links are checked against the reference number
listed in the link text to ensure they match.

2 years agoCorrect tracking issue link for `skip_children`
Yacin Tmimi [Sat, 12 Mar 2022 06:14:38 +0000 (01:14 -0500)]
Correct tracking issue link for `skip_children`

Update the issue link to point to issue 3389

2 years agoAuto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber
bors [Tue, 15 Mar 2022 03:56:33 +0000 (03:56 +0000)]
Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber

More robust fallback for `use` suggestion

Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion.

But this was fragile, as illustrated in issue #87613

This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion.

Fix #87613

2 years agofix: imports_granularity module with path containing self
Tom Milligan [Fri, 4 Mar 2022 18:13:08 +0000 (18:13 +0000)]
fix: imports_granularity module with path containing self

2 years agoImprove mod resolution error for mods with multiple candidate files
Yacin Tmimi [Tue, 11 Jan 2022 01:45:27 +0000 (20:45 -0500)]
Improve mod resolution error for mods with multiple candidate files

Fixes 5167

When ``a.rs`` and ``a/mod.rs`` are both present we would emit an error
message telling the user that the module couldn't be found. However,
this behavior is misleading because we're dealing with an ambiguous
module path, not a "file not found" error.

Is the file ``a.rs`` or is it ``a/mod.rs``? Rustfmt can't decide, and
the user needs to resolve this ambiguity themselves.

Now, the error message displayed to the user is in line with what they
would see if they went to compile their code with these conflicting
module names.

2 years agoplacate rustfmt in rustfmt.
Felix S. Klock II [Mon, 7 Mar 2022 21:37:35 +0000 (16:37 -0500)]
placate rustfmt in rustfmt.

2 years agoAdd test for issue #4791
cassaundra [Sat, 5 Mar 2022 22:17:15 +0000 (14:17 -0800)]
Add test for issue #4791

2 years agoAdd more tests for struct_field_align_threshold and trailing_comma
cassaundra [Sat, 15 Jan 2022 01:25:46 +0000 (17:25 -0800)]
Add more tests for struct_field_align_threshold and trailing_comma

2 years agoFix missing struct field separators under certain conditions
cassaundra [Wed, 29 Dec 2021 23:41:26 +0000 (15:41 -0800)]
Fix missing struct field separators under certain conditions

When struct_field_align_threshold is non-zero and trailing_comma is set to
"Never," struct field separators are omitted between field groups. This issue is
resolved by forcing separators between groups.

Fixes #4791.

A test is included with a minimal reproducible example.

2 years agoRollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum
Matthias Krüger [Sun, 6 Mar 2022 14:41:26 +0000 (15:41 +0100)]
Rollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum

Update `itertools`

Update to 0.10.1

2 years agoChange syntax for TyAlias where clauses
Jack Huey [Tue, 19 Oct 2021 22:45:48 +0000 (18:45 -0400)]
Change syntax for TyAlias where clauses

2 years agoPlacate tidy in submodule.
Felix S. Klock II [Fri, 4 Mar 2022 22:05:30 +0000 (17:05 -0500)]
Placate tidy in submodule.

2 years agoUpdate `itertools`
pierwill [Fri, 4 Mar 2022 17:54:28 +0000 (11:54 -0600)]
Update `itertools`

Update to 0.10.1

2 years agoAdjusted diagnostic output so that if there is no `use` in a item sequence,
Felix S. Klock II [Thu, 20 Jan 2022 19:07:54 +0000 (14:07 -0500)]
Adjusted diagnostic output so that if there is no `use` in a item sequence,
then we just suggest the first legal position where you could inject a use.

To do this, I added `inject_use_span` field to `ModSpans`, and populate it in
parser (it is the span of the first token found after inner attributes, if any).
Then I rewrote the use-suggestion code to utilize it, and threw out some stuff
that is now unnecessary with this in place. (I think the result is easier to
understand.)

Then I added a test of issue 87613.

2 years agoAssociate multiple with a crate too.
Felix S. Klock II [Thu, 3 Mar 2022 23:45:25 +0000 (18:45 -0500)]
Associate multiple with a crate too.

2 years agorefactor: prepare to associate multiple spans with a module.
Felix S. Klock II [Thu, 20 Jan 2022 16:06:45 +0000 (11:06 -0500)]
refactor: prepare to associate multiple spans with a module.

2 years agoPrevent wrapping markdown headers in doc comments
Yacin Tmimi [Fri, 25 Feb 2022 16:31:09 +0000 (11:31 -0500)]
Prevent wrapping markdown headers in doc comments

Fixes 5238

A markdown header is defined by a string that starts with `#`.

Previously, rustfmt would wrap long markdown headers when
`wrap_comments=true`. This lead to issues when rendering these headers
in HTML using rustdoc.

Now, rustfmt leaves markdown headers alone when wrapping comments.

2 years agofallback to dir_path when relative external mod resolution fails
Yacin Tmimi [Sun, 30 Jan 2022 18:46:53 +0000 (13:46 -0500)]
fallback to dir_path when relative external mod resolution fails

We only want to fall back if two conditions are met:

1) Initial module resolution is performed relative to some nested
   directory.
2) Module resolution fails because of a ModError::FileNotFound error.

When these conditions are met we can try to fallback to searching for
the module's file relative to the dir_path instead of the nested
relative directory.

Fixes 5198

As demonstrated by 5198, it's possible that a directory name conflicts
with a rust file name. For example, src/lib/ and src/lib.rs.

If src/lib.rs references an external module like ``mod foo;``, then
module resolution will try to resolve ``foo`` to src/lib/foo.rs or
src/lib/foo/mod.rs. Module resolution would fail with a file not
found error if the ``foo`` module were defined at src/foo.rs.

When encountering these kinds of module resolution issues we now fall
back to the current directory and attempt to resolve the module again.

Given the current example, this means that if we can't find the module
``foo`` at src/lib/foo.rs or src/lib/foo/mod.rs, we'll attempt
to resolve the module to src/foo.rs.

2 years agoEnable rustc_pass_by_value for Span
Mark Rousskov [Wed, 23 Feb 2022 13:11:17 +0000 (08:11 -0500)]
Enable rustc_pass_by_value for Span

2 years agofix: unused test imports on non-nightly, prevent regression
Caleb Cartwright [Thu, 24 Feb 2022 03:37:42 +0000 (21:37 -0600)]
fix: unused test imports on non-nightly, prevent regression

2 years agorustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.
Eduard-Mihai Burtescu [Wed, 26 Jan 2022 03:39:14 +0000 (03:39 +0000)]
rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.

2 years agorustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.
Eduard-Mihai Burtescu [Sun, 23 Jan 2022 23:11:37 +0000 (23:11 +0000)]
rustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.

2 years agofix: formatting in new test
Caleb Cartwright [Wed, 16 Feb 2022 02:49:36 +0000 (20:49 -0600)]
fix: formatting in new test

2 years agoUse cargo-fmt in self_tests
Cameron Steffen [Tue, 1 Feb 2022 19:39:01 +0000 (13:39 -0600)]
Use cargo-fmt in self_tests

2 years agoFormat code
Cameron Steffen [Tue, 1 Feb 2022 19:38:54 +0000 (13:38 -0600)]
Format code

2 years agoAdd context to get_toml_path() error (#5207)
Travis Finkenauer [Tue, 15 Feb 2022 23:25:44 +0000 (15:25 -0800)]
Add context to get_toml_path() error (#5207)

* rustfmt: print full error chain

* Add context to get_toml_path() error

Instead of an error like:

```
Permission denied (os error 13)
```

Gives error like:

```
Failed to get metadata for config file "/root/.rustfmt.toml": Permission denied (os error 13)
```

2 years agoLeverage itemized blocks to support formatting markdown block quotes
Yacin Tmimi [Thu, 30 Dec 2021 00:59:54 +0000 (19:59 -0500)]
Leverage itemized blocks to support formatting markdown block quotes

Fixes 5157

Doc comments support markdown, but rustfmt didn't previously assign any
semantic value to leading '> ' in comments. This lead to poor formatting
when using ``wrap_comments=true``.

Now, rustfmt treats block quotes as itemized blocks, which greatly
improves how block quotes are formatted when ``wrap_comments=true``.

2 years agochore(rustfmt): remove executable path from usage string (#5216)
Tharun Rajendran [Fri, 11 Feb 2022 04:35:45 +0000 (10:05 +0530)]
chore(rustfmt): remove executable path from usage string (#5216)

* chore(rustfmt): remove executable path from usage string

* add unit test for usage string

* rename test and check usage text in a single assert

2 years agoClarify generated marker requires a config option
Stepan Koltsov [Mon, 7 Feb 2022 04:39:53 +0000 (04:39 +0000)]
Clarify generated marker requires a config option

2 years agoFix incorrect string indentation in macro defs with `format_strings`
Gabriel Smith [Sat, 29 Jan 2022 21:44:49 +0000 (16:44 -0500)]
Fix incorrect string indentation in macro defs with `format_strings`

2 years agoFix doc of generic items formmating error (#5124)
Frank King [Mon, 7 Feb 2022 02:57:39 +0000 (10:57 +0800)]
Fix doc of generic items formmating error (#5124)

* Fix doc of generic items formmating error

* Remove tracked `attrs_end_with_doc_comment` flag in `RewriteContext`

* Fix duplicated doc comments of const generic params

* Fix `<ast::GenericParam as Spanned>::span()`

* Remove duplicated source file of `doc-of-generic-item.rs`

2 years agoAdd tests for the One and Crate variants
Stéphane Campinas [Wed, 2 Feb 2022 14:43:31 +0000 (15:43 +0100)]
Add tests for the One and Crate variants

2 years agoFix import_granularity option when the use tree has an alias
Stéphane Campinas [Mon, 31 Jan 2022 22:45:30 +0000 (23:45 +0100)]
Fix import_granularity option when the use tree has an alias

2 years agoRetain trailing separator when extracting the last inline post comment
Yacin Tmimi [Sun, 19 Dec 2021 21:47:13 +0000 (16:47 -0500)]
Retain trailing separator when extracting the last inline post comment

Fixes 5042

Previously, trailing commas were removed from the last inline comment.
This lead to rustfmt refusing to format code snippets because
the original comment did not match the rewritten comment.

Now, when rustfmt extracts the last inline comment it leaves trailing
separators alone. Rustfmt does not need to remove these separators
because they are commented out.

2 years agoHandle non-ascii character at boundary (#5089)
Stéphane Campinas [Wed, 2 Feb 2022 01:06:14 +0000 (02:06 +0100)]
Handle non-ascii character at boundary (#5089)

* Handle non-ascii character at boundary

* Replace substraction underflow check with early termination

2 years agoPrevent adding trailing whitespace when rewriting ast::Param
Yacin Tmimi [Fri, 10 Dec 2021 04:17:43 +0000 (23:17 -0500)]
Prevent adding trailing whitespace when rewriting ast::Param

Fixes 5125

Previously, a newline was always added, even if the parameter name was
not preceded by any param attrs.

Now a newline is only added if there were param attrs.

2 years agoFix formatting of comments in empty structs (#5171)
Szymon Gibała [Sat, 29 Jan 2022 04:55:47 +0000 (05:55 +0100)]
Fix formatting of comments in empty structs (#5171)

* Fix formatting of comments in empty structs

* Add tests

* Add single line tests

* Fix block comments

* Revert changes of test source files

2 years agorustc_errors: only box the `diagnostic` field in `DiagnosticBuilder`.
Eduard-Mihai Burtescu [Mon, 24 Jan 2022 11:23:14 +0000 (11:23 +0000)]
rustc_errors: only box the `diagnostic` field in `DiagnosticBuilder`.

2 years agoMerge pull request #5186 from calebcartwright/subtree-sync-2022-01-23
Caleb Cartwright [Sun, 23 Jan 2022 18:35:18 +0000 (12:35 -0600)]
Merge pull request #5186 from calebcartwright/subtree-sync-2022-01-23

sync subtree

2 years agochore: bump toolchain, update test
Caleb Cartwright [Sun, 23 Jan 2022 17:18:17 +0000 (11:18 -0600)]
chore: bump toolchain, update test

2 years agoMerge remote-tracking branch 'upstream/master' into subtree-sync-2022-01-23
Caleb Cartwright [Sun, 23 Jan 2022 17:07:20 +0000 (11:07 -0600)]
Merge remote-tracking branch 'upstream/master' into subtree-sync-2022-01-23

2 years agoAdd term to ExistentialProjection
kadmin [Thu, 13 Jan 2022 07:39:58 +0000 (07:39 +0000)]
Add term to ExistentialProjection

Also prevent ICE when adding a const in associated const equality.

2 years agoAdd term
kadmin [Fri, 7 Jan 2022 03:58:32 +0000 (03:58 +0000)]
Add term

Instead of having a separate enum variant for types and consts have one but have either a const
or type.

2 years agoadd eq constraints on associated constants
kadmin [Fri, 30 Jul 2021 08:56:45 +0000 (08:56 +0000)]
add eq constraints on associated constants

2 years agoAuto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
bors [Mon, 17 Jan 2022 09:40:29 +0000 (09:40 +0000)]
Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu

Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`

2 years agofix(rustfmt): resolve generated file formatting issue
Caleb Cartwright [Sat, 15 Jan 2022 00:18:37 +0000 (18:18 -0600)]
fix(rustfmt): resolve generated file formatting issue

2 years agoRemove LLVM-style inline assembly from rustfmt
Tomasz Miąsko [Wed, 12 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Remove LLVM-style inline assembly from rustfmt

2 years agoCompute most of Public/Exported access level in rustc_resolve
Lamb [Mon, 26 Jul 2021 03:38:16 +0000 (05:38 +0200)]
Compute most of Public/Exported access level in rustc_resolve

Mak DefId to AccessLevel map in resolve for export

hir_id to accesslevel in resolve and applied in privacy
using local def id
removing tracing probes
making function not recursive and adding comments

Move most of Exported/Public res to rustc_resolve

moving public/export res to resolve

fix missing stability attributes in core, std and alloc

move code to access_levels.rs

return for some kinds instead of going through them

Export correctness, macro changes, comments

add comment for import binding

add comment for import binding

renmae to access level visitor, remove comments, move fn as closure, remove new_key

fmt

fix rebase

fix rebase

fmt

fmt

fix: move macro def to rustc_resolve

fix: reachable AccessLevel for enum variants

fmt

fix: missing stability attributes for other architectures

allow unreachable pub in rustfmt

fix: missing impl access level + renaming export to reexport

Missing impl access level was found thanks to a test in clippy

2 years agosome minor clippy fixes
Matthias Krüger [Wed, 5 Jan 2022 20:19:36 +0000 (21:19 +0100)]
some minor clippy fixes

2 years agoUse <stdin> when emitting stdin as filename (#4298)
Seiichi Uchida [Fri, 3 Jul 2020 02:13:16 +0000 (11:13 +0900)]
Use <stdin> when emitting stdin as filename (#4298)

# Conflicts:
# src/config/file_lines.rs
# src/rustfmt/main.rs
# src/test/mod.rs

2 years agoFix newlines in JSON output (#4262)
Tim [Tue, 23 Jun 2020 00:20:29 +0000 (01:20 +0100)]
Fix newlines in JSON output (#4262)

* Fix newlines in JSON output

This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line.

When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too).

Fixes #4259

* Update tests
# Conflicts:
# tests/writemode/target/output.json

2 years agorefactor: update json emitter to better handle errors (#3953)
Caleb Cartwright [Mon, 9 Dec 2019 10:41:16 +0000 (04:41 -0600)]
refactor: update json emitter to better handle errors (#3953)

2 years agoFix --check -l with stdin. (#3910)
Chris Emerson [Tue, 12 Nov 2019 02:55:04 +0000 (02:55 +0000)]
Fix --check -l with stdin. (#3910)

* Fix some possible panics when using `--check` with stdin.

One case which doesn't work is when there are only line ending fixes;
with stdin rustfmt is unable to detect the difference as it stores
the input with Unix line endings.

* Add test for `rustfmt --check -l` with stdin.

2 years agoMake `--check` work when running from stdin. (#3896)
Chris Emerson [Wed, 6 Nov 2019 10:15:34 +0000 (10:15 +0000)]
Make `--check` work when running from stdin. (#3896)

# Conflicts:
# src/bin/main.rs

2 years agoImprove out of line module resolution
Yacin Tmimi [Mon, 20 Dec 2021 02:27:25 +0000 (21:27 -0500)]
Improve out of line module resolution

Fixes 5119

When the directory structure was laid out as follows:

```
dir
 |---mod_a
 |    |---sub_mod_1.rs
 |    |---sub_mod_2.rs
 |---mod_a.rs
```

And ``mod_a.rs`` contains the following content:

```rust
mod mod_a {
    mod sub_mod_1;
    mod sub_mod_2;
}
```

rustfmt previously tried to find ``sub_mod_1.rs`` and ``sub_mod_2.rs``
in ``./mod_a/mod_a/``. This directory does not exist and this caused
rustfmt to fail with the error message:

    Error writing files: failed to resolve mod

Now, both ``sub_mod_1.rs`` and ``sub_mod_2.rs`` are resolved correctly
and found at ``mod_a/sub_mod_1.rs`` and ``mod_a/sub_mod_2.rs``.

2 years agoMerge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree
Caleb Cartwright [Thu, 30 Dec 2021 02:49:39 +0000 (20:49 -0600)]
Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree

2 years agoDo not flatten match arm block with leading attributes
David Lattimore [Wed, 29 Dec 2021 23:13:45 +0000 (10:13 +1100)]
Do not flatten match arm block with leading attributes

This is a backport of #4124.

Fixes #4109

2 years agofeat: support parsing asm! args
Caleb Cartwright [Wed, 29 Dec 2021 01:23:51 +0000 (19:23 -0600)]
feat: support parsing asm! args

2 years agochore: bump toolchain
Caleb Cartwright [Wed, 29 Dec 2021 01:23:31 +0000 (19:23 -0600)]
chore: bump toolchain

2 years agochore: reduce some vis. for updated unreachable_pub lint
Caleb Cartwright [Mon, 27 Dec 2021 23:42:48 +0000 (17:42 -0600)]
chore: reduce some vis. for updated unreachable_pub lint

2 years agoRetain qualified path when rewriting struct literals
Yacin Tmimi [Fri, 24 Dec 2021 01:22:09 +0000 (20:22 -0500)]
Retain qualified path when rewriting struct literals

Fixes 5151

Details about the qualified path are now passed along so that rustfmt
can include them when formatting struct literals.

2 years agoFix static async closure qualifier order
David Tolnay [Thu, 23 Dec 2021 22:23:51 +0000 (14:23 -0800)]
Fix static async closure qualifier order

2 years agochore: cleanup unused imports
Caleb Cartwright [Tue, 21 Dec 2021 02:33:20 +0000 (20:33 -0600)]
chore: cleanup unused imports

2 years agorefactor: encapsulate cfg_if parsing within parse mod
Caleb Cartwright [Tue, 21 Dec 2021 02:28:55 +0000 (20:28 -0600)]
refactor: encapsulate cfg_if parsing within parse mod

2 years agorefactor: extract final rustc_parse touchpoint from macros.rs
Caleb Cartwright [Tue, 21 Dec 2021 01:44:23 +0000 (19:44 -0600)]
refactor: extract final rustc_parse touchpoint from macros.rs

2 years agorefactor: move lazy_static parsing to parse mod
Caleb Cartwright [Tue, 21 Dec 2021 01:38:00 +0000 (19:38 -0600)]
refactor: move lazy_static parsing to parse mod

2 years agorefactor: move macro arg parsing to parse mod
Caleb Cartwright [Tue, 21 Dec 2021 00:59:01 +0000 (18:59 -0600)]
refactor: move macro arg parsing to parse mod

2 years agorefactor: rename syntux mod to parse
Caleb Cartwright [Mon, 20 Dec 2021 23:55:48 +0000 (17:55 -0600)]
refactor: rename syntux mod to parse

2 years agoMerge pull request #5140 from calebcartwright/subtree-sync-2021-12-19
Caleb Cartwright [Mon, 20 Dec 2021 22:40:50 +0000 (16:40 -0600)]
Merge pull request #5140 from calebcartwright/subtree-sync-2021-12-19

Subtree sync

2 years agochore: bump toolchain
Caleb Cartwright [Mon, 20 Dec 2021 17:58:27 +0000 (11:58 -0600)]
chore: bump toolchain

2 years agoMerge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-19
Caleb Cartwright [Sun, 19 Dec 2021 21:22:45 +0000 (15:22 -0600)]
Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-19

2 years agoRemove unnecessary sigils around `Ident::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 05:13:11 +0000 (16:13 +1100)]
Remove unnecessary sigils around `Ident::as_str()` calls.

2 years agoRemove unnecessary sigils around `Symbol::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 03:39:23 +0000 (14:39 +1100)]
Remove unnecessary sigils around `Symbol::as_str()` calls.

2 years agoRemove `SymbolStr`.
Nicholas Nethercote [Tue, 14 Dec 2021 21:32:21 +0000 (08:32 +1100)]
Remove `SymbolStr`.

By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!

2 years agoPrevent duplicate comma when formatting struct pattern with ".."
Yacin Tmimi [Thu, 18 Nov 2021 01:46:48 +0000 (20:46 -0500)]
Prevent duplicate comma when formatting struct pattern with ".."

Fixes 5066

When a struct pattern that contained a ".." was formatted, it was
assumed that a trailing comma should always be added if the struct
fields weren't formatted vertically.

Now, a trailing comma is only added if not already included in the
reformatted struct fields.

2 years agoclippy fixes
Matthias Krüger [Sun, 12 Dec 2021 19:15:08 +0000 (20:15 +0100)]
clippy fixes

2 years agoBackport: Do not touch module with #![rustfmt::skip] (4297)
Yacin Tmimi [Wed, 24 Nov 2021 23:47:37 +0000 (18:47 -0500)]
Backport: Do not touch module with #![rustfmt::skip] (4297)

Although the implementation is slightly different than the original PR,
the general idea is the same. After collecting all modules we want to
exclude formatting those that contain the #![rustfmt::skip] attribute.

2 years agoMerge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree
Caleb Cartwright [Fri, 3 Dec 2021 03:35:30 +0000 (21:35 -0600)]
Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree

2 years agoMerge pull request #5121 from calebcartwright/subtree-sync-2021-12-02
Caleb Cartwright [Fri, 3 Dec 2021 03:29:47 +0000 (21:29 -0600)]
Merge pull request #5121 from calebcartwright/subtree-sync-2021-12-02

subtree sync

2 years agoMerge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02
Caleb Cartwright [Fri, 3 Dec 2021 03:02:14 +0000 (21:02 -0600)]
Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02

2 years agoDetermine when new comment lines are needed for itemized blocks
Yacin Tmimi [Fri, 19 Nov 2021 23:52:52 +0000 (18:52 -0500)]
Determine when new comment lines are needed for itemized blocks

Fixes 5088

Previously, rustfmt would add a new comment line anytime it reformatted
an itemized block within a comment when ``wrap_comments=true``. This
would lead to rustfmt adding empty comments with trailing whitespace.

Now, new comment lines are only added if the original comment spanned
multiple lines, if the comment needs to be wrapped, or if the comment
originally started with an empty comment line.

2 years agoUpdate nightly only test with #[nightly_only_test] attribute
Yacin Tmimi [Mon, 29 Nov 2021 04:39:31 +0000 (23:39 -0500)]
Update nightly only test with #[nightly_only_test] attribute

2 years agorefactor: maintain more AST info when formatting a RHS
Caleb Cartwright [Sun, 28 Nov 2021 21:22:49 +0000 (15:22 -0600)]
refactor: maintain more AST info when formatting a RHS

2 years agoConditionally compile tests based on CFG_RELEASE_CHANNEL env var
Yacin Tmimi [Sat, 27 Nov 2021 22:14:15 +0000 (17:14 -0500)]
Conditionally compile tests based on CFG_RELEASE_CHANNEL env var

Adds the ``nightly_only_test`` and ``stable_only_test`` attribute macros
that prevent or allow certain tests to compile on nightly and stable
respectively. This is achieved through conditionally outputting the
tests TokenStream.

If CFG_RELEASE_CHANNEL is not set, it's assumed that we're running in a
nightly environment.

To mark a test as nightly only:

    #[nightly_only_test]
    #[test]
    fn only_run_on_nightly() {
        ...
    }

To mark a test a stable only:

    #[stable_only_test]
    #[test]
    fn only_run_on_stable() {
        ...
    }

2 years agoRun Windows, Linux, and Mac CI tests with nightly and stable channels
Yacin Tmimi [Wed, 24 Nov 2021 08:35:01 +0000 (03:35 -0500)]
Run Windows, Linux, and Mac CI tests with nightly and stable channels

2 years agoAdd more tests for comments in lists
mujpao [Wed, 24 Nov 2021 23:05:23 +0000 (15:05 -0800)]
Add more tests for comments in lists

2 years agoUpdate README.md
Fabian Keller [Wed, 24 Nov 2021 09:38:55 +0000 (10:38 +0100)]
Update README.md

2 years agoChange how the fn params span is calculated
Esteban Kuber [Wed, 24 Nov 2021 17:11:15 +0000 (17:11 +0000)]
Change how the fn params span is calculated

Use the available Generics span field to avoid issues with `T: Fn()` bounds.

This is necessary to land #85346.

2 years agofix: do not wrap reference-style doc links
Dom [Fri, 19 Nov 2021 19:15:33 +0000 (20:15 +0100)]
fix: do not wrap reference-style doc links

Prevents wrap_comments from incorrectly wrapping reference-style doc
links.

2 years agoAdd a few missing tracking issues in Configurations.md (#5084)
Johannes Linke [Sat, 20 Nov 2021 01:22:50 +0000 (02:22 +0100)]
Add a few missing tracking issues in Configurations.md (#5084)

* Add a few missing tracking issues in Configurations.md

* fix: tracking issue for imports_granularity stabilization

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2 years agoPreserve normalized comments after last list item
mujpao [Fri, 19 Nov 2021 01:06:49 +0000 (17:06 -0800)]
Preserve normalized comments after last list item

2 years agofix: correct some type alias issues
Caleb Cartwright [Thu, 18 Nov 2021 18:39:38 +0000 (12:39 -0600)]
fix: correct some type alias issues

2 years agotests: add cases for type alias issues
Caleb Cartwright [Thu, 18 Nov 2021 18:38:34 +0000 (12:38 -0600)]
tests: add cases for type alias issues

2 years agorefactor: cleanup duplicative Impl handling code
Caleb Cartwright [Wed, 17 Nov 2021 18:51:37 +0000 (12:51 -0600)]
refactor: cleanup duplicative Impl handling code

2 years agoLink tracking issues in Configurations.md (#4096)
Wu Yu Wei [Tue, 31 Mar 2020 06:36:12 +0000 (14:36 +0800)]
Link tracking issues in Configurations.md (#4096)

# Conflicts:
# Configurations.md