Skip to content

ICE: assertion failed: !ty.has_non_region_infer() #122638

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet, original probably from tests/ui/const-generics/type-dependent/issue-70507.rs

#![feature(min_specialization)]

impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> {
    fn next(&mut self) -> Option<Self::Item> {}
}

struct ConstChunksExact<'a, T: '_, const assert: usize> {}

impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
    type Item = &'a [T; N];
}

Version information

rustc 1.79.0-nightly (ecdea9e94 2024-03-17)
binary: rustc
commit-hash: ecdea9e9438cdb8cf707e7f60e066eda02344d05
commit-date: 2024-03-17
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0637]: `'_` cannot be used here
 --> /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:7:32
  |
7 | struct ConstChunksExact<'a, T: '_, const assert: usize> {}
  |                                ^^ `'_` is a reserved lifetime name

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:11:2
   |
11 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs`

error[E0308]: mismatched types
 --> /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:9:83
  |
9 | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
  |                                                                                   ^^ expected `usize`, found `()`

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/outlives_bounds.rs:51:5:
assertion failed: !ty.has_non_region_infer()
stack backtrace:
   0:     0x7f8b45b8c912 - std::backtrace_rs::backtrace::libunwind::trace::h130a839c96311127
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f8b45b8c912 - std::backtrace_rs::backtrace::trace_unsynchronized::h5053166127c32fca
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8b45b8c912 - std::sys_common::backtrace::_print_fmt::hc8bfe34d9b6ab8fa
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f8b45b8c912 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf5178e0e8c2a3754
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f8b45bddc8c - core::fmt::rt::Argument::fmt::h0a056d227bbd784c
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/core/src/fmt/rt.rs:142:9
   5:     0x7f8b45bddc8c - core::fmt::write::h10db7fef763d7bc1
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f8b45b8180f - std::io::Write::write_fmt::hae2c866742ac8216
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/io/mod.rs:1843:15
   7:     0x7f8b45b8c6e4 - std::sys_common::backtrace::_print::h5b25d695d3c3668b
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f8b45b8c6e4 - std::sys_common::backtrace::print::h734c64740bca27d9
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f8b45b8f3eb - std::panicking::default_hook::{{closure}}::hee6d4abdb3c0f483
  10:     0x7f8b45b8f143 - std::panicking::default_hook::h6fd6c192a391bb75
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/panicking.rs:292:9
  11:     0x7f8b48bb545f - std[1edb51698615b6b2]::panicking::update_hook::<alloc[e67a01ca5641d9fc]::boxed::Box<rustc_driver_impl[e0ef1a8995aede8b]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f8b45b8fb50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3d34b5ca386d93df
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/alloc/src/boxed.rs:2034:9
  13:     0x7f8b45b8fb50 - std::panicking::rust_panic_with_hook::ha06f2d1f1e60cb61
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/panicking.rs:783:13
  14:     0x7f8b45b8f859 - std::panicking::begin_panic_handler::{{closure}}::h8bd340824b2f16fb
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/panicking.rs:649:13
  15:     0x7f8b45b8cde6 - std::sys_common::backtrace::__rust_end_short_backtrace::h73dc69ff952ce613
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f8b45b8f5c4 - rust_begin_unwind
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/panicking.rs:645:5
  17:     0x7f8b45bda1a5 - core::panicking::panic_fmt::heaebb21c3402ed66
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/core/src/panicking.rs:72:14
  18:     0x7f8b45bda263 - core::panicking::panic::he4503a1f8c8c6482
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/core/src/panicking.rs:145:5
  19:     0x7f8b4788b3ad - rustc_trait_selection[7f61bd169b63885]::traits::outlives_bounds::implied_outlives_bounds
  20:     0x7f8b4a4c1436 - <rustc_infer[d3187ed693eaf61e]::infer::outlives::env::OutlivesEnvironment>::with_bounds::<core[b12cd9a0ca34f197]::iter::adapters::flatten::FlatMap<indexmap[d807711f4009a88]::set::iter::Iter<rustc_middle[7b6cdb9727477273]::ty::Ty>, alloc[e67a01ca5641d9fc]::vec::Vec<rustc_middle[7b6cdb9727477273]::traits::query::OutlivesBound>, <rustc_infer[d3187ed693eaf61e]::infer::InferCtxt as rustc_trait_selection[7f61bd169b63885]::traits::outlives_bounds::InferCtxtExt>::implied_bounds_tys::{closure#0}>>
  21:     0x7f8b4a4a0fe0 - rustc_hir_analysis[3992a0a0dd7933ad]::check::check::check_item_type
  22:     0x7f8b4a4c9adc - rustc_hir_analysis[3992a0a0dd7933ad]::check::wfcheck::check_well_formed
  23:     0x7f8b4a4c85c7 - rustc_query_impl[199a7318a0a2d0ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[199a7318a0a2d0ea]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7b6cdb9727477273]::query::erase::Erased<[u8; 1usize]>>
  24:     0x7f8b4a4c7d40 - rustc_query_system[5343cac5ae2d7d0f]::query::plumbing::try_execute_query::<rustc_query_impl[199a7318a0a2d0ea]::DynamicConfig<rustc_query_system[5343cac5ae2d7d0f]::query::caches::VecCache<rustc_hir[a79073bc83b4044]::hir_id::OwnerId, rustc_middle[7b6cdb9727477273]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[199a7318a0a2d0ea]::plumbing::QueryCtxt, false>
  25:     0x7f8b4a4c7abf - rustc_query_impl[199a7318a0a2d0ea]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f8b4a4c59fa - rustc_hir_analysis[3992a0a0dd7933ad]::check::wfcheck::check_mod_type_wf
  27:     0x7f8b4a4c5821 - rustc_query_impl[199a7318a0a2d0ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[199a7318a0a2d0ea]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7b6cdb9727477273]::query::erase::Erased<[u8; 1usize]>>
  28:     0x7f8b4a8936f0 - rustc_query_system[5343cac5ae2d7d0f]::query::plumbing::try_execute_query::<rustc_query_impl[199a7318a0a2d0ea]::DynamicConfig<rustc_query_system[5343cac5ae2d7d0f]::query::caches::DefaultCache<rustc_span[1fcd8257a8e9ae58]::def_id::LocalModDefId, rustc_middle[7b6cdb9727477273]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[199a7318a0a2d0ea]::plumbing::QueryCtxt, false>
  29:     0x7f8b4a89349b - rustc_query_impl[199a7318a0a2d0ea]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f8b4a16ef8b - rustc_hir_analysis[3992a0a0dd7933ad]::check_crate
  31:     0x7f8b4a2a492a - rustc_interface[f8af93c899996b27]::passes::analysis
  32:     0x7f8b4a2a4499 - rustc_query_impl[199a7318a0a2d0ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[199a7318a0a2d0ea]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7b6cdb9727477273]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7f8b4ab8c4a5 - rustc_query_system[5343cac5ae2d7d0f]::query::plumbing::try_execute_query::<rustc_query_impl[199a7318a0a2d0ea]::DynamicConfig<rustc_query_system[5343cac5ae2d7d0f]::query::caches::SingleCache<rustc_middle[7b6cdb9727477273]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[199a7318a0a2d0ea]::plumbing::QueryCtxt, false>
  34:     0x7f8b4ab8c209 - rustc_query_impl[199a7318a0a2d0ea]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f8b4aa67fc4 - rustc_interface[f8af93c899996b27]::interface::run_compiler::<core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>, rustc_driver_impl[e0ef1a8995aede8b]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7f8b4ab63a45 - std[1edb51698615b6b2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f8af93c899996b27]::util::run_in_thread_with_globals<rustc_interface[f8af93c899996b27]::util::run_in_thread_pool_with_globals<rustc_interface[f8af93c899996b27]::interface::run_compiler<core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>, rustc_driver_impl[e0ef1a8995aede8b]::run_compiler::{closure#0}>::{closure#0}, core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>>::{closure#0}, core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>>
  37:     0x7f8b4ab63872 - <<std[1edb51698615b6b2]::thread::Builder>::spawn_unchecked_<rustc_interface[f8af93c899996b27]::util::run_in_thread_with_globals<rustc_interface[f8af93c899996b27]::util::run_in_thread_pool_with_globals<rustc_interface[f8af93c899996b27]::interface::run_compiler<core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>, rustc_driver_impl[e0ef1a8995aede8b]::run_compiler::{closure#0}>::{closure#0}, core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>>::{closure#0}, core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b12cd9a0ca34f197]::result::Result<(), rustc_span[1fcd8257a8e9ae58]::ErrorGuaranteed>>::{closure#1} as core[b12cd9a0ca34f197]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f8b45b991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1668ba6e00dd332a
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/alloc/src/boxed.rs:2020:9
  39:     0x7f8b45b991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h19f13da360e1925b
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/alloc/src/boxed.rs:2020:9
  40:     0x7f8b45b991e5 - std::sys::pal::unix::thread::Thread::new::thread_start::h3bd6e605cc65dc69
                               at /rustc/ecdea9e9438cdb8cf707e7f60e066eda02344d05/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7f8b4598155a - <unknown>
  42:     0x7f8b459fea3c - <unknown>
  43:                0x0 - <unknown>

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: rustc 1.79.0-nightly (ecdea9e94 2024-03-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:3:1: 3:89>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error[E0392]: lifetime parameter `'a` is never used
 --> /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:7:25
  |
7 | struct ConstChunksExact<'a, T: '_, const assert: usize> {}
  |                         ^^ unused lifetime parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: type parameter `T` is never used
 --> /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:7:29
  |
7 | struct ConstChunksExact<'a, T: '_, const assert: usize> {}
  |                             ^ unused type parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`

error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
 --> /tmp/icemaker_global_tempdir.NwJkWeuZqOxD/rustc_testrunner_tmpdir_reporting.DGCv6r40KmDi/mvce.rs:9:30
  |
9 | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
  |                              ^^^^^^^^^^^^^^ unconstrained const parameter
  |
  = note: expressions using a const parameter must map each value to a distinct output value
  = note: proving the result of expressions other than the parameter are unique is not supported

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0207, E0308, E0392, E0601, E0637.
For more information about an error, try `rustc --explain E0207`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions