baoyachi / shadow-rs

A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
https://docs.rs/shadow-rs
MIT License
447 stars 41 forks source link

indexing may cause panic #88

Closed Chronophylos closed 2 years ago

Chronophylos commented 2 years ago

When using version 0.11 clippy raises an error. See indexing_slicing.

This can be reproduced by running cargo clippy -- -D clippy::indexing_slicing.

Error Details ``` error: indexing may panic --> [...]/target/debug/build/[...]-7348521971c93af5/out/shadow.rs:740:36 | 740 | pub const CLAP_LONG_VERSION:&str = shadow_rs::formatcp!(r#"{} | ____________________________________^ 741 | | branch:{} 742 | | commit_hash:{} 743 | | build_time:{} 744 | | build_env:{},{}"#,PKG_VERSION, BRANCH, SHORT_COMMIT, BUILD_TIME, RUST_VERSION, RUST_CHANNEL 745 | | ); | |_^ | = help: consider using `.get(n)` or `.get_mut(n)` instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing = note: this error originates in the macro `__write_pvariant` (in Nightly builds, run with -Z macro-backtrace for more info) ```
baoyachi commented 2 years ago

Thank you, It's bug, caused by with new cargo-clippy version

I will fix with new version.

baoyachi commented 2 years ago

I will add cargo clippy -- -D clippy::indexing_slicing into github action

...
...
...

      # build on nightly
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          override: true
      - name: Build on nightly
        run: cargo build --release
      - name: Check with clippy indexing_slicing
        run: cargo clippy -- -D clippy::indexing_slicing
baoyachi commented 2 years ago

fix https://github.com/baoyachi/shadow-rs/pull/94