Rust-clippy: cargo-clippy compile-errors on chrono 0.4.2

Created on 14 May 2018  路  11Comments  路  Source: rust-lang/rust-clippy

chrono

D:\Christopher\Documents\Code\Rust\chrono>cargo clean

D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly --version
cargo 1.27.0-nightly (9e53ac6e6 2018-05-07)

D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly clippy --version
0.0.200

D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly check
   Compiling winapi v0.3.4
   Compiling num-traits v0.2.4
   Compiling num-integer v0.1.38
    Checking libc v0.2.40
    Checking time v0.1.40
    Checking chrono v0.4.2 (file:///D:/Christopher/Documents/Code/Rust/chrono)
    Finished dev [unoptimized + debuginfo] target(s) in 6.14s

D:\Christopher\Documents\Code\Rust\chrono>cargo clean

D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly clippy
   Compiling winapi v0.3.4
   Compiling num-traits v0.2.4
   Compiling num-integer v0.1.38
    Checking libc v0.2.40
    Checking time v0.1.40
    Checking chrono v0.4.2 (file:///D:/Christopher/Documents/Code/Rust/chrono)
error[E0277]: the trait bound `Tz2: offset::TimeZone` is not satisfied
  --> src\date.rs:44:5
   |
44 |     offset: Tz::Offset,
   |     ^^^^^^^^^^^^^^^^^^ the trait `offset::TimeZone` is not implemented for `Tz2`
   |
   = help: consider adding a `where Tz2: offset::TimeZone` bound

error[E0277]: the trait bound `Tz2: offset::TimeZone` is not satisfied
  --> src\datetime.rs:60:5
   |
60 |     offset: Tz::Offset,
   |     ^^^^^^^^^^^^^^^^^^ the trait `offset::TimeZone` is not implemented for `Tz2`
   |
   = help: consider adding a `where Tz2: offset::TimeZone` bound

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `chrono`.

To learn more, run the command again with --verbose.

I have no idea what even could be causing this. Additionally, it doesn't seem to be happening on Travis, so it may be Windows-only (or I just could've gotten lucky with the version of rustc+clippy that my CI is pinned to).

L-crash

Most helpful comment

I think I've hit upon this same issue when trying to run clippy against gfx. This is a minimal example I put together that seems to be the same bug:
https://gist.github.com/AIOOB/a09909c52a1b52b46b7c955c102dcdfb
This compiles fine with cargo build but cargo clippy gives:

error[E0277]: the trait bound `T: Foo` is not satisfied
 --> src/lib.rs:6:5
  |
6 |     bar: T::Bar,
  |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
  |
  = help: consider adding a `where T: Foo` bound

All 11 comments

O_o that's very weird indeed. Can you run with RUSTFLAG=-Ztreat-err-as-bug and report the backtrace?

D:\Christopher\Documents\Code\Rust\chrono>set RUSTFLAGS=-Ztreat-err-as-bug

D:\Christopher\Documents\Code\Rust\chrono>echo %RUSTFLAGS%
-Ztreat-err-as-bug

D:\Christopher\Documents\Code\Rust\chrono>cargo clean

D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly clippy
   Compiling num-traits v0.2.4
   Compiling winapi v0.3.4
   Compiling num-integer v0.1.38
    Checking libc v0.2.40
    Checking time v0.1.40
    Checking chrono v0.4.2 (file:///D:/Christopher/Documents/Code/Rust/chrono)
error[E0277]: the trait bound `Tz2: offset::TimeZone` is not satisfied
  --> src\date.rs:44:5
   |
44 |     offset: Tz::Offset,
   |     ^^^^^^^^^^^^^^^^^^ the trait `offset::TimeZone` is not implemented for `Tz2`
   |
   = help: consider adding a `where Tz2: offset::TimeZone` bound

thread 'main' panicked at 'encountered error with `-Z treat_err_as_bug', librustc_errors\lib.rs:461:13
stack backtrace:
   0: <std::collections::hash::map::DefaultHasher as core::fmt::Debug>::fmt
   1: <std::ffi::os_str::OsString as std::sys::windows::ext::ffi::OsStringExt>::from_wide
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::mir::interpret::error::EvalError<'a>>::lift_to_tcx
   5: std::panicking::rust_panic_with_hook
   6: <rustc_errors::diagnostic::SubDiagnostic as core::fmt::Debug>::fmt
   7: rustc_errors::Handler::force_print_db
   8: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
   9: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_selection_error
  10: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_fulfillment_errors
  11: rustc::ty::context::tls::track_diagnostic
  12: rustc::ty::util::<impl rustc::ty::ParamEnv<'tcx>>::can_type_implement_copy
  13: <unknown>
  14: <unknown>
  15: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
  16: rustc::hir::intravisit::NestedVisitorMap::inter
  17: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
  18: rustc::hir::intravisit::NestedVisitorMap::inter
  19: rustc::hir::intravisit::NestedVisitorMap::inter
  20: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  21: rustc::hir::intravisit::NestedVisitorMap::inter
  22: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  23: rustc::hir::intravisit::NestedVisitorMap::inter
  24: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  25: rustc::hir::intravisit::NestedVisitorMap::inter
  26: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  27: rustc::lint::context::check_crate
  28: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  29: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  30: <unknown>
  31: rustc_driver::driver::compile_input
  32: rustc_driver::run_compiler
  33: rustc_driver::driver::build_output_filenames
  34: <unknown>
  35: rustc_driver::run_compiler
  36: <unknown>
  37: <unknown>
  38: _rust_maybe_catch_panic
  39: <unknown>
  40: <unknown>
  41: <unknown>
  42: std::panicking::update_panic_count
  43: _rust_maybe_catch_panic
  44: std::rt::lang_start_internal
  45: <unknown>
  46: <unknown>
  47: BaseThreadInitThunk
  48: RtlUserThreadStart
query stack during panic:
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.27.0-nightly (9fae15374 2018-05-13) running on x86_64-pc-windows-msvc

note: compiler flags: -Z treat-err-as-bug -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `chrono`.

To learn more, run the command again with --verbose.

(going to try to install a debug build of clippy, better stacktrace maybe incoming)

Doesn't seem to include any new information, but here's one generated from an install --debug:

D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly install clippy --git https://github.com/rust-lang-nursery/rust-clippy.git --force --debug
    Updating git repository `https://github.com/rust-lang-nursery/rust-clippy.git`
   [snip]
    Finished dev [unoptimized + debuginfo] target(s) in 1m 0.74s
   Replacing C:\Users\Christopher\.cargo\bin\cargo-clippy.exe
   Replacing C:\Users\Christopher\.cargo\bin\clippy-driver.exe



D:\Christopher\Documents\Code\Rust\chrono>cargo +nightly clippy
   Compiling num-traits v0.2.4
   Compiling winapi v0.3.4
   Compiling num-integer v0.1.38
    Checking libc v0.2.40
    Checking time v0.1.40
    Checking chrono v0.4.2 (file:///D:/Christopher/Documents/Code/Rust/chrono)
error[E0277]: the trait bound `Tz2: offset::TimeZone` is not satisfied
  --> src\date.rs:44:5
   |
44 |     offset: Tz::Offset,
   |     ^^^^^^^^^^^^^^^^^^ the trait `offset::TimeZone` is not implemented for `Tz2`
   |
   = help: consider adding a `where Tz2: offset::TimeZone` bound

thread 'main' panicked at 'encountered error with `-Z treat_err_as_bug', librustc_errors\lib.rs:461:13
stack backtrace:
   0: <std::collections::hash::map::DefaultHasher as core::fmt::Debug>::fmt
   1: <std::ffi::os_str::OsString as std::sys::windows::ext::ffi::OsStringExt>::from_wide
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::mir::interpret::error::EvalError<'a>>::lift_to_tcx
   5: std::panicking::rust_panic_with_hook
   6: <rustc_errors::diagnostic::SubDiagnostic as core::fmt::Debug>::fmt
   7: rustc_errors::Handler::force_print_db
   8: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
   9: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_selection_error
  10: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_fulfillment_errors
  11: rustc::ty::context::tls::track_diagnostic
  12: rustc::ty::util::<impl rustc::ty::ParamEnv<'tcx>>::can_type_implement_copy
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
  18: rustc::hir::intravisit::NestedVisitorMap::inter
  19: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item
  20: rustc::hir::intravisit::NestedVisitorMap::inter
  21: rustc::hir::intravisit::NestedVisitorMap::inter
  22: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  23: rustc::hir::intravisit::NestedVisitorMap::inter
  24: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  25: rustc::hir::intravisit::NestedVisitorMap::inter
  26: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  27: rustc::hir::intravisit::NestedVisitorMap::inter
  28: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  29: rustc::lint::context::check_crate
  30: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  31: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
  32: <unknown>
  33: rustc_driver::driver::compile_input
  34: rustc_driver::run_compiler
  35: rustc_driver::driver::build_output_filenames
  36: <unknown>
  37: rustc_driver::run_compiler
  38: <unknown>
  39: <unknown>
  40: <unknown>
  41: <unknown>
  42: <unknown>
  43: _rust_maybe_catch_panic
  44: <unknown>
  45: <unknown>
  46: <unknown>
  47: <unknown>
  48: <unknown>
  49: <unknown>
  50: <unknown>
  51: std::panicking::update_panic_count
  52: _rust_maybe_catch_panic
  53: std::rt::lang_start_internal
  54: <unknown>
  55: <unknown>
  56: <unknown>
  57: BaseThreadInitThunk
  58: RtlUserThreadStart
query stack during panic:
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.27.0-nightly (9fae15374 2018-05-13) running on x86_64-pc-windows-msvc

note: compiler flags: -Z treat-err-as-bug -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `chrono`.

To learn more, run the command again with --verbose.

I'm getting the same on Ubuntu 17.10, so it's not windows only.

```
rustup override set nightly-2018-05-15
export RUSTFLAG=-Ztreat-err-as-bug
cargo install clippy --git https://github.com/rust-lang-nursery/rust-clippy.git --branch master --force && cargo clean && RUST_BACKTRACE=full cargo clippy

The backtrace has some hint that this might be

https://github.com/rust-lang-nursery/rust-clippy/blob/ff0f8d5ac3434518644411313b71b5395462d7a7/clippy_lints/src/needless_pass_by_value.rs#L204

But not sure without further testing. We probably need to pass a real parameter environment, and not just empty.

I can confirm that this happens on macOS (Sierra) as well.

Now I'm just confused as to how this never happened on Travis. Guess I got "saved" by the cache, not needing to recheck dependencies.

This issue rapidly becomes a total show-stopper. Chances to have chrono as your direct or indirect dependency is pretty high and it renders clippy completely unusable in this situation.

I think I've hit upon this same issue when trying to run clippy against gfx. This is a minimal example I put together that seems to be the same bug:
https://gist.github.com/AIOOB/a09909c52a1b52b46b7c955c102dcdfb
This compiles fine with cargo build but cargo clippy gives:

error[E0277]: the trait bound `T: Foo` is not satisfied
 --> src/lib.rs:6:5
  |
6 |     bar: T::Bar,
  |     ^^^^^^^^^^^ the trait `Foo` is not implemented for `T`
  |
  = help: consider adding a `where T: Foo` bound

On it, thanks for the minimal repro! @AIOOB

Was this page helpful?
0 / 5 - 0 ratings

Related issues

casey picture casey  路  19Comments

Manishearth picture Manishearth  路  18Comments

davemilter picture davemilter  路  18Comments

b1zzu picture b1zzu  路  28Comments

malbarbo picture malbarbo  路  26Comments