rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.25k stars 1.52k forks source link

rustc_codegen_ssa::mir::locals Unexpected initial operand type #12676

Open tsatke opened 5 months ago

tsatke commented 5 months ago

Summary

rustc-ice-2024-04-16T09_01_06-68750.txt

I'm running cargo clippy on https://github.com/tsatke/devos , I'm not sure what causes this. I'm using MacOS, but I'm also getting the same error with the same stack trace on Ubuntu 22.0.4 (with the latest nightly toolchains).

The first time I got this error was 3 days ago with Clippy version: clippy 0.1.79 (7942405 2024-04-12)

Version

rustc 1.79.0-nightly (ccfcd950b 2024-04-15)
binary: rustc
commit-hash: ccfcd950b333fed046275dd8d54fe736ca498aa7
commit-date: 2024-04-15
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3

Error output

Backtrace

``` WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: expected *mut usize, found !.See . thread 'rustc' panicked at /rustc/ccfcd950b333fed046275dd8d54fe736ca498aa7/compiler/rustc_codegen_ssa/src/mir/statement.rs:54:63: index out of bounds: the len is 2 but the index is 4 stack backtrace: 0: 0x103e18e84 - ::fmt::h7cdb5a1170713007 1: 0x103e5bf2c - core::fmt::write::h8899ab0faf0aeb5b 2: 0x103e0f170 - std::io::Write::write_fmt::he01363a5dbf59062 3: 0x103e18cdc - std::sys_common::backtrace::print::hac59c91626bc9770 4: 0x103e1b274 - std::panicking::default_hook::{{closure}}::h5367a42dc3a51b34 5: 0x103e1af64 - std::panicking::default_hook::h325121b0a19ce539 6: 0x10d4fbc78 - as core[a526d0f2da4bdc54]::ops::function::Fn<(&dyn for<'a, 'b> core[a526d0f2da4bdc54]::ops::function::Fn<(&'a core[a526d0f2da4bdc54]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[a526d0f2da4bdc54]::marker::Send + core[a526d0f2da4bdc54]::marker::Sync, &core[a526d0f2da4bdc54]::panic::panic_info::PanicInfo)>>::call 7: 0x103e1bc84 - std::panicking::rust_panic_with_hook::hb4c26d5b4b34973c 8: 0x103e1b678 - std::panicking::begin_panic_handler::{{closure}}::h773d17657c6067cf 9: 0x103e19314 - std::sys_common::backtrace::__rust_end_short_backtrace::h10752405464c3195 10: 0x103e1b3e4 - _rust_begin_unwind 11: 0x103e77cf0 - core::panicking::panic_fmt::ha79b3b561d439946 12: 0x103e77e60 - core::panicking::panic_bounds_check::h745fce92402fce70 13: 0x10d28c6a8 - rustc_codegen_ssa[c9204a01dd46d2f7]::mir::codegen_mir:: 14: 0x10d1ce904 - rustc_codegen_ssa[c9204a01dd46d2f7]::base::codegen_instance:: 15: 0x10d27fcb8 - rustc_codegen_llvm[5cae397a62af0338]::base::compile_codegen_unit::module_codegen 16: 0x10d27f84c - rustc_codegen_llvm[5cae397a62af0338]::base::compile_codegen_unit 17: 0x10d1cdfc8 - rustc_codegen_ssa[c9204a01dd46d2f7]::base::codegen_crate:: 18: 0x10d1b94d0 - ::codegen_crate 19: 0x10dce985c - ::time::, rustc_interface[d3728023a92c63c5]::passes::start_codegen::{closure#0}> 20: 0x10dc737c4 - rustc_interface[d3728023a92c63c5]::passes::start_codegen 21: 0x10dcee578 - ::enter::<::codegen_and_build_linker::{closure#0}, core[a526d0f2da4bdc54]::result::Result> 22: 0x10dc651c8 - ::codegen_and_build_linker 23: 0x10d51ff08 - ::enter::, rustc_span[fb2399e6facb433a]::ErrorGuaranteed>> 24: 0x10d4fe820 - rustc_span[fb2399e6facb433a]::set_source_map::, rustc_interface[d3728023a92c63c5]::interface::run_compiler, rustc_driver_impl[1e20964f5d10a404]::run_compiler::{closure#0}>::{closure#0}::{closure#0}> 25: 0x10d53ae18 - >::set::, rustc_driver_impl[1e20964f5d10a404]::run_compiler::{closure#0}>::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>> 26: 0x10d50710c - std[882017e1060a487f]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[1e20964f5d10a404]::run_compiler::{closure#0}>::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>> 27: 0x10d542a24 - <::spawn_unchecked_, rustc_driver_impl[1e20964f5d10a404]::run_compiler::{closure#0}>::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a526d0f2da4bdc54]::result::Result<(), rustc_span[fb2399e6facb433a]::ErrorGuaranteed>>::{closure#2} as core[a526d0f2da4bdc54]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 28: 0x103e2470c - std::sys::pal::unix::thread::Thread::new::thread_start::h56a548cf4819bf03 29: 0x191ff2f94 - __pthread_joiner_wake error: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml note: please make sure that you have updated to the latest nightly note: please attach the file at `/Users/tsatke/CLionProjects/devos/rustc-ice-2024-04-16T09_01_06-68750.txt` to your bug report note: compiler flags: --crate-type lib -C embed-bitcode=no -C incremental=[REDACTED] -C link-arg=-z -C link-arg=nostart-stop-gc note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack note: Clippy version: clippy 0.1.79 (ccfcd950 2024-04-15) ```

tsatke commented 3 months ago

https://github.com/rust-lang/rust/issues/124375 may be related?

tsatke commented 3 months ago

The problem disappears when switching giving the switch function https://github.com/tsatke/devos/blob/23ca7400e3465b344e86e192173a87979f10d142/kernel/src/arch/x86_64/switch.rs a return type of !, however that breaks the functionality.

tsatke commented 4 days ago

This issue still persists. I'd be thankful for any pointers or fixes.