Running clippy with cargo clippy --release --features="stm32f429" on crate stm32f4xx-hal in version 0.3.0 results in the following ICE:
Checking cortex-m v0.5.8
Checking cortex-m-rt v0.6.8
error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:745: Cannot create local mono-item for DefId(5/0:10 ~ r0[f593]::zero_bss[0])
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
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.34.0 (91856ed52 2019-04-10) running on x86_64-apple-darwin
note: compiler flags: -C opt-level=s -C debuginfo=2 -C link-arg=-Tlink.x --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `cortex-m-rt`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Works fine in dev mode. Also works fine with --release in beta (rustc 1.35.0-beta.1 (2bc1d406d 2019-04-10)) and nightly (rustc 1.35.0-nightly (96d700f1b 2019-04-10)).
rustc 1.34.0 (91856ed52 2019-04-10)
binary: rustc
commit-hash: 91856ed52c58aa5ba66a015354d1cc69e9779bdf
commit-date: 2019-04-10
host: x86_64-apple-darwin
release: 1.34.0
LLVM version: 8.0
Backtrace:
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::_print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: rustc::util::common::panic_hook
5: std::panicking::rust_panic_with_hook
6: std::panicking::begin_panic
7: rustc_errors::Handler::bug
8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
9: rustc::ty::context::tls::with_opt::{{closure}}
10: rustc::ty::context::tls::with_context_opt
11: rustc::ty::context::tls::with_opt
12: rustc::util::bug::opt_span_bug_fmt
13: rustc::util::bug::bug_fmt
14: rustc_mir::monomorphize::collector::should_monomorphize_locally
15: rustc_mir::monomorphize::collector::visit_instance_use
16: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
17: rustc_mir::monomorphize::collector::collect_items_rec
18: rustc_mir::monomorphize::collector::collect_items_rec
19: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
20: rustc::util::common::time
21: rustc_mir::monomorphize::collector::collect_crate_mono_items
22: rustc::util::common::time
23: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
24: rustc::ty::query::__query_compute::collect_and_partition_mono_items
25: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::collect_and_partition_mono_items<'tcx>>::compute
26: rustc::dep_graph::graph::DepGraph::with_task_impl
27: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
28: core::ops::function::FnOnce::call_once
29: rustc::ty::query::__query_compute::backend_optimization_level
30: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::backend_optimization_level<'tcx>>::compute
31: rustc::dep_graph::graph::DepGraph::with_task_impl
32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
33: rustc_codegen_llvm::back::write::create_target_machine
34: rustc_codegen_llvm::context::create_module
35: rustc_codegen_ssa::base::codegen_crate
36: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
37: rustc::util::common::time
38: rustc_driver::driver::phase_4_codegen
39: rustc_driver::driver::compile_input::{{closure}}
40: <std::thread::local::LocalKey<T>>::with
41: rustc::ty::context::TyCtxt::create_and_enter
42: rustc_driver::driver::compile_input
43: rustc_driver::run_compiler_with_pool
44: <scoped_tls::ScopedKey<T>>::set
45: rustc_driver::run_compiler
46: <scoped_tls::ScopedKey<T>>::set
47: syntax::with_globals
48: __rust_maybe_catch_panic
49: <F as alloc::boxed::FnBox<A>>::call_box
50: std::sys::unix::thread::Thread::new::thread_start
51: _pthread_body
52: _pthread_start
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [backend_optimization_level] optimization level used by backend
end of query stack
Can reproduce it on linux. Using the latest git version also works (https://github.com/stm32-rs/stm32f4xx-hal/commit/23dd28d06badc4cb5c5df0ea3ee8ccb167fc8933) as well.
cargo build ... isn't enough, it has to be cargo clippy .... Where exactly is the difference? :|
You can also use cargo check ... to provoke the error.
This has something to do with the given opt-level=s. If I modify the Cargo.toml and add opt-level="s" to the dev profile cargo check (only cargo check without any additional arguments) will crash as well.
The opt-level either needs to be "s" or "z". Opt-levels 2 and 3 do not crash.
Confirmed this is a regression from stable to stable, which is fixed in beta/nightly. Bisecting the fix.
cc @rust-lang/compiler @rust-lang/release
@rustbot modify labels: I-ICE regression-from-stable-to-stable T-compiler I-nominated
The issue is fixed by https://github.com/rust-lang/rust/pull/58605, which for whatever reason wasn't beta-nominated. stable-nominating it.
This is effectively a duplicate of https://github.com/rust-lang/rust/issues/58323, which just resurfaced and broke my build again :( https://travis-ci.org/jonas-schievink/rubble/builds/519713130
triage: P-high due to ICE. removing nomination tag since I don't think there's much to discuss here. (PR #58605 we will discuss as part of stable-nominations discussion.)
I'm going to close this as fixed, in the sense that we've landed a fix (PR #58605) that is currently in the beta branch, and is not going to be backported to stable.
Most helpful comment
The issue is fixed by https://github.com/rust-lang/rust/pull/58605, which for whatever reason wasn't beta-nominated. stable-nominating it.