Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustfmt subtree update #117065

Closed
wants to merge 84 commits into from

Conversation

calebcartwright
Copy link
Member

r? @ghost

Includes let chain formatting, amongst a few other smaller changes and fixes

WaffleLapkin and others added 30 commits June 19, 2023 12:54
…trieb

Syntactically accept `become` expressions (explicit tail calls experiment)

This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature.

cc `@scottmcm`
There were some upstream changes made a while back that requires this to
be set when building rustfmt from source like we do in the
`check_diff.sh` script.

See issue 5675 for more details.
The `set -e` option is used to immediately exit if any command exits
with a non zero exit status. This will help us catch errors in the
script, for example, needing the `LD_LIBRARY_PATH` to be set.
There was an issue with the script when passing optional rustfmt configs
without specifying a commit hash. Because these optional values are
passed via positional arguments the configs ($4)  would be used in place
of the commit hash ($3). Now that we set a default value for the
optional commit hash we avoid this problem.
* Use matches!() macro to improve readability

1. Use `matches!()` macro in `is_line_comment` and `is_block_comment` to
improve readability.
2. Very sightly improve the wording of the doc comment for these two functions.

* Update wording on doc comment on is_line_comment()
Fixes 5730

Previously rustfmt was attempting to slice a string with an invalid
range (`start > end`), leading to the ICE.

When formatting a macro transcriber snippet consisting of a lone
semicolon, the snippet was being formatted into the empty string,
leading the enclosing `fn main() {\n}` added by `format_code_block` to
be formatted into `fn main() {}`. However, rustfmt was assuming that the
enclosing function string's length had been left unchanged. This was
leading to an invalid range being constructed when attempting to trim
off the enclosing function.

The fix is to just clamp the range's start to be less than or equal
to the range's end, since if `end < start` there's nothing to iterate
over anyway.
Implement rust-lang/compiler-team#578.

When an ICE is encountered on nightly releases, the new rustc panic
handler will also write the contents of the backtrace to disk. If any
`delay_span_bug`s are encountered, their backtrace is also added to the
file. The platform and rustc version will also be collected.
…g#5838)

Update docs to include an example of running `rustfmt` built from src,
and show how users can set the `RUSTFMT` environment variable to test
`cargo-fmt` using the `rustfmt` they built from src.
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to
indicate that output should be blessed, but they use different variable names.
In order to improve consistency, this patch applies the following changes:

- Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always
  available
- Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS`
- Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS`
- Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS`
- Adjust the blessable test in `rustc_errors` to use this same
  convention
- Update documentation where applicable

Any tools that uses `RUSTC_BLESS` should check that it is set to any value
other than `"0"`.
Token tree cloning is only needed in one place.
Resolves 5542

Prior to rust-lang#101212 the `ast::TraitObjectSyntax` enum only
had two variants `Dyn` and `None`. The PR that introduced the `dyn*`
syntax added a new variant `DynStar`, but did not update the formatting
rules to account for the new variant.

Now the new `DynStar` variant is properly handled and is no longer
removed by rustfmt.
… r=petrochenkov

Less `TokenTree` cloning

`TokenTreeCursor` has this comment on it:
```
// FIXME: Many uses of this can be replaced with by-reference iterator to avoid clones.
```
This PR completes that FIXME. It doesn't have much perf effect, but at least we now know that.

r? `@petrochenkov`
matthewjasper and others added 22 commits September 11, 2023 15:51
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>
* chore: Update clap
* refactor(cargo): Update style of derive
* feat(cargo): Style help like cargo nightly
* Fix rust-lang#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>
Signed-off-by: cui fliter <imcusg@gmail.com>
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.
bumping from v1.6.0 -> v1.7.0 since we added support for let-chains
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2023
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2023

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 23, 2023
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2023

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git rebase -i master
$ # delete any merge commits in the editor that appears
$ git push --force-with-lease

The following commits are merge commits:

@calebcartwright calebcartwright added the subtree-sync PR updates a subtree (miri, clippy, etc). Ignored by no-merges check label Oct 23, 2023
@calebcartwright calebcartwright changed the title Update Rustfmt Rustfmt subtree update Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. subtree-sync PR updates a subtree (miri, clippy, etc). Ignored by no-merges check
Projects
None yet
Development

Successfully merging this pull request may close these issues.