]> git.lizzy.rs Git - rust.git/commit
Merge #7055
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Thu, 31 Dec 2020 11:21:23 +0000 (11:21 +0000)
committerGitHub <noreply@github.com>
Thu, 31 Dec 2020 11:21:23 +0000 (11:21 +0000)
commit53e2cdf18e155ad61262fed5dcd3d73ef343c042
tree8414439a6141133dd2eb68ffd94f0ede306870f3
parent558206f70e418730967fd690f5f219993de071bc
parent5ce420ac8487d991ead53f51ae2d45ef33d4f94e
Merge #7055

7055: Install rustfmt if needed during formatting request r=matklad a=kinnison

In order to fix #6052 and to fix #4249 this PR installs `rustfmt` using `rustup` if `rustfmt --help` fails.

In theory we ought to memoise the attempts (both the `--help` and the installation) so that we don't keep retrying something which will fail (e.g. if nightly is missing rustfmt), but this is a first-pass for opinions.

In order to make it possible to notify the user of what happened, I added a facility for `GlobalStateSnapshot` to send *messages* to the client indicating what happened.  There may be a cleaner way to do this as well but I wasn't sure exactly what might be best given this is my first time in this codebase.

It may be worth, longer term, working with `rustup` to provide a way to detect a missing component binary since `rustup` returns `1` if `rustfmt` is not installed, which is not ideal.

Co-authored-by: Daniel Silverstone <dsilvers@digital-scurf.org>