rust-lang / docker-rust

The official Docker images for Rust
441 stars 90 forks source link

Provide rustfmt by default #16

Closed otavio closed 6 years ago

otavio commented 6 years ago

It is convenient to have the rustfmt already installed so we avoid getting it every time we build.

If agreed, I can prepare a pull request to include it.

sfackler commented 6 years ago

I think the right way to do this is to pick it up via rustup. It should land in the standard distribution in the next release or two.

otavio commented 6 years ago

Don't you think, until it is included, we could add it so people is stimulated to use it?

sfackler commented 6 years ago

Which version would they use? The rustfmt cargo package is pretty out of date IIRC, and rustfmt-nightly wouldn't work since the image has a stable toolchain.

otavio commented 6 years ago

The rustfmt-nightly does work with 1.22.1 toolchain. I am using it.

sfackler commented 6 years ago
$ docker run --rm rust:1.22.1 cargo install rustfmt-nightly
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading rustfmt-nightly v0.3.1
  Installing rustfmt-nightly v0.3.1
 Downloading regex v0.2.3
 Downloading serde v1.0.24
 Downloading serde_derive v1.0.24
 Downloading unicode-segmentation v1.2.0
 Downloading derive-new v0.5.0
 Downloading getopts v0.2.15
 Downloading diff v0.1.11
 Downloading env_logger v0.4.3
 Downloading cargo_metadata v0.3.3
 Downloading log v0.3.8
 Downloading toml v0.4.5
 Downloading serde_json v1.0.8
 Downloading term v0.4.6
 Downloading aho-corasick v0.6.4
 Downloading regex-syntax v0.4.1
 Downloading memchr v2.0.1
 Downloading thread_local v0.3.5
 Downloading utf8-ranges v1.0.0
 Downloading libc v0.2.34
 Downloading lazy_static v1.0.0
 Downloading unreachable v1.0.0
 Downloading void v1.0.2
 Downloading serde_derive_internals v0.18.0
 Downloading syn v0.11.11
 Downloading quote v0.3.15
 Downloading synom v0.11.3
 Downloading unicode-xid v0.0.4
 Downloading semver v0.8.0
 Downloading error-chain v0.11.0
 Downloading num-traits v0.1.41
 Downloading itoa v0.3.4
 Downloading dtoa v0.4.2
 Downloading semver-parser v0.7.0
 Downloading backtrace v0.3.4
 Downloading rustc-demangle v0.1.5
 Downloading cfg-if v0.1.2
 Downloading backtrace-sys v0.1.16
 Downloading cc v1.0.3
   Compiling libc v0.2.34
   Compiling itoa v0.3.4
   Compiling num-traits v0.1.41
   Compiling cfg-if v0.1.2
   Compiling serde v1.0.24
   Compiling rustfmt-nightly v0.3.1
   Compiling unicode-segmentation v1.2.0
   Compiling lazy_static v1.0.0
   Compiling semver-parser v0.7.0
   Compiling unicode-xid v0.0.4
   Compiling quote v0.3.15
   Compiling dtoa v0.4.2
   Compiling regex-syntax v0.4.1
   Compiling log v0.3.8
   Compiling rustc-demangle v0.1.5
   Compiling cc v1.0.3
   Compiling diff v0.1.11
   Compiling term v0.4.6
   Compiling void v1.0.2
   Compiling getopts v0.2.15
   Compiling utf8-ranges v1.0.0
   Compiling memchr v2.0.1
   Compiling synom v0.11.3
   Compiling toml v0.4.5
   Compiling semver v0.8.0
   Compiling serde_json v1.0.8
   Compiling unreachable v1.0.0
   Compiling backtrace-sys v0.1.16
   Compiling aho-corasick v0.6.4
   Compiling syn v0.11.11
   Compiling thread_local v0.3.5
   Compiling regex v0.2.3
   Compiling backtrace v0.3.4
   Compiling error-chain v0.11.0
   Compiling env_logger v0.4.3
   Compiling serde_derive_internals v0.18.0
   Compiling derive-new v0.5.0
   Compiling serde_derive v1.0.24
   Compiling cargo_metadata v0.3.3
error[E0432]: unresolved import `syntax::ast::CrateSugar`
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/utils.rs:14:36
   |
14 | use syntax::ast::{self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem,
   |                                    ^^^^^^^^^^ no `CrateSugar` in `ast`

error[E0432]: unresolved import `syntax::ast::CrateSugar`
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/items.rs:17:19
   |
17 | use syntax::ast::{CrateSugar, ImplItem};
   |                   ^^^^^^^^^^ no `CrateSugar` in `ast`

error[E0432]: unresolved import `ast::UseTreeKind`
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:43:14
   |
43 |     use ast::UseTreeKind::*;
   |              ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0416]: identifier `Glob` is bound more than once in the same pattern
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:83:18
   |
83 |         (&Glob, &Glob) => Ordering::Equal,
   |                  ^^^^ used in a pattern more than once

error[E0408]: variable `Glob` is not bound in all patterns
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:84:9
   |
84 |         (&Simple(_), _) | (&Glob, &Nested(_)) => Ordering::Less,
   |         ^^^^^^^^^^^^^^^     ---- variable not in all patterns
   |         |
   |         pattern doesn't bind `Glob`

error[E0408]: variable `Glob` is not bound in all patterns
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:104:31
    |
104 |         (&Glob, &Simple(_)) | (&Nested(_), _) => Ordering::Greater,
    |           ----                ^^^^^^^^^^^^^^^ pattern doesn't bind `Glob`
    |           |
    |           variable not in all patterns

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:138:18
    |
138 |             ast::UseTreeKind::Nested(ref items) => {
    |                  ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:141:18
    |
141 |             ast::UseTreeKind::Glob => {
    |                  ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:151:18
    |
151 |             ast::UseTreeKind::Simple(ident) => {
    |                  ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:180:14
    |
180 |         ast::UseTreeKind::Nested(ref items) => match items.len() {
    |              ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:325:14
    |
325 |         ast::UseTreeKind::Simple(rename) => {
    |              ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:350:14
    |
350 |         ast::UseTreeKind::Glob | ast::UseTreeKind::Nested(..) => {
    |              ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0433]: failed to resolve. Could not find `UseTreeKind` in `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:350:39
    |
350 |         ast::UseTreeKind::Glob | ast::UseTreeKind::Nested(..) => {
    |                                       ^^^^^^^^^^^ Could not find `UseTreeKind` in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:42:31
   |
42 | fn compare_use_trees(a: &ast::UseTree, b: &ast::UseTree, nested: bool) -> Ordering {
   |                               ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:42:49
   |
42 | fn compare_use_trees(a: &ast::UseTree, b: &ast::UseTree, nested: bool) -> Ordering {
   |                                                 ^^^^^^^ not found in `ast`

error[E0531]: cannot find tuple struct/variant `Simple` in this scope
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:55:11
   |
55 |         (&Simple(ident_a), &Simple(ident_b)) => {
   |           ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Simple` in this scope
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:55:29
   |
55 |         (&Simple(ident_a), &Simple(ident_b)) => {
   |                             ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Simple` in this scope
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:84:11
   |
84 |         (&Simple(_), _) | (&Glob, &Nested(_)) => Ordering::Less,
   |           ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Nested` in this scope
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:84:36
   |
84 |         (&Simple(_), _) | (&Glob, &Nested(_)) => Ordering::Less,
   |                                    ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Nested` in this scope
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:85:11
   |
85 |         (&Nested(ref a_items), &Nested(ref b_items)) => {
   |           ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Nested` in this scope
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:85:33
   |
85 |         (&Nested(ref a_items), &Nested(ref b_items)) => {
   |                                 ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Simple` in this scope
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:104:18
    |
104 |         (&Glob, &Simple(_)) | (&Nested(_), _) => Ordering::Greater,
    |                  ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct/variant `Nested` in this scope
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:104:33
    |
104 |         (&Glob, &Simple(_)) | (&Nested(_), _) => Ordering::Greater,
    |                                 ^^^^^^ not found in this scope

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:135:23
    |
135 | impl Rewrite for ast::UseTree {
    |                       ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:174:33
    |
174 | fn is_unused_import(tree: &ast::UseTree, attrs: &[ast::Attribute]) -> bool {
    |                                 ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:178:39
    |
178 | fn is_unused_import_inner(tree: &ast::UseTree) -> bool {
    |                                       ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:193:17
    |
193 |     tree: &ast::UseTree,
    |                 ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:290:67
    |
290 |     pub fn format_import(&mut self, item: &ast::Item, tree: &ast::UseTree) {
    |                                                                   ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:321:17
    |
321 |     tree: &ast::UseTree,
    |                 ^^^^^^^ not found in `ast`

error[E0412]: cannot find type `UseTree` in module `ast`
   --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/imports.rs:436:20
    |
436 |     trees: &[(ast::UseTree, ast::NodeId)],
    |                    ^^^^^^^ not found in `ast`

error[E0554]: #![feature] may not be used on the stable release channel
  --> usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rustfmt-nightly-0.3.1/src/lib.rs:11:1
   |
11 | #![feature(rustc_private)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 31 previous errors

error: failed to compile `rustfmt-nightly v0.3.1`, intermediate artifacts can be found at `/tmp/cargo-install.hONZulnc7n4C`

Caused by:
  Could not compile `rustfmt-nightly`.

To learn more, run the command again with --verbose.
otavio commented 6 years ago

@sfackler sorry for this. I did the test using the nightly by mistake.

As it seems it eventually will be included through the rustup, we can close this right?

sfackler commented 6 years ago

Yep!