Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: StableHasher: unexpected region '_#0r #95311

Closed
boulanlo opened this issue Mar 25, 2022 · 4 comments · Fixed by #95315
Closed

ICE: StableHasher: unexpected region '_#0r #95311

boulanlo opened this issue Mar 25, 2022 · 4 comments · Fixed by #95315
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@boulanlo
Copy link

boulanlo commented Mar 25, 2022

I recently updated my nightly toolchain and our project (still not open-sourced) ICE'd. I managed to reduce the problem to a minimal working example:

Code

#![feature(ptr_metadata)]

trait Bar: Sized + 'static { }

struct Foo<B: Bar> {
    marker: std::marker::PhantomData<B>,
}

impl<B: Bar> Foo<B> {
    fn foo<T: ?Sized>(value: &T) {
        std::ptr::metadata(value);
    }
}

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (63b8f01bb 2022-03-24)
binary: rustc
commit-hash: 63b8f01bb5ca277e7df8d7efe094ed4244c1790c
commit-date: 2022-03-24
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/impls_ty.rs:128:17: StableHasher: unexpected region '_#0r

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1261:9
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/impls_ty.rs:128:17: StableHasher: unexpected region '_#0r

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1261:9
stack backtrace:
   0:     0x7fa26fa9d55d - std::backtrace_rs::backtrace::libunwind::trace::h2d2403a4858e54e0
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fa26fa9d55d - std::backtrace_rs::backtrace::trace_unsynchronized::h19488f91fb99335d
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa26fa9d55d - std::sys_common::backtrace::_print_fmt::hc7dc3caa1b1fa1a8
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fa26fa9d55d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdd9bf0d62a609be4
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fa26faf755c - core::fmt::write::h5aa356cee5fb9fa9
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/core/src/fmt/mod.rs:1190:17
   5:     0x7fa26fa8eb51 - std::io::Write::write_fmt::h5f1c72988edc233a
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/io/mod.rs:1655:15
   6:     0x7fa26faa0645 - std::sys_common::backtrace::_print::hf7422c13ad711003
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fa26faa0645 - std::sys_common::backtrace::print::hd1d7cd277e511da8
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fa26faa0645 - std::panicking::default_hook::{{closure}}::h197cc907105123d7
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/panicking.rs:295:22
   9:     0x7fa26faa02f9 - std::panicking::default_hook::h1359dace8bca1122
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/panicking.rs:314:9
  10:     0x7fa2702ce2e1 - rustc_driver[dfa02f50b2a2e61e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fa26faa0d90 - std::panicking::rust_panic_with_hook::h6964c34f5177236d
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/panicking.rs:702:17
  12:     0x7fa2713751f1 - std[93bbb3cd3e7c1062]::panicking::begin_panic::<rustc_errors[b882cf8cc0f2d9b3]::ExplicitBug>::{closure#0}
  13:     0x7fa2713750b6 - std[93bbb3cd3e7c1062]::sys_common::backtrace::__rust_end_short_backtrace::<std[93bbb3cd3e7c1062]::panicking::begin_panic<rustc_errors[b882cf8cc0f2d9b3]::ExplicitBug>::{closure#0}, !>
  14:     0x7fa27137bfff - std[93bbb3cd3e7c1062]::panicking::begin_panic::<rustc_errors[b882cf8cc0f2d9b3]::ExplicitBug>
  15:     0x7fa271388f16 - std[93bbb3cd3e7c1062]::panic::panic_any::<rustc_errors[b882cf8cc0f2d9b3]::ExplicitBug>
  16:     0x7fa27138a6f3 - <rustc_errors[b882cf8cc0f2d9b3]::HandlerInner>::bug
  17:     0x7fa27138a150 - <rustc_errors[b882cf8cc0f2d9b3]::Handler>::bug
  18:     0x7fa2712c68b6 - rustc_middle[c43c5dddfafcfdf0]::ty::context::tls::with_opt::<rustc_middle[c43c5dddfafcfdf0]::util::bug::opt_span_bug_fmt<rustc_span[5a327fbd7b70632c]::span_encoding::Span>::{closure#0}, ()>
  19:     0x7fa2712c9946 - rustc_middle[c43c5dddfafcfdf0]::util::bug::opt_span_bug_fmt::<rustc_span[5a327fbd7b70632c]::span_encoding::Span>
  20:     0x7fa2712c98b3 - rustc_middle[c43c5dddfafcfdf0]::util::bug::bug_fmt
  21:     0x7fa2720a35ee - <rustc_data_structures[4e1b415330f15730]::intern::Interned<rustc_middle[c43c5dddfafcfdf0]::ty::sty::RegionKind> as rustc_data_structures[4e1b415330f15730]::stable_hasher::HashStable<rustc_query_system[7e1ef711748c1dc0]::ich::hcx::StableHashingContext>>::hash_stable
  22:     0x7fa2720ec69f - <rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnv as rustc_data_structures[4e1b415330f15730]::stable_hasher::HashStable<rustc_query_system[7e1ef711748c1dc0]::ich::hcx::StableHashingContext>>::hash_stable
  23:     0x7fa271c3bf1e - <rustc_query_system[7e1ef711748c1dc0]::query::config::QueryVtable<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::Ty>, bool>>::to_dep_node
  24:     0x7fa271ba757f - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::try_execute_query::<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_query_system[7e1ef711748c1dc0]::query::caches::DefaultCache<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::Ty>, bool>>
  25:     0x7fa27267f4fb - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::get_query::<rustc_query_impl[5eb223aa473b54b7]::queries::is_sized_raw, rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt>
  26:     0x7fa2720e2335 - <rustc_middle[c43c5dddfafcfdf0]::ty::Ty>::is_sized
  27:     0x7fa271eebcfa - rustc_trait_selection[d05df1b49be1ed2e]::traits::project::opt_normalize_projection_type
  28:     0x7fa272916a08 - rustc_trait_selection[d05df1b49be1ed2e]::traits::project::normalize_projection_type
  29:     0x7fa2725a8433 - <rustc_infer[130c9cf43637d4b6]::infer::InferCtxtBuilder as rustc_trait_selection[d05df1b49be1ed2e]::infer::InferCtxtBuilderExt>::enter_canonical_trait_query::<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::sty::ProjectionTy>, rustc_middle[c43c5dddfafcfdf0]::traits::query::NormalizationResult, rustc_traits[6d6289cb5976f7ed]::normalize_projection_ty::normalize_projection_ty::{closure#0}>
  30:     0x7fa2725afe17 - rustc_traits[6d6289cb5976f7ed]::normalize_projection_ty::normalize_projection_ty
  31:     0x7fa2726e949f - <rustc_query_system[7e1ef711748c1dc0]::dep_graph::graph::DepGraph<rustc_middle[c43c5dddfafcfdf0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[c43c5dddfafcfdf0]::ty::context::TyCtxt, rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::sty::ProjectionTy>>, core[c7f008e1dcb6080]::result::Result<&rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::QueryResponse<rustc_middle[c43c5dddfafcfdf0]::traits::query::NormalizationResult>>, rustc_middle[c43c5dddfafcfdf0]::traits::query::NoSolution>>
  32:     0x7fa272621a08 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::try_execute_query::<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_query_system[7e1ef711748c1dc0]::query::caches::DefaultCache<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::sty::ProjectionTy>>, core[c7f008e1dcb6080]::result::Result<&rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::QueryResponse<rustc_middle[c43c5dddfafcfdf0]::traits::query::NormalizationResult>>, rustc_middle[c43c5dddfafcfdf0]::traits::query::NoSolution>>>
  33:     0x7fa27268da78 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::get_query::<rustc_query_impl[5eb223aa473b54b7]::queries::normalize_projection_ty, rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt>
  34:     0x7fa272750788 - <rustc_query_impl[5eb223aa473b54b7]::Queries as rustc_middle[c43c5dddfafcfdf0]::ty::query::QueryEngine>::normalize_projection_ty
  35:     0x7fa271f205e7 - <rustc_trait_selection[d05df1b49be1ed2e]::traits::query::normalize::QueryNormalizer as rustc_middle[c43c5dddfafcfdf0]::ty::fold::FallibleTypeFolder>::try_fold_ty
  36:     0x7fa271a9bf7a - <rustc_infer[130c9cf43637d4b6]::infer::InferCtxtBuilder>::enter_with_canonical::<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::Ty>, core[c7f008e1dcb6080]::result::Result<&rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::QueryResponse<rustc_middle[c43c5dddfafcfdf0]::traits::query::DropckOutlivesResult>>, rustc_middle[c43c5dddfafcfdf0]::traits::query::NoSolution>, rustc_traits[6d6289cb5976f7ed]::dropck_outlives::dropck_outlives::{closure#0}>
  37:     0x7fa2725acb2b - rustc_traits[6d6289cb5976f7ed]::dropck_outlives::dropck_outlives
  38:     0x7fa2726e8457 - <rustc_query_system[7e1ef711748c1dc0]::dep_graph::graph::DepGraph<rustc_middle[c43c5dddfafcfdf0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[c43c5dddfafcfdf0]::ty::context::TyCtxt, rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::Ty>>, core[c7f008e1dcb6080]::result::Result<&rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::QueryResponse<rustc_middle[c43c5dddfafcfdf0]::traits::query::DropckOutlivesResult>>, rustc_middle[c43c5dddfafcfdf0]::traits::query::NoSolution>>
  39:     0x7fa272620aa5 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::try_execute_query::<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_query_system[7e1ef711748c1dc0]::query::caches::DefaultCache<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::ty::ParamEnvAnd<rustc_middle[c43c5dddfafcfdf0]::ty::Ty>>, core[c7f008e1dcb6080]::result::Result<&rustc_middle[c43c5dddfafcfdf0]::infer::canonical::Canonical<rustc_middle[c43c5dddfafcfdf0]::infer::canonical::QueryResponse<rustc_middle[c43c5dddfafcfdf0]::traits::query::DropckOutlivesResult>>, rustc_middle[c43c5dddfafcfdf0]::traits::query::NoSolution>>>
  40:     0x7fa272683474 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::get_query::<rustc_query_impl[5eb223aa473b54b7]::queries::dropck_outlives, rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt>
  41:     0x7fa2727507dc - <rustc_query_impl[5eb223aa473b54b7]::Queries as rustc_middle[c43c5dddfafcfdf0]::ty::query::QueryEngine>::dropck_outlives
  42:     0x7fa271f2f065 - <rustc_infer[130c9cf43637d4b6]::infer::at::At as rustc_trait_selection[d05df1b49be1ed2e]::traits::query::dropck_outlives::AtExt>::dropck_outlives
  43:     0x7fa27174ed4d - <rustc_typeck[435f3367231454a0]::check::regionck::RegionCtxt as rustc_hir[9824cce51557701d]::intravisit::Visitor>::visit_expr
  44:     0x7fa2717502ce - <rustc_typeck[435f3367231454a0]::check::regionck::RegionCtxt as rustc_hir[9824cce51557701d]::intravisit::Visitor>::visit_expr
  45:     0x7fa27174dfd5 - <rustc_typeck[435f3367231454a0]::check::regionck::RegionCtxt>::visit_fn_body
  46:     0x7fa2716b5b4c - <rustc_typeck[435f3367231454a0]::check::fn_ctxt::FnCtxt>::regionck_fn
  47:     0x7fa27172e533 - <rustc_infer[130c9cf43637d4b6]::infer::InferCtxtBuilder>::enter::<&rustc_middle[c43c5dddfafcfdf0]::ty::context::TypeckResults, <rustc_typeck[435f3367231454a0]::check::inherited::InheritedBuilder>::enter<rustc_typeck[435f3367231454a0]::check::typeck_with_fallback<rustc_typeck[435f3367231454a0]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[c43c5dddfafcfdf0]::ty::context::TypeckResults>::{closure#0}>
  48:     0x7fa2717143af - rustc_typeck[435f3367231454a0]::check::typeck
  49:     0x7fa2726f0710 - <rustc_query_system[7e1ef711748c1dc0]::dep_graph::graph::DepGraph<rustc_middle[c43c5dddfafcfdf0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[c43c5dddfafcfdf0]::ty::context::TyCtxt, rustc_span[5a327fbd7b70632c]::def_id::LocalDefId, &rustc_middle[c43c5dddfafcfdf0]::ty::context::TypeckResults>
  50:     0x7fa271bc25d5 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::try_execute_query::<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_query_system[7e1ef711748c1dc0]::query::caches::DefaultCache<rustc_span[5a327fbd7b70632c]::def_id::LocalDefId, &rustc_middle[c43c5dddfafcfdf0]::ty::context::TypeckResults>>
  51:     0x7fa271ca1ed8 - <rustc_query_impl[5eb223aa473b54b7]::Queries as rustc_middle[c43c5dddfafcfdf0]::ty::query::QueryEngine>::typeck
  52:     0x7fa27176f60c - <rustc_middle[c43c5dddfafcfdf0]::hir::map::Map>::par_body_owners::<rustc_typeck[435f3367231454a0]::check::typeck_item_bodies::{closure#0}>
  53:     0x7fa27241058c - rustc_typeck[435f3367231454a0]::check::typeck_item_bodies
  54:     0x7fa27270e613 - <rustc_query_system[7e1ef711748c1dc0]::dep_graph::graph::DepGraph<rustc_middle[c43c5dddfafcfdf0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[c43c5dddfafcfdf0]::ty::context::TyCtxt, (), ()>
  55:     0x7fa27265e4bf - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::try_execute_query::<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_query_system[7e1ef711748c1dc0]::query::caches::DefaultCache<(), ()>>
  56:     0x7fa272686b01 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::get_query::<rustc_query_impl[5eb223aa473b54b7]::queries::typeck_item_bodies, rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt>
  57:     0x7fa2724131e3 - <rustc_session[62db8dbcb5f03131]::session::Session>::time::<(), rustc_typeck[435f3367231454a0]::check_crate::{closure#7}>
  58:     0x7fa272410b93 - rustc_typeck[435f3367231454a0]::check_crate
  59:     0x7fa2721978f7 - rustc_interface[a6e240183aba3d57]::passes::analysis
  60:     0x7fa27270a7f5 - <rustc_query_system[7e1ef711748c1dc0]::dep_graph::graph::DepGraph<rustc_middle[c43c5dddfafcfdf0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[c43c5dddfafcfdf0]::ty::context::TyCtxt, (), core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>
  61:     0x7fa272654502 - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::try_execute_query::<rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt, rustc_query_system[7e1ef711748c1dc0]::query::caches::DefaultCache<(), core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>>
  62:     0x7fa27269566e - rustc_query_system[7e1ef711748c1dc0]::query::plumbing::get_query::<rustc_query_impl[5eb223aa473b54b7]::queries::analysis, rustc_query_impl[5eb223aa473b54b7]::plumbing::QueryCtxt>
  63:     0x7fa2721732a7 - <rustc_interface[a6e240183aba3d57]::passes::QueryContext>::enter::<rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>
  64:     0x7fa272150cb8 - <rustc_interface[a6e240183aba3d57]::interface::Compiler>::enter::<rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}::{closure#2}, core[c7f008e1dcb6080]::result::Result<core[c7f008e1dcb6080]::option::Option<rustc_interface[a6e240183aba3d57]::queries::Linker>, rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>
  65:     0x7fa272163d0f - rustc_span[5a327fbd7b70632c]::with_source_map::<core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>, rustc_interface[a6e240183aba3d57]::interface::create_compiler_and_run<core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>, rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}>::{closure#1}>
  66:     0x7fa272162b94 - rustc_interface[a6e240183aba3d57]::interface::create_compiler_and_run::<core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>, rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}>
  67:     0x7fa27214e6b2 - <scoped_tls[3e920f98e8d1f9d2]::ScopedKey<rustc_span[5a327fbd7b70632c]::SessionGlobals>>::set::<rustc_interface[a6e240183aba3d57]::interface::run_compiler<core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>, rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}>::{closure#0}, core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>
  68:     0x7fa27214ca1f - std[93bbb3cd3e7c1062]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a6e240183aba3d57]::util::run_in_thread_pool_with_globals<rustc_interface[a6e240183aba3d57]::interface::run_compiler<core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>, rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}>::{closure#0}, core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>::{closure#0}, core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>
  69:     0x7fa272164ca2 - <<std[93bbb3cd3e7c1062]::thread::Builder>::spawn_unchecked_<rustc_interface[a6e240183aba3d57]::util::run_in_thread_pool_with_globals<rustc_interface[a6e240183aba3d57]::interface::run_compiler<core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>, rustc_driver[dfa02f50b2a2e61e]::run_compiler::{closure#1}>::{closure#0}, core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>::{closure#0}, core[c7f008e1dcb6080]::result::Result<(), rustc_errors[b882cf8cc0f2d9b3]::ErrorGuaranteed>>::{closure#1} as core[c7f008e1dcb6080]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  70:     0x7fa26faaaf83 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd51c3662b34e3fa5
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/alloc/src/boxed.rs:1861:9
  71:     0x7fa26faaaf83 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb373dd9df6b8a0f7
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/alloc/src/boxed.rs:1861:9
  72:     0x7fa26faaaf83 - std::sys::unix::thread::Thread::new::thread_start::h987e16b384dce900
                               at /rustc/63b8f01bb5ca277e7df8d7efe094ed4244c1790c/library/std/src/sys/unix/thread.rs:108:17
  73:     0x7fa26f8835c2 - start_thread
  74:     0x7fa26f908584 - __clone
  75:                0x0 - <unknown>

note: 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: rustc 1.61.0-nightly (63b8f01bb 2022-03-24) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [normalize_projection_ty] normalizing `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(TraitPredicate(<B as Bar>, polarity:Positive), []), Binder(TraitPredicate(<B as core::marker::Sized>, polarity:Positive), []), Binder(OutlivesPredicate(B, ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrAnon(0) })), [])], reveal: UserFacing, constness: NotConst }, value: ProjectionTy { substs: [T], item_def_id: DefId(2:2092 ~ core[c7f0]::ptr::metadata::Pointee::Metadata) } } }`
#1 [dropck_outlives] computing dropck types for `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(TraitPredicate(<B as Bar>, polarity:Positive), []), Binder(TraitPredicate(<B as core::marker::Sized>, polarity:Positive), []), Binder(OutlivesPredicate(B, ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrAnon(0) })), [])], reveal: UserFacing, constness: NotConst }, value: <T as core::ptr::metadata::Pointee>::Metadata } }`
#2 [typeck] type-checking `<impl at src/main.rs:9:1: 13:2>::foo`
#3 [typeck_item_bodies] type-checking all item bodies
#4 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `foo`

I ran a quick cargo-bisect:

searched nightlies: from nightly-2022-03-01 to nightly-2022-03-24
regressed nightly: nightly-2022-03-16
searched commits: from 285fa7e to 52b3455
regressed commit: 2184c7c

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc 

The offending line is the std::ptr::metadata(), so we should probably tag this with the appropriate feature tag.

(Sorry if I messed anything up, I'm completely new to Rust ICE bug reports!)

@boulanlo boulanlo added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 25, 2022
@boulanlo boulanlo changed the title ICE: StableHasher: unexpected region _#0r ICE: StableHasher: unexpected region '_#0r Mar 25, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Mar 25, 2022

probably due to my PR #93977

@rustbot claim

@dimpolo
Copy link
Contributor

dimpolo commented Apr 2, 2022

I get the same error on code that I got minimized to:

#![feature(ptr_metadata)]

use core::marker::PhantomData;
use core::ops::Deref;
use core::ptr::{DynMetadata, Pointee};

struct Foo<T> {
    bar: PhantomData<T>,
}

impl<T> Deref for Foo<T>
where
    T: Pointee<Metadata = DynMetadata<T>> + 'static,
{
    type Target = T;

    fn deref(&self) -> &Self::Target {
        self.some_method()
    }
}

@usamoi
Copy link
Contributor

usamoi commented Apr 6, 2022

Same error with this example:

#![feature(ptr_metadata)]

use std::ptr::Pointee;

unsafe fn ice<T: ?Sized + 'static>(ptr: *const T) -> <T as Pointee>::Metadata {
    std::ptr::metadata(ptr)
}

@maximveligan
Copy link

Same error I got with this example

#![feature(ptr_metadata)]

fn bar<U: 'static + ?Sized>() -> <U as core::ptr::Pointee>::Metadata {panic!()}

Defining it in a trait is fine though

#![feature(ptr_metadata)]

trait Foo {
    fn bar<U: 'static + ?Sized>() -> <U as core::ptr::Pointee>::Metadata;
}

But adding a function body results in a crash

#![feature(ptr_metadata)]

trait Foo {
    fn bar<U: 'static + ?Sized>() -> <U as core::ptr::Pointee>::Metadata { panic!() }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants