Which crate to use `rustfmt` or `rustfmt-nightly`

I am trying to use rustfmt APIs inside my code to format my generated rust code from within a library.

It seems that the rustfmt crate is deprecated, but one is recommended to use the rustfmt-nightly crate. The issue is as follows -

with rustfmt crate, I can build the code fine on the stable channel. But I cannot build the code on nightly due to an error - that appears due to transitive dependency of rustfmt (See below) -

Error -

   Compiling extprim v1.7.1
error[E0557]: feature has been removed
  --> /home/gabhijit/.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.1/src/lib.rs:58:81
   |
58 | #![cfg_attr(extprim_channel="unstable", feature(llvm_asm, test, specialization, const_fn))]
   |                                                                                 ^^^^^^^^ feature has been removed
   |
   = note: split into finer-grained feature gates

My toolchains are as follows -

$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/gabhijit/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
1.48.0-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

riscv64gc-unknown-none-elf
thumbv7em-none-eabihf
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.54.0-nightly (ed597e7e1 2021-06-08)

Since I am building some derive macros, I would like to be able to build on nightly as well.

If I instead use rustfmt-nightly even from the git repo, Some or other package croaks with the same error as above. I have tried different tags v1.4.21 (latest released crate version) v1.4.36 (latest released version), master. All of them have the issues.

Any suggestions?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.