tokei icon indicating copy to clipboard operation
tokei copied to clipboard

[Bug] Failed to output json.

Open Adamska1008 opened this issue 5 months ago • 1 comments

Environment

Version

>= v13.0.0-alpha.2

OS

wsl

Description

when running cargo run -- --output json, it shows:

thread 'main' panicked at src/cli.rs:296:30:
Mismatch between definition and access of `output`. Could not downcast to tokei::input::Format, need to downcast to alloc::string::String

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps to Reproduce

checkout

git checkout v13.0.0-alpha.2 # or any tags later

run

cargo run -- --output json

Additional Info

I can see some warnings at compiling

warning: `/home/adamska/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
warning: `/home/adamska/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:24:23
    |
24  |                   #[cfg(feature = $feature)] extern crate $krate;
    |                         ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: `#[warn(unexpected_cfgs)]` on by default
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:36:23
    |
36  |                   #[cfg(feature = $feature)] $variant
    |                         ^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:36:23
    |
36  |                   #[cfg(feature = $feature)] $variant
    |                         ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:46:31
    |
46  |                           #[cfg(feature = $feature)] stringify!($name)
    |                                 ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:66:35
    |
66  |                           #[cfg(not(feature = $feature))] stringify!($name)
    |                                     ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:82:27
    |
82  |                       #[cfg(feature = $feature)]
    |                             ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:105:31
    |
105 |                           #[cfg(feature = $feature)] Format::$variant => {
    |                                 ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:122:35
    |
122 |                               #[cfg(feature = $feature)]
    |                                     ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unexpected `cfg` condition value: `json`
   --> src/input.rs:125:39
    |
125 |                               #[cfg(not(feature = $feature))]
    |                                         ^^^^^^^^^^^^^^^^^^
...
149 | / supported_formats!(
150 | |     (cbor, "cbor", Cbor [serde_cbor, hex]) =>
151 | |         |input| {
152 | |             hex::FromHex::from_hex(input)
...   |
164 | |         serde_yaml::to_string,
165 | | );
    | |_- in this macro invocation
    |
    = note: expected values for `feature` are: `all`, `cbor`, `default`, `yaml`
    = help: consider adding `json` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
    = note: this warning originates in the macro `supported_formats` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `tokei` (bin "tokei") generated 9 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s

I guess it's related to the issue but don't know how to handle it.

Adamska1008 avatar Sep 21 '24 16:09 Adamska1008