Skip to content

Enable incremental rustfmt adoption#65939

Merged
bors merged 7 commits intorust-lang:masterfrom
anp:incremental-rustfmt-rollout
Dec 22, 2019
Merged

Enable incremental rustfmt adoption#65939
bors merged 7 commits intorust-lang:masterfrom
anp:incremental-rustfmt-rollout

Conversation

@anp
Copy link
Contributor

@anp anp commented Oct 29, 2019

Enables an incremental rollout of rustfmt usage within the compiler via a granular ignore configuration and automated enforcement. The decision to format the repository was approved in rust-lang/compiler-team#80 (comment).

This PR includes:

  • an [ignore] section to rustfmt.toml including most of the repository
  • ./x.py downloads rustfmt from a specific nightly (we do not pin to beta or stable as we need unstable features)
  • an ./x.py fmt [--check] command which runs cargo-fmt
  • ./x.py fmt --check runs during the same test step as src/tools/tidy, on master, but not on beta or stable as we don't want to depend on nightly rustfmt there.
  • a commit to format src/librustc_fs_util as an initial target and to ensure enforcement is working from the start

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 29, 2019
@nikomatsakis
Copy link
Contributor

Big 👍 to this approach overall, I have no idea about the question of integrating into tidy though -- maybe we can somehow find it in path?

@Mark-Simulacrum
Copy link
Member

I'm going to r? @Mark-Simulacrum here and try and find some time this week to get back to you here on the overall approach and such. I'm sure we'll want sign off from T-compiler (and perhaps T-libs) as the primary "owners" of the code in this repository but for now we can likely figure out a game plan to bring to fcp.

@Mark-Simulacrum
Copy link
Member

Would it make more sense to use the bootstrap toolchain's rustfmt binary? What's the best way to experiment with that?

I suspect that the best thing is indeed to use the bootstrap binary, as that'll be a preset way that'll change at the right points and is guaranteed to exist and such. The way to do this today is probably to add another artifact to the things we download (in particular, in src/bootstrap/bootstrap.py).

Let me know if you'd like further details on how to do that, I can look into it, though I've not recently explored that piece of code.

I agree with @nikomatsakis that this is the right approach, seems like the best way to phase this in.

If we want to test this out on a particular subdirectory I think src/bootstrap is perhaps a good candidate as it's fairly small and changes not too often. However, we can also land this I think without enabling it and then enable it for a specific directory in a separate PR.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 29, 2019
@anp
Copy link
Contributor Author

anp commented Oct 30, 2019

Cool! I think I have bootstrap.py fetching the binary (see pushed commit). Next step is to figure out the places to run it. I see two:

  1. modify bootstrap+tidy to know how to use x.py's rustfmt as part of its style checking (working on this)
  2. add a documented command somewhere (maybe a bootstrap subcommand?) that can be used to format one's code locally

@anp anp force-pushed the incremental-rustfmt-rollout branch from 78794d1 to 7a52437 Compare October 30, 2019 02:59
@Centril
Copy link
Contributor

Centril commented Oct 30, 2019

I believe the compiler team already approved of formatting the repo in rust-lang/compiler-team#80.

@anp take a look at Centril/rfcs#21

@Mark-Simulacrum
Copy link
Member

Cool! I think I have bootstrap.py fetching the binary (see pushed commit).

Yep, this looks good.

I think we should add it as an x.py command, e.g., x.py fmt to mirror cargo fmt, which would have a --check flag for CI (similar to cargo fmt I believe), it would also know how to run rustfmt/cargo fmt with the appropriate flags and such.

I think tidy is probably not quite the right place as at least I know that it's sort of not the thing you run by default, i.e., x.py fmt should be runnable "on save" or so from editors I hope whereas tidy is possibly too slow or not a good fit for that. The tidy test step in bootstrap might want to run the fmt check as well though (not the tidy binary, but the impl Step for Tidy (not sure on naming) in src/bootstrap/test.rs).

@Mark-Simulacrum
Copy link
Member

Last two commits look a little different from what I had expected but actually seem like a better approach, so continue on!

We should try to keep the PR description up to date with a summary of what we've decided on so far (it'll go into commit history, so treat it as such). Just wanted to write that so we can avoid a surprise of work at the end, no need necessarily to do incremental work to get there, I think it's primarily useful for historical reasons.

@anp anp changed the title Hypothesis for improving rustfmt adoption within rustc? Incremental rustfmt adoption Oct 31, 2019
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-31T02:24:30.5993660Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-31T02:24:30.6178154Z ##[command]git config gc.auto 0
2019-10-31T02:24:30.6249888Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-31T02:24:30.6320128Z ##[command]git config --get-all http.proxy
2019-10-31T02:24:30.6447553Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65939/merge:refs/remotes/pull/65939/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@anp anp force-pushed the incremental-rustfmt-rollout branch from 9fdefe3 to d33bd58 Compare November 1, 2019 00:37
@anp
Copy link
Contributor Author

anp commented Nov 1, 2019

In getting this to work, I found that rustfmt hangs on stdin activity if no paths are passed, so I took @Mark-Simulacrum's recommendation to format src/bootstrap as a starter.

@anp anp changed the title Incremental rustfmt adoption Enable incremental rustfmt adoption Nov 2, 2019
anp added a commit to anp/rustfmt that referenced this pull request Nov 2, 2019
@Mark-Simulacrum
Copy link
Member

One thought -- could we split the bootstrap re-formatting into a separate PR which I can r+ immediately? That way we keep the diff line count in this PR down (making it a little easier to review).

I would also like us to try and prepare a (potentially hacky) script that re-formats the repository automatically during rebasing or so with the idea being that a PR that is currently in flight to e.g. bootstrap would not be too hard to rebase atop this. Not sure how easy that is, if it proves pretty much impossible then no need to spend too much time on it.

@anp
Copy link
Contributor Author

anp commented Nov 4, 2019

This makes sense! Another thought: maybe instead of formatting src/bootstrap I should pick an even smaller target like src/build_helper?

@anp
Copy link
Contributor Author

anp commented Nov 4, 2019

Note to self: this PR should probably include or immediately kick off changes to the rustc guide.

@Mark-Simulacrum
Copy link
Member

This makes sense! Another thought: maybe instead of formatting src/bootstrap I should pick an even smaller target like src/build_helper?

Sure, yeah, or maybe even src/libarena -- basically any small and rarely changed crate seems like a fine fit, optimizing a little more for smallness (I had expected src/bootstrap to have a smaller diff, somehow).

@anp anp force-pushed the incremental-rustfmt-rollout branch from 50e8b75 to b1d0cdf Compare November 4, 2019 16:23
@anp
Copy link
Contributor Author

anp commented Nov 4, 2019

I picked librustc_fs_util (it's really tiny!) and pushed it to this branch since it's such a low risk for churn and hopefully doesn't increase review burden. Happy to split it up if you'd like though, lmk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the edition flag move to rustfmt.toml?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these latest commits are very much just testing things -- I wouldn't expect them to stick around.

@Mark-Simulacrum Mark-Simulacrum force-pushed the incremental-rustfmt-rollout branch from 24d7934 to 1b9ac08 Compare December 19, 2019 15:38
@rust-highfive
Copy link
Contributor

The job i686-mingw-1 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-19T15:39:22.1811829Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-19T15:39:22.2826257Z ##[command]git config gc.auto 0
2019-12-19T15:39:22.3429650Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-19T15:39:22.3761156Z ##[command]git config --get-all http.proxy
2019-12-19T15:39:22.4165341Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65939/merge:refs/remotes/pull/65939/merge
---
2019-12-19T15:40:02.8452494Z do so (now or later) by using -b with the checkout command again. Example:
2019-12-19T15:40:02.8452557Z 
2019-12-19T15:40:02.8452614Z   git checkout -b <new-branch-name>
2019-12-19T15:40:02.8452642Z 
2019-12-19T15:40:02.8452731Z HEAD is now at 4370f1d62 Merge 1b9ac0801e6af1f059d138f779affe694a4a3169 into 0de96d37fbcc54978458c18f5067cd9817669bc8
2019-12-19T15:40:02.8960614Z ##[section]Starting: Setup environment
2019-12-19T15:40:02.9060910Z ==============================================================================
2019-12-19T15:40:02.9060966Z Task         : Bash
2019-12-19T15:40:02.9061028Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-12-19T15:40:04.8777773Z BUILD_REQUESTEDFORID=5e5f2016-b710-434c-83b9-9adad28a8d3a
2019-12-19T15:40:04.8778027Z BUILD_SOURCEBRANCH=refs/pull/65939/merge
2019-12-19T15:40:04.8778275Z BUILD_SOURCEBRANCHNAME=merge
2019-12-19T15:40:04.8778469Z BUILD_SOURCESDIRECTORY=D:\a\1\s
2019-12-19T15:40:04.8778714Z BUILD_SOURCEVERSION=4370f1d62f4cabc29dab90a2a1aa90d3b5577a6e
2019-12-19T15:40:04.8778878Z BUILD_SOURCEVERSIONAUTHOR=Adam Perry
2019-12-19T15:40:04.8779200Z CI_JOB_NAME=i686-mingw-1
2019-12-19T15:40:04.8779551Z COBERTURA_HOME=C:\cobertura-2.1.1
2019-12-19T15:40:04.8779661Z COMMONPROGRAMFILES=C:\Program Files\Common Files
2019-12-19T15:40:04.8779723Z COMMON_TESTRESULTSDIRECTORY=D:\a\1\TestResults
---
2019-12-19T15:40:04.8794054Z SYSTEM_PHASEID=27eddb93-7805-576c-c80f-37b2176e40f7
2019-12-19T15:40:04.8794099Z SYSTEM_PHASENAME=Windows
2019-12-19T15:40:04.8794146Z SYSTEM_PIPELINESTARTTIME=2019-12-19 15:39:10+00:00
2019-12-19T15:40:04.8794219Z SYSTEM_PLANID=4e183b42-12ff-4d71-adf0-bdafdc80ac38
2019-12-19T15:40:04.8794307Z SYSTEM_PULLREQUEST_ISFORK=True
2019-12-19T15:40:04.8794355Z SYSTEM_PULLREQUEST_MERGEDAT=
2019-12-19T15:40:04.8794418Z SYSTEM_PULLREQUEST_PULLREQUESTID=333716262
2019-12-19T15:40:04.8794465Z SYSTEM_PULLREQUEST_PULLREQUESTNUMBER=65939
2019-12-19T15:40:04.8794515Z SYSTEM_PULLREQUEST_SOURCEBRANCH=incremental-rustfmt-rollout
2019-12-19T15:40:04.8794586Z SYSTEM_PULLREQUEST_SOURCECOMMITID=1b9ac0801e6af1f059d138f779affe694a4a3169
2019-12-19T15:40:04.8794702Z SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI=***.git
2019-12-19T15:40:04.8794761Z SYSTEM_PULLREQUEST_TARGETBRANCH=master
2019-12-19T15:40:04.8794822Z SYSTEM_RESTRICTSECRETS=True
2019-12-19T15:40:04.8794908Z SYSTEM_STAGEATTEMPT=1
2019-12-19T15:40:04.8794970Z SYSTEM_STAGEDISPLAYNAME=__default
2019-12-19T15:40:04.8795018Z SYSTEM_STAGEID=96ac2280-8cb4-5df5-99de-dd2da759617d
2019-12-19T15:40:04.8795063Z SYSTEM_STAGENAME=__default
---
2019-12-19T15:44:53.6357470Z + modules=($modules)
2019-12-19T15:44:53.6357638Z + use_git=
2019-12-19T15:44:53.6511597Z ++ git config --file .gitmodules --get-regexp '\.url$'
2019-12-19T15:44:53.6588106Z ++ cut '-d ' -f2
2019-12-19T15:44:53.6796926Z + urls='***-installer.git
2019-12-19T15:44:53.6797704Z https://github.com/rust-lang/cargo.git
2019-12-19T15:44:53.6797885Z https://github.com/rust-lang/reference.git
2019-12-19T15:44:53.6798027Z https://github.com/rust-lang/book.git
2019-12-19T15:44:53.6798186Z https://github.com/rust-lang-nursery/rls.git
---
2019-12-19T15:44:54.0506987Z ++ awk '{print $3}'
2019-12-19T15:44:54.0816445Z + commit=4835e025826729827a94fdeb7cb85fed288d08bb
2019-12-19T15:44:54.0840443Z + git rm src/doc/rust-by-example
2019-12-19T15:44:54.1669860Z rm 'src/doc/rust-by-example'
2019-12-19T15:44:54.1717155Z + url=***-by-example.git
2019-12-19T15:44:54.1726412Z + url=***-by-example
2019-12-19T15:44:54.1810584Z + for i in ${!modules[@]}
2019-12-19T15:44:54.1811124Z + module=src/stdarch
2019-12-19T15:44:54.1811337Z + [[  src/llvm-project src/doc/book src/doc/rust-by-example  = *\ \s\r\c\/\s\t\d\a\r\c\h\ * ]]
2019-12-19T15:44:54.1811506Z + use_git=' src/tools/rust-installer src/doc/nomicon src/tools/cargo src/doc/reference src/tools/rls src/tools/clippy src/tools/rustfmt src/tools/miri src/stdarch'
---
2019-12-19T15:44:54.1812796Z + use_git=' src/tools/rust-installer src/doc/nomicon src/tools/cargo src/doc/reference src/tools/rls src/tools/clippy src/tools/rustfmt src/tools/miri src/stdarch src/doc/rustc-guide src/doc/edition-guide'
2019-12-19T15:44:54.1812971Z + for i in ${!modules[@]}
2019-12-19T15:44:54.1813108Z + module=src/llvm-project
2019-12-19T15:44:54.1813269Z + [[  src/llvm-project src/doc/book src/doc/rust-by-example  = *\ \s\r\c\/\l\l\v\m\-\p\r\o\j\e\c\t\ * ]]
2019-12-19T15:44:54.1813484Z + fetch_github_commit_archive src/doc/rust-by-example ***-by-example/archive/4835e025826729827a94fdeb7cb85fed288d08bb.tar.gz
2019-12-19T15:44:54.1814058Z + local cached=download-src-doc-rust-by-example.tar.gz
2019-12-19T15:44:54.1814058Z + local cached=download-src-doc-rust-by-example.tar.gz
2019-12-19T15:44:54.1823680Z + retry sh -c 'rm -f download-src-doc-rust-by-example.tar.gz &&         curl -f -sSL -o download-src-doc-rust-by-example.tar.gz ***-by-example/archive/4835e025826729827a94fdeb7cb85fed288d08bb.tar.gz'
2019-12-19T15:44:54.1823822Z + echo 'Attempting with retry:' sh -c 'rm -f download-src-doc-rust-by-example.tar.gz &&         curl -f -sSL -o download-src-doc-rust-by-example.tar.gz ***-by-example/archive/4835e025826729827a94fdeb7cb85fed288d08bb.tar.gz'
2019-12-19T15:44:54.1823956Z + local max=5
2019-12-19T15:44:54.1824015Z + true
2019-12-19T15:44:54.1824015Z + true
2019-12-19T15:44:54.1824100Z Attempting with retry: sh -c rm -f download-src-doc-rust-by-example.tar.gz &&         curl -f -sSL -o download-src-doc-rust-by-example.tar.gz ***-by-example/archive/4835e025826729827a94fdeb7cb85fed288d08bb.tar.gz
2019-12-19T15:44:54.1824267Z + sh -c 'rm -f download-src-doc-rust-by-example.tar.gz &&         curl -f -sSL -o download-src-doc-rust-by-example.tar.gz ***-by-example/archive/4835e025826729827a94fdeb7cb85fed288d08bb.tar.gz'
2019-12-19T15:44:54.2078415Z ++ awk '{print $3}'
2019-12-19T15:44:54.2368060Z + commit=2cb41005ed5c4747b10d2bf01d8779d3bb4ae32d
2019-12-19T15:44:54.2368485Z + git rm src/llvm-project
2019-12-19T15:44:54.3224578Z rm 'src/llvm-project'
---
2019-12-19T15:44:57.5009004Z Submodule 'src/doc/edition-guide' (https://github.com/rust-lang/edition-guide.git) registered for path 'src/doc/edition-guide'
2019-12-19T15:44:57.5009146Z Submodule 'src/doc/embedded-book' (https://github.com/rust-embedded/book.git) registered for path 'src/doc/embedded-book'
2019-12-19T15:44:57.5009259Z Submodule 'src/doc/nomicon' (https://github.com/rust-lang/nomicon.git) registered for path 'src/doc/nomicon'
2019-12-19T15:44:57.5009324Z Submodule 'src/doc/reference' (https://github.com/rust-lang/reference.git) registered for path 'src/doc/reference'
2019-12-19T15:44:57.5009486Z Submodule 'src/doc/rustc-guide' (***c-guide.git) registered for path 'src/doc/rustc-guide'
2019-12-19T15:44:57.5009642Z Submodule 'src/tools/cargo' (https://github.com/rust-lang/cargo.git) registered for path 'src/tools/cargo'
2019-12-19T15:44:57.5009706Z Submodule 'src/tools/clippy' (https://github.com/rust-lang-nursery/rust-clippy.git) registered for path 'src/tools/clippy'
2019-12-19T15:44:57.5009784Z Submodule 'src/tools/miri' (https://github.com/rust-lang/miri.git) registered for path 'src/tools/miri'
2019-12-19T15:44:57.5009852Z Submodule 'src/tools/rls' (https://github.com/rust-lang-nursery/rls.git) registered for path 'src/tools/rls'
2019-12-19T15:44:57.5009852Z Submodule 'src/tools/rls' (https://github.com/rust-lang-nursery/rls.git) registered for path 'src/tools/rls'
2019-12-19T15:44:57.5009946Z Submodule 'src/rust-installer' (***-installer.git) registered for path 'src/tools/rust-installer'
2019-12-19T15:44:57.6033474Z Cloning into 'D:/a/1/s/src/doc/edition-guide'...
2019-12-19T15:45:09.2476732Z Cloning into 'D:/a/1/s/src/doc/nomicon'...
2019-12-19T15:45:09.2477215Z Cloning into 'D:/a/1/s/src/doc/embedded-book'...
2019-12-19T15:45:09.2477433Z Cloning into 'D:/a/1/s/src/doc/rustc-guide'...
---
2019-12-19T15:46:08.7195498Z file:.git/config submodule.src/doc/nomicon.url=https://github.com/rust-lang/nomicon.git
2019-12-19T15:46:08.7195552Z file:.git/config submodule.src/doc/reference.active=true
2019-12-19T15:46:08.7195608Z file:.git/config submodule.src/doc/reference.url=https://github.com/rust-lang/reference.git
2019-12-19T15:46:08.7196964Z file:.git/config submodule.src/doc/rustc-guide.active=true
2019-12-19T15:46:08.7197169Z file:.git/config submodule.src/doc/rustc-guide.url=***c-guide.git
2019-12-19T15:46:08.7197306Z file:.git/config submodule.src/stdarch.url=https://github.com/rust-lang/stdarch.git
2019-12-19T15:46:08.7197373Z file:.git/config submodule.src/tools/cargo.active=true
2019-12-19T15:46:08.7197427Z file:.git/config submodule.src/tools/cargo.url=https://github.com/rust-lang/cargo.git
2019-12-19T15:46:08.7197500Z file:.git/config submodule.src/tools/clippy.active=true
2019-12-19T15:46:08.7197500Z file:.git/config submodule.src/tools/clippy.active=true
2019-12-19T15:46:08.7197557Z file:.git/config submodule.src/tools/clippy.url=https://github.com/rust-lang-nursery/rust-clippy.git
2019-12-19T15:46:08.7197611Z file:.git/config submodule.src/tools/miri.active=true
2019-12-19T15:46:08.7197686Z file:.git/config submodule.src/tools/miri.url=https://github.com/rust-lang/miri.git
2019-12-19T15:46:08.7197744Z file:.git/config submodule.src/tools/rls.active=true
2019-12-19T15:46:08.7197799Z file:.git/config submodule.src/tools/rls.url=https://github.com/rust-lang-nursery/rls.git
2019-12-19T15:46:08.7197873Z file:.git/config submodule.src/rust-installer.active=true
2019-12-19T15:46:08.7197944Z file:.git/config submodule.src/rust-installer.url=***-installer.git
2019-12-19T15:46:08.7198189Z file:.git/config submodule.src/tools/rustfmt.url=https://github.com/rust-lang-nursery/rustfmt.git
2019-12-19T15:46:08.7554461Z      DOS    UNIX     MAC  BOM       TXTBIN  FILE
2019-12-19T15:46:08.7556453Z        0    5264       0  no_bom    text    Cargo.lock
2019-12-19T15:46:08.7556769Z        0     987       0  no_bom    text    src/tools/rust-installer/install-template.sh

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Mark-Simulacrum
Copy link
Member

This PR is tentatively blocked on rust-lang/rustfmt#3930 at this point unless someone comes up with a scheme to avoid that. I think it might be possible to do something like filtering based on the ignore list ourselves and running rustfmt with --skip-children ourselves on the relevant files, which I'm going to try and experiment with today or tomorrow, but if it gets pretty complex then it might be that for now we just punt on rustfmt in this repository :/

@anp
Copy link
Contributor Author

anp commented Dec 20, 2019

Oh my! Well that’s a fun discovery. Thank you for your thoroughness while I’m in between desk setups <3.

@Mark-Simulacrum Mark-Simulacrum force-pushed the incremental-rustfmt-rollout branch 2 times, most recently from e3948a3 to a8b794e Compare December 21, 2019 15:46
@Mark-Simulacrum
Copy link
Member

Okay, I've manually implemented scanning src and filtering based on rustfmt.toml, running rustfmt with --skip-children on each .rs file. This seems to work well.

I've dropped the mingw CI builder and rebased to drop all of the debugging commits out.

I believe this is ready to land, so I'm going to approve it and try to get it in fairly quickly so that we can then land a fairly large reformatting (to be generated and approved by well-known contributors).

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 21, 2019

📌 Commit a8b794efbb251928f6310bcf27d4fa77bec57ba5 has been approved by Mark-Simulacrum

@bors bors removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Dec 21, 2019
anp and others added 6 commits December 21, 2019 20:23
Co-Authored-By: Mark Rousskov <mark.simulacrum@gmail.com>
Co-Authored-By: Mark Rousskov <mark.simulacrum@gmail.com>
In total it's about 100 lines of code and has received less than 5 commits in 2019 -- a good starting point.
This replaces cargo-fmt with rustfmt with --skip-children which should
allow us to format code without running into rust-lang/rustfmt#3930.

This also bumps up the version of rustfmt used to a more recent one.
@Mark-Simulacrum
Copy link
Member

Rebased. @bors r+

@bors
Copy link
Collaborator

bors commented Dec 22, 2019

📌 Commit dddd872 has been approved by Mark-Simulacrum

@Centril
Copy link
Contributor

Centril commented Dec 22, 2019

@bors p=210

@bors
Copy link
Collaborator

bors commented Dec 22, 2019

⌛ Testing commit dddd872 with merge 242f3d774c05dca236a07e1564720a37ef6a7c31...

@rust-highfive
Copy link
Contributor

The job x86_64-gnu-distcheck of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-22T03:39:51.5560941Z    Compiling toml v0.5.3
2019-12-22T03:39:51.9217012Z    Compiling serde_json v1.0.40
2019-12-22T03:39:55.1377441Z    Compiling bootstrap v0.0.0 (/checkout/obj/build/tmp/distcheck/src/bootstrap)
2019-12-22T03:40:30.4746169Z     Finished dev [unoptimized] target(s) in 1m 23s
2019-12-22T03:40:32.2588099Z thread 'main' panicked at 'std::fs::read_to_string(build.src.join("rustfmt.toml")) failed with No such file or directory (os error 2)', src/bootstrap/format.rs:41:26
2019-12-22T03:40:32.2589770Z failed to run: /checkout/obj/build/tmp/distcheck/build/bootstrap/debug/bootstrap test
2019-12-22T03:40:32.2595711Z Build completed unsuccessfully in 0:01:42
2019-12-22T03:40:32.2596666Z make: *** [check] Error 1
2019-12-22T03:40:32.2596666Z make: *** [check] Error 1
2019-12-22T03:40:32.2597274Z Makefile:48: recipe for target 'check' failed
2019-12-22T03:40:32.2597636Z 
2019-12-22T03:40:32.2597800Z command did not execute successfully: "make" "make" "check"
2019-12-22T03:40:32.2597990Z expected success, got: exit code: 2
2019-12-22T03:40:32.2598122Z 
---
2019-12-22T03:40:32.2599943Z   local time: Sun Dec 22 03:40:31 UTC 2019
2019-12-22T03:40:32.2600168Z   network time: Sun, 22 Dec 2019 03:40:31 GMT
2019-12-22T03:40:32.2600348Z == end clock drift check ==
2019-12-22T03:40:41.8523626Z 
2019-12-22T03:40:41.8642821Z ##[error]Bash exited with code '1'.
2019-12-22T03:40:41.8687929Z ##[section]Starting: Checkout
2019-12-22T03:40:41.8690554Z ==============================================================================
2019-12-22T03:40:41.8690667Z Task         : Get sources
2019-12-22T03:40:41.8690751Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Collaborator

bors commented Dec 22, 2019

💔 Test failed - checks-azure

distcheck (and generally publishing tarballs) will not package
rustfmt.toml and we for now still support running tidy etc in those
tarballs.
@Mark-Simulacrum
Copy link
Member

@bors r+

Fixed distcheck -- if we don't find rustfmt.toml we'll just bail out of formatting.

@bors
Copy link
Collaborator

bors commented Dec 22, 2019

📌 Commit b9e4174 has been approved by Mark-Simulacrum

@bors
Copy link
Collaborator

bors commented Dec 22, 2019

⌛ Testing commit b9e4174 with merge 0d2817a...

@bors
Copy link
Collaborator

bors commented Dec 22, 2019

☀️ Test successful - checks-azure
Approved by: Mark-Simulacrum
Pushing 0d2817a to master...

Comment on lines +26 to +27
let status = cmd.status().expect("executing rustfmt");
assert!(status.success(), "running {} successful", cmd_debug);
Copy link
Member

@eddyb eddyb Mar 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One rustfmt --check failure should not prevent running rustfmt --check on other files, otherwise you only get one error at a time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When that bit was originally written we were running rustfmt once for the whole repository and it showed all errors. Is that no longer how it's running?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like @Mark-Simulacrum pushed commits to this PR to run rustfmt on individual files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha - maybe file a bug so someone can pick up a fix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, rustfmt on the whole repository was leading to errors in rustfmt (IIRC, it had some problems with ignoring files or so, I don't recall the specifics now).

This should be fixable though, like we do in tidy etc by keeping track of whether we errored and only stopping at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.