Coder Social home page Coder Social logo

dprint-plugin-rustfmt's Introduction

dprint

CI Homebrew

Monorepo for dprint—a pluggable and configurable code formatting platform.

Links

Plugins

Notes

This repo is under active early development.

  1. The interface between the CLI and plugins might change often. You may need to keep updating to the latest version of both the CLI and plugins (the CLI will let you know what to do).
    • An upgrade path will be outlined in the release notes when this occurs.
  2. I do a lot of this development in my spare time. Please consider sponsoring if you are a commercial company using this.

dprint-plugin-rustfmt's People

Contributors

dsherret avatar thomaseizinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dprint-plugin-rustfmt's Issues

Automated releases

The releases should be automated based on the nightly version and the latest stable release version should be set as the "latest" plugin in plugins.dprint.dev/info.json

Occasional panic formatting

I sometimes get an error that looks like this in the CLI:

[dprint-plugin-rustfmt]
error: expected item, found keyword `let`
 --> <stdin>:1:1
  |
1 | let result = dprint_core::formatting::format(|| {
  | ^^^ expected item

thread 'main' panicked at 'range start index 8 out of range for slice of length 0', src\format.rs:18:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: expected item, found keyword `let`
 --> <stdin>:3:1
  |
3 | let parent_process_id = ...; // parse this from the `--parent-pid` command line argument
  | ^^^ expected item

thread 'main' panicked at 'range start index 8 out of range for slice of length 0', src\format.rs:18:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: expected item, found keyword `let`
 --> <stdin>:1:1
  |
1 | let result = dprint_core::formatting::format(|| {
  | ^^^ expected item

thread 'main' panicked at 'range start index 8 out of range for slice of length 0', src\format.rs:18:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: expected item, found keyword `let`
 --> <stdin>:3:1
  |
3 | let parent_process_id = ...; // parse this from the `--parent-pid` command line argument
  | ^^^ expected item

thread 'main' panicked at 'range start index 8 out of range for slice of length 0', src\format.rs:18:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: expected one of `!` or `::`, found `(`
 --> <stdin>:1:30
  |
1 | handle_process_stdio_messages(MyPluginHandler::new())
  |                              ^ expected one of `!` or `::`

thread 'main' panicked at 'range start index 8 out of range for slice of length 0', src\format.rs:18:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The error goes away when I run it again. It might have to do with the <stdin>:x:x thing.

Error when calling invoke: A `unreachable` trap was thrown at code offset 3612991

Version: 0.9.1

First, thanks for making dprint! I am super excited to start using it to a) unify tools for formatting and b) finally get rid of prettier which is awfully slow!

Now, I tried using it on our current project and unfortunately, received this error:

Error formatting /home/thomas/src/github.com/comit-network/comit-rs/nectar/src/database.rs. Message: Error when calling invoke: A unreachable trap was thrown at code offset 3612991

This is the offending file: https://raw.githubusercontent.com/comit-network/comit-rs/95dcccfdcb319e452c5866e70b66a75ea48e254a/nectar/src/database.rs

Hopefully that helps!

Adopt rustfmt versioning

For now because this is now, it will just use 0.x versioning, but once stabilized it should match rustfmt's versioning and bump the patch version for any fixes.

Compile errors when building 0.4.0

I was trying to compile this plugin in order to help resolve dprint/dprint#409 but compilation failed.

   Compiling cargo_metadata v0.8.2
     Running `rustc --crate-name cargo_metadata /home/rishflab/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo_metadata-0.8.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' -C metadata=d968fcedfcbd54b1 -C extra-filename=-d968fcedfcbd54b1 --out-dir /home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps -L dependency=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps --extern semver=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libsemver-f7536294878aa226.rmeta --extern serde=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libserde-596361274aa9d55a.rmeta --extern serde_derive=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps/libserde_derive-4951c2f7191e6604.so --extern serde_json=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libserde_json-6167f5ede36f440b.rmeta --cap-lints allow`
     Running `rustc --crate-name rustfmt_nightly --edition=2018 /home/rishflab/.cargo/git/checkouts/rustfmt-c4b65366788d3254/129c888/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="cargo-fmt"' --cfg 'feature="default"' --cfg 'feature="rustfmt-format-diff"' -C metadata=d6ee6c195b970233 -C extra-filename=-d6ee6c195b970233 --out-dir /home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps -L dependency=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps --extern annotate_snippets=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libannotate_snippets-c92b79408f0600e9.rmeta --extern anyhow=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libanyhow-101a732f15831f18.rmeta --extern bytecount=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libbytecount-c9ef821899239c91.rmeta --extern cargo_metadata=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libcargo_metadata-d968fcedfcbd54b1.rmeta --extern derive_new=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps/libderive_new-fc3c5c9fc137cb6c.so --extern diff=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libdiff-3377d3aad505ccd7.rmeta --extern dirs=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libdirs-4f67ea63a3126779.rmeta --extern env_logger=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libenv_logger-2cede2fd4135419e.rmeta --extern getopts=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libgetopts-848c5087eb088b76.rmeta --extern ignore=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libignore-8a1282242b63696f.rmeta --extern itertools=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libitertools-0532b425598748cd.rmeta --extern lazy_static=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/liblazy_static-dc505f6b51090c17.rmeta --extern log=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/liblog-f89072dff55fef5a.rmeta --extern regex=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libregex-dde5f988033996b8.rmeta --extern rustc_workspace_hack=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/librustc_workspace_hack-dbb7d9fb6d938fc8.rmeta --extern rustfmt_config_proc_macro=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps/librustfmt_config_proc_macro-cbd058a62e07c989.so --extern serde=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libserde-596361274aa9d55a.rmeta --extern serde_json=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libserde_json-6167f5ede36f440b.rmeta --extern structopt=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libstructopt-627ff929530a0ed2.rmeta --extern term=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libterm-2d22f5c3efe7c2ad.rmeta --extern thiserror=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libthiserror-7312a45965ecbb1b.rmeta --extern toml=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libtoml-c58bb194ddf37f8e.rmeta --extern unicode_segmentation=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libunicode_segmentation-63227aa007118084.rmeta --extern unicode_width=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libunicode_width-dd37efb992b30009.rmeta --extern unicode_categories=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libunicode_categories-fa1780c05dcbb100.rmeta --cap-lints allow`
error[E0463]: can't find crate for `rustc_ast`
  --> /home/rishflab/.cargo/git/checkouts/rustfmt-c4b65366788d3254/129c888/src/lib.rs:14:1
   |
14 | extern crate rustc_ast;
   | ^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `rustfmt-nightly`

Caused by:
  process didn't exit successfully: `rustc --crate-name rustfmt_nightly --edition=2018 /home/rishflab/.cargo/git/checkouts/rustfmt-c4b65366788d3254/129c888/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="cargo-fmt"' --cfg 'feature="default"' --cfg 'feature="rustfmt-format-diff"' -C metadata=d6ee6c195b970233 -C extra-filename=-d6ee6c195b970233 --out-dir /home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps -L dependency=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps --extern annotate_snippets=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libannotate_snippets-c92b79408f0600e9.rmeta --extern anyhow=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libanyhow-101a732f15831f18.rmeta --extern bytecount=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libbytecount-c9ef821899239c91.rmeta --extern cargo_metadata=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libcargo_metadata-d968fcedfcbd54b1.rmeta --extern derive_new=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps/libderive_new-fc3c5c9fc137cb6c.so --extern diff=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libdiff-3377d3aad505ccd7.rmeta --extern dirs=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libdirs-4f67ea63a3126779.rmeta --extern env_logger=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libenv_logger-2cede2fd4135419e.rmeta --extern getopts=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libgetopts-848c5087eb088b76.rmeta --extern ignore=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libignore-8a1282242b63696f.rmeta --extern itertools=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libitertools-0532b425598748cd.rmeta --extern lazy_static=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/liblazy_static-dc505f6b51090c17.rmeta --extern log=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/liblog-f89072dff55fef5a.rmeta --extern regex=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libregex-dde5f988033996b8.rmeta --extern rustc_workspace_hack=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/librustc_workspace_hack-dbb7d9fb6d938fc8.rmeta --extern rustfmt_config_proc_macro=/home/rishflab/dprint/dprint-plugin-rustfmt/target/release/deps/librustfmt_config_proc_macro-cbd058a62e07c989.so --extern serde=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libserde-596361274aa9d55a.rmeta --extern serde_json=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libserde_json-6167f5ede36f440b.rmeta --extern structopt=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libstructopt-627ff929530a0ed2.rmeta --extern term=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libterm-2d22f5c3efe7c2ad.rmeta --extern thiserror=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libthiserror-7312a45965ecbb1b.rmeta --extern toml=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libtoml-c58bb194ddf37f8e.rmeta --extern unicode_segmentation=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libunicode_segmentation-63227aa007118084.rmeta --extern unicode_width=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libunicode_width-dd37efb992b30009.rmeta --extern unicode_categories=/home/rishflab/dprint/dprint-plugin-rustfmt/target/wasm32-unknown-unknown/release/deps/libunicode_categories-fa1780c05dcbb100.rmeta --cap-lints allow` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.