rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.14k stars 12.69k forks source link

ICE: `region variables should not be hashed` #131639

Open matthiaskrgr opened 2 weeks ago

matthiaskrgr commented 2 weeks ago

Code

rustc l.rs -Cincremental=.

fn main() {
    unsafe { std::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(&'a ())>(5); }
}

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (6b9676b45 2024-10-12)
binary: rustc
commit-hash: 6b9676b45431a1e531b9c5f7bd289fc36a312749
commit-date: 2024-10-12
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.1

Error output

error[E0261]: use of undeclared lifetime name `'a`
 --> l.rs:3:78
  |
3 |     unsafe { std::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(&'a ())>(5); }
  |                                                                              ^^ undeclared lifetime
  |
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the type lifetime-generic with a new `'a` lifetime
  |
3 |     unsafe { std::mem::transmute::<usize, for<'a> extern "C-cmse-nonsecure-call" fn(&'a ())>(5); }
  |                                           +++++++
help: consider introducing lifetime `'a` here
  |
2 | fn main<'a>() {
  |        ++++

error[E0658]: C-cmse-nonsecure-call ABI is experimental and subject to change
 --> l.rs:3:50
  |
3 |     unsafe { std::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(&'a ())>(5); }
  |                                                  ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #81391 <https://github.com/rust-lang/rust/issues/81391> for more information
  = help: add `#![feature(abi_c_cmse_nonsecure_call)]` to the crate attributes to enable
  = note: this compiler was built on 2024-10-12; consider upgrading it if it is out of date
Backtrace

``` thread 'rustc' panicked at /rustc/6b9676b45431a1e531b9c5f7bd289fc36a312749/compiler/rustc_type_ir/src/region_kind.rs:238:17: region variables should not be hashed: '?0 stack backtrace: 0: 0x724fa79ca41a - ::fmt::h8b2043b14ab05304 1: 0x724fa82034a6 - core::fmt::write::hf9887d457cdbc966 2: 0x724fa941e951 - std::io::Write::write_fmt::ha659b10ba83556c4 3: 0x724fa79ca272 - std::sys::backtrace::BacktraceLock::print::hf85affc2cf4419f7 4: 0x724fa79cc746 - std::panicking::default_hook::{{closure}}::hde5089a7c4039350 5: 0x724fa79cc590 - std::panicking::default_hook::hf6b38aee6b14f9c5 6: 0x724fa6a249ff - std[b9c4ef606f74e7a3]::panicking::update_hook::>::{closure#0} 7: 0x724fa79cce58 - std::panicking::rust_panic_with_hook::hafbd7f0e47ba5b9a 8: 0x724fa79ccc2a - std::panicking::begin_panic_handler::{{closure}}::heb41764772c3697f 9: 0x724fa79ca8c9 - std::sys::backtrace::__rust_end_short_backtrace::hcc198f67593013e0 10: 0x724fa79cc8ec - rust_begin_unwind 11: 0x724fa53758b0 - core::panicking::panic_fmt::hd2428fc03641ffed 12: 0x724fa83b3e87 - > as rustc_data_structures[d65d6190c281c564]::stable_hasher::HashStable>::hash_stable 13: 0x724fa87ca803 - rustc_query_system[2162b26b9e1c67a3]::query::plumbing::try_execute_query::, rustc_middle[3e2c59a537b514a7]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[5ae70715c347e1a5]::plumbing::QueryCtxt, true> 14: 0x724fa87c9b29 - rustc_query_impl[5ae70715c347e1a5]::query_impl::layout_of::get_query_incr::__rust_end_short_backtrace 15: 0x724fa911295e - rustc_middle[3e2c59a537b514a7]::query::plumbing::query_get_at::, rustc_middle[3e2c59a537b514a7]::query::erase::Erased<[u8; 16usize]>>> 16: 0x724fa8b042e0 - ::lower_fn_ty 17: 0x724fa8b0a4bf - ::lower_ty 18: 0x724fa82b539e - <::instantiate_value_path::CtorGenericArgsCtxt as rustc_hir_analysis[b8eef9b6240b8e77]::hir_ty_lowering::GenericArgsLowerer>::provided_kind 19: 0x724fa82ad3e1 - ::instantiate_value_path 20: 0x724fa82a16d0 - ::check_expr_path 21: 0x724fa8e74092 - ::check_expr_with_expectation_and_args 22: 0x724fa8e75d77 - ::check_expr_with_expectation_and_args 23: 0x724fa8e6f6aa - ::check_block_with_expected 24: 0x724fa8e76923 - ::check_expr_with_expectation_and_args 25: 0x724fa8e6f78a - ::check_block_with_expected 26: 0x724fa8e76923 - ::check_expr_with_expectation_and_args 27: 0x724fa8b91a26 - rustc_hir_typeck[fded10133472f41e]::check::check_fn 28: 0x724fa8b86761 - rustc_hir_typeck[fded10133472f41e]::typeck 29: 0x724fa8b860cf - rustc_query_impl[5ae70715c347e1a5]::plumbing::__rust_begin_short_backtrace::> 30: 0x724fa85ffbd7 - rustc_query_system[2162b26b9e1c67a3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5ae70715c347e1a5]::plumbing::QueryCtxt, true> 31: 0x724fa85da854 - rustc_query_impl[5ae70715c347e1a5]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace 32: 0x724fa85fbb61 - ::par_body_owners::::{closure#0} 33: 0x724fa85f9a9b - rustc_hir_analysis[b8eef9b6240b8e77]::check_crate 34: 0x724fa85f64d7 - rustc_interface[a3bf963724784d96]::passes::run_required_analyses 35: 0x724fa8f6a65e - rustc_interface[a3bf963724784d96]::passes::analysis 36: 0x724fa8f6a631 - rustc_query_impl[5ae70715c347e1a5]::plumbing::__rust_begin_short_backtrace::> 37: 0x724fa92d530d - rustc_query_system[2162b26b9e1c67a3]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[5ae70715c347e1a5]::plumbing::QueryCtxt, true> 38: 0x724fa92d4dfa - rustc_query_impl[5ae70715c347e1a5]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace 39: 0x724fa8f7b0de - rustc_interface[a3bf963724784d96]::interface::run_compiler::, rustc_driver_impl[e627dad8a5ad147c]::run_compiler::{closure#0}>::{closure#1} 40: 0x724fa90244d4 - std[b9c4ef606f74e7a3]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[e627dad8a5ad147c]::run_compiler::{closure#0}>::{closure#1}, core[208fe08024603fa1]::result::Result<(), rustc_span[6af807c565a72bbf]::ErrorGuaranteed>>::{closure#0}, core[208fe08024603fa1]::result::Result<(), rustc_span[6af807c565a72bbf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[208fe08024603fa1]::result::Result<(), rustc_span[6af807c565a72bbf]::ErrorGuaranteed>> 41: 0x724fa90248e8 - <::spawn_unchecked_, rustc_driver_impl[e627dad8a5ad147c]::run_compiler::{closure#0}>::{closure#1}, core[208fe08024603fa1]::result::Result<(), rustc_span[6af807c565a72bbf]::ErrorGuaranteed>>::{closure#0}, core[208fe08024603fa1]::result::Result<(), rustc_span[6af807c565a72bbf]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[208fe08024603fa1]::result::Result<(), rustc_span[6af807c565a72bbf]::ErrorGuaranteed>>::{closure#1} as core[208fe08024603fa1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 42: 0x724fa90253ab - std::sys::pal::unix::thread::Thread::new::thread_start::h0e0386f9f8272e66 43: 0x724faa67739d - 44: 0x724faa6fc49c - 45: 0x0 - error: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: please make sure that you have updated to the latest nightly note: please attach the file at `/tmp/im/rustc-ice-2024-10-13T07_13_22-625025.txt` to your bug report note: compiler flags: -C incremental=[REDACTED] query stack during panic: panicked at /rustc/6b9676b45431a1e531b9c5f7bd289fc36a312749/compiler/rustc_type_ir/src/region_kind.rs:238:17: thread panicked while processing panic. aborting. [2] 625025 IOT instruction rustc l.rs -Cincremental=. ```

matthiaskrgr commented 2 weeks ago

bisects to #127814

jieyouxu commented 2 weeks ago

cc @folkertdev

folkertdev commented 2 weeks ago

yeah, basically the validation works great for correct types, but fails in various ways for types that already have other errors. I've asked around whether there is some way to run the analysis a bit later (after erroneous types have been weeded out, but haven't really heard anything back. So I don't know how to fix this other than in an ad-hoc way.