]> git.lizzy.rs Git - rust.git/log
rust.git
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 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

2 years agoMerge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
Caleb Cartwright [Mon, 8 Nov 2021 02:37:34 +0000 (20:37 -0600)]
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync

2 years agoMerge pull request #5070 from calebcartwright/rustup-2021-11-s1
Caleb Cartwright [Mon, 8 Nov 2021 01:40:15 +0000 (19:40 -0600)]
Merge pull request #5070 from calebcartwright/rustup-2021-11-s1

subtree sync

2 years agochore: bump toolchain
Caleb Cartwright [Mon, 8 Nov 2021 01:06:24 +0000 (19:06 -0600)]
chore: bump toolchain

2 years agoMerge remote-tracking branch 'upstream/master' into rustup-2021-11-s1
Caleb Cartwright [Sun, 7 Nov 2021 20:44:33 +0000 (14:44 -0600)]
Merge remote-tracking branch 'upstream/master' into rustup-2021-11-s1

2 years agorefactor: dedupe associated item visitation
Caleb Cartwright [Sat, 6 Nov 2021 22:12:25 +0000 (17:12 -0500)]
refactor: dedupe associated item visitation

2 years agoast: Fix naming conventions in AST structures
Vadim Petrochenkov [Sun, 7 Nov 2021 08:43:49 +0000 (16:43 +0800)]
ast: Fix naming conventions in AST structures

TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn

All `*Kind`s in AST are supposed to be enums.

Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.

Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.

2 years agorefactor: dedupe & simplify ty alias formatting
Caleb Cartwright [Sat, 6 Nov 2021 17:59:06 +0000 (12:59 -0500)]
refactor: dedupe & simplify ty alias formatting

2 years agoPut empty trait braces on same line if possible
mujpao [Tue, 2 Nov 2021 06:13:30 +0000 (23:13 -0700)]
Put empty trait braces on same line if possible

2 years agoUpdate IntelliJ Integration (#4238)
Dmitry Murzin [Sat, 6 Jun 2020 14:19:50 +0000 (17:19 +0300)]
Update IntelliJ Integration (#4238)

2 years agofix: handle external mods imported via external->inline load hierarchy
Caleb Cartwright [Thu, 4 Nov 2021 23:00:22 +0000 (18:00 -0500)]
fix: handle external mods imported via external->inline load hierarchy

2 years agoci: drop appveyor
Caleb Cartwright [Thu, 4 Nov 2021 02:10:01 +0000 (21:10 -0500)]
ci: drop appveyor

2 years ago Remove grave accent that shouldn't be there
r00ster [Mon, 1 Nov 2021 18:53:35 +0000 (19:53 +0100)]
 Remove grave accent that shouldn't be there

2 years agoUse a custom env var for log settings intead of default RUST_LOG
Peter Hall [Wed, 7 Oct 2020 11:55:01 +0000 (12:55 +0100)]
Use a custom env var for log settings intead of default RUST_LOG

# Conflicts:
# src/rustfmt/main.rs

2 years agoPrevent trailing whitespace in where clause bound predicate
Yacin Tmimi [Fri, 8 Oct 2021 23:22:12 +0000 (19:22 -0400)]
Prevent trailing whitespace in where clause bound predicate

resolves 5012
resolves 4850

This behavior was noticed when using the ``trailing_comma = "Never"``
configuration option (5012).

This behavior was also noticed when using default configurations (4850).

rustfmt would add a trailing space to where clause bounds that had an
empty right hand side.

Now no trailing space is added to the end of these where clause bounds.

2 years agoDocument RUSTFMT environment variable (#4464)
Jonathan [Sun, 11 Oct 2020 16:28:45 +0000 (16:28 +0000)]
Document RUSTFMT environment variable (#4464)

* Document RUSTFMT env var

* Move documentation up

* Apply suggestions from code review

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

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

2 years agoFix MSRV
chansuke [Wed, 25 Nov 2020 10:31:02 +0000 (19:31 +0900)]
Fix MSRV

2 years agoREADME grammar fix (#3926)
enterprisey [Thu, 14 Nov 2019 14:44:59 +0000 (09:44 -0500)]
README grammar fix (#3926)

Remove comma splice

2 years agorefactor: minor parser cleanup
Caleb Cartwright [Sat, 30 Oct 2021 15:10:08 +0000 (10:10 -0500)]
refactor: minor parser cleanup

2 years agoRetain trailing comments in module when using rustfmt::skip attribute
Yacin Tmimi [Tue, 19 Oct 2021 05:14:51 +0000 (01:14 -0400)]
Retain trailing comments in module when using rustfmt::skip attribute

Resolves 5033

Trailing comments at the end of the root Module were removed because the
module span did not extend until the end of the file.

The root Module's span now encompasses the entire file, which ensures
that no comments are lost when using ``#![rustfmt::skip]``

2 years agoRemove legacy-rustfmt.toml (#4169)
Seiichi Uchida [Mon, 11 May 2020 00:50:41 +0000 (09:50 +0900)]
Remove legacy-rustfmt.toml (#4169)

2 years agofix a bunch of the other clippy warnings that look interesting
Matthias Krüger [Sat, 23 Oct 2021 21:21:52 +0000 (23:21 +0200)]
fix a bunch of the other clippy warnings that look interesting

2 years agofix clippy::needless_borrow
Matthias Krüger [Sat, 23 Oct 2021 21:07:57 +0000 (23:07 +0200)]
fix clippy::needless_borrow

2 years agoAdd rustdoc CI check
Yacin Tmimi [Sat, 23 Oct 2021 21:18:47 +0000 (17:18 -0400)]
Add rustdoc CI check

Resolves 5038

rust-lang/rust builds now document rustfmt (rust-lang/rust#87119). The
build process is updated with doc checks to ensure that rustfmt doesn't
introduce warnings.

Warnings are treated as hard errors in rust-lang/rust and won't show
until bors tests the changes (refs rust-lang/rust#90087).

2 years agoMerge pull request #5043 from calebcartwright/another-subtree-sync
Caleb Cartwright [Sun, 24 Oct 2021 19:56:55 +0000 (14:56 -0500)]
Merge pull request #5043 from calebcartwright/another-subtree-sync

sync subtree

2 years agoMerge remote-tracking branch 'upstream/master' into another-subtree-sync
Caleb Cartwright [Sun, 24 Oct 2021 18:45:19 +0000 (13:45 -0500)]
Merge remote-tracking branch 'upstream/master' into another-subtree-sync

2 years agoAdd One option to group_imports (#4966)
Martinez [Sat, 23 Oct 2021 16:01:48 +0000 (19:01 +0300)]
Add One option to group_imports (#4966)

* Add Together option to group_imports

* Rename option to One

* Rename files from Together to One

2 years agofix doc issue in rustfmt
Caleb Cartwright [Thu, 21 Oct 2021 22:22:54 +0000 (17:22 -0500)]
fix doc issue in rustfmt

2 years agoensure cargo-fmt tests are excluded from root workspace
Caleb Cartwright [Wed, 20 Oct 2021 15:12:22 +0000 (10:12 -0500)]
ensure cargo-fmt tests are excluded from root workspace

2 years agoMerge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree
Caleb Cartwright [Wed, 20 Oct 2021 05:11:59 +0000 (00:11 -0500)]
Merge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree

2 years agochore: bump version and changelog
Caleb Cartwright [Wed, 20 Oct 2021 05:00:30 +0000 (00:00 -0500)]
chore: bump version and changelog

2 years agoMerge pull request #5036 from calebcartwright/1.4.38-subtree
Caleb Cartwright [Wed, 20 Oct 2021 04:38:47 +0000 (23:38 -0500)]
Merge pull request #5036 from calebcartwright/1.4.38-subtree

sync subtree

2 years agochore: bump toolchain, fix conflict
Caleb Cartwright [Wed, 20 Oct 2021 04:13:06 +0000 (23:13 -0500)]
chore: bump toolchain, fix conflict

2 years agoMerge branch 'master' into 1.4.38-subtree
Caleb Cartwright [Wed, 20 Oct 2021 04:01:25 +0000 (23:01 -0500)]
Merge branch 'master' into 1.4.38-subtree

2 years agoReplace match expression with match! macro
Yacin Tmimi [Tue, 19 Oct 2021 00:48:58 +0000 (20:48 -0400)]
Replace match expression with match! macro

This is a follow up to 5f4811ed7bc600e0cbe40c962e8933adb9baaddf

The matches! macro expresses the condition more succinctly and avoids
the extra level of indentation introduced with the match arm body.

2 years agoHandle DefinitiveListTactic::SpecialMacro when writing pre-comments
Yacin Tmimi [Thu, 14 Oct 2021 21:16:28 +0000 (17:16 -0400)]
Handle DefinitiveListTactic::SpecialMacro when writing pre-comments

Resolves 4615

Previously only Vertical and Mixed enum variants of DefinitiveListTactic
were considered when rewriting pre-comments for inner items in
lists::write_list.

Because we failed to considering the SpecialMacro variant we ended up in
a scenario where a ListItem with a pre_comment and a pre_comment_style
of ListItemCommentStyle::DifferentLine was written on the same line as the
list item itself.

Now we apply the same pre-comment formatting to SpecialMacro, Vertical,
and Mixed variants of DefinitiveListTactic.

2 years agoci: fix release asset upload job
Caleb Cartwright [Thu, 14 Oct 2021 02:41:50 +0000 (21:41 -0500)]
ci: fix release asset upload job

2 years agofeat: stabilize disable_all_formatting
Caleb Cartwright [Thu, 14 Oct 2021 02:22:34 +0000 (21:22 -0500)]
feat: stabilize disable_all_formatting

2 years agoUpdate connector search in ControlFlow::rewrite_pat_expr for for loops
Yacin Tmimi [Wed, 6 Oct 2021 17:09:24 +0000 (13:09 -0400)]
Update connector search in ControlFlow::rewrite_pat_expr for for loops

Resolves 5009

For loops represented by a ControlFlow object use " in" as their connector.
rustfmt searches for the first uncommented occurrence of the word "in" within the
current span and adjusts it's starting point to look for comments right after that.
visually this looks like this:

    rustfmt starts looking for comments here
            |
            V
    for x in /* ... */ 0..1 {}

This works well in most cases, however when the pattern also contains
the word "in", this leads to issues.

    rustfmt starts looking for comments here
          |
          V
    for in_here in /* ... */ 0..1 {}
        -------
        pattern

In order to correctly identify the connector, the new approach first
updates the span to start after the pattern and then searches for the
first uncommented occurrence of "in".

2 years agoAdjust non-empty tuple struct span to start before fields
Yacin Tmimi [Tue, 5 Oct 2021 05:24:10 +0000 (01:24 -0400)]
Adjust non-empty tuple struct span to start before fields

Resolves 5011

Tuple structs with visibility modifiers and comments before the first
field were incorrectly formatted. Comments would duplicate part of the
visibility modifier and struct name.

When trying to parse the tuple fields the ``items::Context`` searches
for the opening '(', but because the visibility modifier introduces
another '(' -- for example ``pub(crate)`` -- the parsing gets messed up.

Now the span is adjusted to start after the struct identifier, or after
any generics. Adjusting the span in this way ensures that the
``items::Contex`` will correctly find the tuple fields.

2 years agoPrevent structs with ".." from being rewritten with alignment
Yacin Tmimi [Mon, 11 Oct 2021 22:30:35 +0000 (18:30 -0400)]
Prevent structs with ".." from being rewritten with alignment

 rustfmt should only support rewriting a struct in an expression
 position with alignment (non-default behavior) when there is no rest
 (with or without a base) and all of the fields are non-shorthand.

2 years agoStabilize match_block_trailing_comma. (#4145)
Emilio Cobos Álvarez [Sat, 16 May 2020 20:20:51 +0000 (22:20 +0200)]
Stabilize match_block_trailing_comma. (#4145)

Servo has used this since forever, and it'd be useful to be able to use
rustfmt stable there so that we can use the same rustfmt version in
both Firefox and Servo.

Feel free to close this if there's any reason it shouldn't be done.

2 years agoAdd additional test cases for issue 4984
Yacin Tmimi [Wed, 29 Sep 2021 18:18:54 +0000 (14:18 -0400)]
Add additional test cases for issue 4984

2 years agoUpdate derive attibute span to start after opening '('
Yacin Tmimi [Fri, 24 Sep 2021 02:43:03 +0000 (22:43 -0400)]
Update derive attibute span to start after opening '('

Fixes 4984

When parsing derive attributes we're only concerned about the traits
and comments listed between the opening and closing parentheses.

Derive attribute spans currently start at the '#'.

    Span starts here
    |
    v
    #[derive(...)]

After this update the derive spans start after the opening '('.

    Span starts here
             |
             V
    #[derive(...)]

2 years agoWrap long array and slice patterns.
Patrick Walton [Sat, 18 Sep 2021 01:56:30 +0000 (18:56 -0700)]
Wrap long array and slice patterns.

Closes #4530.

2 years agoAdd tests for binop_separator = Back
Ulyssa [Mon, 20 Sep 2021 23:29:28 +0000 (16:29 -0700)]
Add tests for binop_separator = Back

2 years agoPrevent removal of qualified path for tuple struct inside macro
Yacin Tmimi [Mon, 27 Sep 2021 20:55:23 +0000 (16:55 -0400)]
Prevent removal of qualified path for tuple struct inside macro

fixes 5005

This was very similar to 4964 and the fix was to extract and pass along
the qself of the ``PatKind::TupleStruct``

2 years agoIn Configurations.md demonstrate both cases for noop selections
Lucas Kent [Fri, 10 Sep 2021 07:50:40 +0000 (17:50 +1000)]
In Configurations.md demonstrate both cases for noop selections

2 years agorefactor: simplify local dep lookups
Caleb Cartwright [Tue, 21 Sep 2021 00:09:16 +0000 (19:09 -0500)]
refactor: simplify local dep lookups

2 years agotests: restructure and extend cargo-fmt tests
Caleb Cartwright [Mon, 20 Sep 2021 23:58:38 +0000 (18:58 -0500)]
tests: restructure and extend cargo-fmt tests

2 years agodeps: update cargo_metadata to include 'path'
Caleb Cartwright [Mon, 20 Sep 2021 03:15:50 +0000 (22:15 -0500)]
deps: update cargo_metadata to include 'path'

2 years agoMigrate to 2021
Mark Rousskov [Sun, 19 Sep 2021 16:49:55 +0000 (12:49 -0400)]
Migrate to 2021

2 years agoTrailing comma on match block goes missing when guard is on its own line
Ulyssa [Wed, 15 Sep 2021 15:58:23 +0000 (08:58 -0700)]
Trailing comma on match block goes missing when guard is on its own line

2 years agorefactor: use iter workaround for contains() gap
Caleb Cartwright [Fri, 17 Sep 2021 02:25:09 +0000 (21:25 -0500)]
refactor: use iter workaround for contains() gap

2 years agofeat: add --check flag to cargo fmt (#3890)
Caleb Cartwright [Sun, 27 Oct 2019 02:07:04 +0000 (21:07 -0500)]
feat: add --check flag to cargo fmt (#3890)

2 years agoRollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco
Manish Goregaokar [Wed, 15 Sep 2021 21:56:58 +0000 (14:56 -0700)]
Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco

Revert anon union parsing

Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.

Fix #88583.

2 years agofeat: upper- or lowercase hexadecimal literals
Arjen Laarhoven [Thu, 15 Jul 2021 17:55:52 +0000 (19:55 +0200)]
feat: upper- or lowercase hexadecimal literals

2 years agoSupport @generated marker to skip code formatting
Seiichi Uchida [Fri, 10 Jul 2020 02:23:12 +0000 (11:23 +0900)]
Support @generated marker to skip code formatting

This is a copy of #4296 with these changes:
* file is not reopened again to find if the file is generated
* first five lines are scanned for `@generated` marker instead of one
* no attempt is made to only search for marker in comments

`@generated` marker is used by certain tools to understand that the
file is generated, so it should be treated differently than a file
written by a human:
* linters should not be invoked on these files,
* diffs in these files are less important,
* and these files should not be reformatted.

This PR proposes builtin support for `@generated` marker.

I have not found a standard for a generated file marker, but:
* Facebook [uses `@generated` marker](https://tinyurl.com/fb-generated)
* Phabricator tool which was spawned from Facebook internal tool
  [also understands `@generated` marker](https://git.io/JnVHa)
* Cargo inserts `@generated` marker into [generated Cargo.lock files](https://git.io/JnVHP)

My personal story is that rust-protobuf project which I maintain
was broken twice because of incompatibilities/bugs in rustfmt marker
handling: [one](https://github.com/stepancheg/rust-protobuf/issues/493),
[two](https://github.com/stepancheg/rust-protobuf/issues/551).
(Also, rust-protobuf started generating `@generated` marker
[6 years ago](https://git.io/JnV5h)).

While rustfmt AST markers are useful to apply to a certain AST
elements, disable whole-file-at-once all-tools-at-once text level
marker might be easier to use and more reliable for generated code.

2 years agoopts: rephrase wording for --all and -p
Laurențiu Nicola [Fri, 8 Nov 2019 21:50:18 +0000 (23:50 +0200)]
opts: rephrase wording for --all and -p

2 years agoAuto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
bors [Sat, 11 Sep 2021 23:35:28 +0000 (23:35 +0000)]
Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov

Encode spans relative to the enclosing item

The aim of this PR is to avoid recomputing queries when code is moved without modification.

MCP at https://github.com/rust-lang/compiler-team/issues/443

This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.

Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
  depends on the span's absolute byte position.

With this scheme, I believe the dependency tracking to be accurate.

For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.

2 years agoKeep a parent LocalDefId in SpanData.
Camille GILLOT [Sun, 18 Apr 2021 12:27:04 +0000 (14:27 +0200)]
Keep a parent LocalDefId in SpanData.

2 years agoIgnore automatically derived impls of `Clone` and `Debug` in dead code analysis
Fabian Wolff [Fri, 21 May 2021 17:35:49 +0000 (19:35 +0200)]
Ignore automatically derived impls of `Clone` and `Debug` in dead code analysis

2 years agoRevert "Allow formatting `Anonymous{Struct, Union}` declarations"
Felix S. Klock II [Wed, 8 Sep 2021 17:40:32 +0000 (13:40 -0400)]
Revert "Allow formatting `Anonymous{Struct, Union}` declarations"

This reverts commit 64acb7d92135ae722dfce89f0ca9d7cf6576de66.

2 years agorustfmt doc code blocks with multiple comma-separated attributes
Nipunn Koorapati [Sun, 8 Aug 2021 01:00:51 +0000 (18:00 -0700)]
rustfmt doc code blocks with multiple comma-separated attributes

Added test covering this. Chose to treat the code block
as rust if and only if all of the comma-separated attributes
are rust-valid. Chose to allow/preserve whitespace around commas

Fixes #3158

2 years agofix: handle param doc comments for macro scenarios
Caleb Cartwright [Wed, 8 Sep 2021 23:59:49 +0000 (18:59 -0500)]
fix: handle param doc comments for macro scenarios

2 years agofix: resolve idempotency issue in extern body elements
Caleb Cartwright [Wed, 8 Sep 2021 00:49:56 +0000 (19:49 -0500)]
fix: resolve idempotency issue in extern body elements

2 years agotests: add files for issue 4579
Caleb Cartwright [Mon, 6 Sep 2021 22:30:16 +0000 (17:30 -0500)]
tests: add files for issue 4579

2 years agotry to write the parameter on a new line in case the attribute/parameter together...
Stéphane Campinas [Tue, 6 Oct 2020 01:44:48 +0000 (03:44 +0200)]
try to write the parameter on a new line in case the attribute/parameter together are over max_width

2 years agofix: use correct spans for params with attrs
Caleb Cartwright [Mon, 6 Sep 2021 20:35:25 +0000 (15:35 -0500)]
fix: use correct spans for params with attrs

2 years agofix: newline width calc in combine w/ comments (#4123)
Caleb Cartwright [Thu, 16 Apr 2020 12:52:47 +0000 (07:52 -0500)]
fix: newline width calc in combine w/ comments (#4123)

2 years agoAuto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
bors [Mon, 6 Sep 2021 00:14:41 +0000 (00:14 +0000)]
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank

Fix #88256 remove duplicated diagnostics

Fix #88256

2 years agoFix #88256, remove duplicated diagnostic
yukang [Sat, 4 Sep 2021 11:26:25 +0000 (19:26 +0800)]
Fix #88256, remove duplicated diagnostic

2 years agoDetect bare blocks with type ascription that were meant to be a `struct` literal
Esteban Kuber [Thu, 2 Sep 2021 18:34:03 +0000 (18:34 +0000)]
Detect bare blocks with type ascription that were meant to be a `struct` literal

Address part of #34255.

Potential improvement: silence the other knock down errors in
`issue-34255-1.rs`.

2 years agotest: add test for #4322
Eric [Mon, 30 Aug 2021 09:17:43 +0000 (21:17 +1200)]
test: add test for #4322

2 years agotest: add test for #4954
Eric [Mon, 30 Aug 2021 09:13:42 +0000 (21:13 +1200)]
test: add test for #4954

2 years agotest: add test for #4257
Eric [Mon, 30 Aug 2021 09:09:21 +0000 (21:09 +1200)]
test: add test for #4257

2 years agotest: add missing source for #4943
Eric [Mon, 30 Aug 2021 08:59:45 +0000 (20:59 +1200)]
test: add missing source for #4943

2 years agoAdd <title> to docs
Akiomi Kamakura [Wed, 1 Sep 2021 11:15:16 +0000 (20:15 +0900)]
Add <title> to docs

2 years agoImplement `One` option for imports_granularity (#4669)
Yusuke Tanaka [Sat, 30 Jan 2021 05:50:28 +0000 (14:50 +0900)]
Implement `One` option for imports_granularity (#4669)

This option merges all imports into a single `use` statement as long as
they have the same visibility.

2 years agoTemporary fix rustfmt for let-else
Cameron Steffen [Sun, 25 Jul 2021 23:28:08 +0000 (18:28 -0500)]
Temporary fix rustfmt for let-else

2 years agoFix rustfmt test
Deadbeef [Fri, 27 Aug 2021 11:53:03 +0000 (11:53 +0000)]
Fix rustfmt test

2 years agoIntroduce `~const`
Deadbeef [Wed, 25 Aug 2021 11:53:16 +0000 (11:53 +0000)]
Introduce `~const`

 - [x] Removed `?const` and change uses of `?const`
 - [x] Added `~const` to the AST. It is gated behind const_trait_impl.
 - [x] Validate `~const` in ast_validation.
 - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and
 `ConstIfConst` allowing future extensions)
 - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`.
 - [ ] Optional steps (*for this PR, obviously*)
      - [ ] Fix #88155
      - [ ] Do something with constness bounds in chalk

2 years agofix: remove wrong reformatting of qualified paths in struct patterns
Ashvin Arsakularatne [Wed, 25 Aug 2021 18:51:29 +0000 (00:21 +0530)]
fix: remove wrong reformatting of qualified paths in struct patterns