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: unexpected inference var #122549

Closed
matthiaskrgr opened this issue Mar 15, 2024 · 1 comment · Fixed by #122837
Closed

ICE: unexpected inference var #122549

matthiaskrgr opened this issue Mar 15, 2024 · 1 comment · Fixed by #122837
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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

trait ConstChunksExactTrait<T> {
    fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
}

impl<T> ConstChunksExactTrait<T> for [T] {}

struct ConstChunksExact<'rem, T: 'a, const N: usize> {}

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

fn main() {
    let slice = &[1i32, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].iter();

    for a in slice.const_chunks_exact::<3>() {
        assert_eq!(a, iter.next().unwrap());
    }
}

Version information

rustc 1.78.0-nightly (d7723b219 2024-03-15)
binary: rustc
commit-hash: d7723b21910075a3c38c2b6e64b2467394c93724
commit-date: 2024-03-15
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0261]: use of undeclared lifetime name `'a`
 --> /tmp/icemaker_global_tempdir.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:2:70
  |
2 |     fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
  |                                                                      ^^ undeclared lifetime
  |
help: consider introducing lifetime `'a` here
  |
2 |     fn const_chunks_exact<'a, const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
  |                           +++
help: consider introducing lifetime `'a` here
  |
1 | trait ConstChunksExactTrait<'a, T> {
  |                             +++

error[E0261]: use of undeclared lifetime name `'a`
 --> /tmp/icemaker_global_tempdir.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:7:34
  |
7 | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
  |                         -        ^^ undeclared lifetime
  |                         |
  |                         help: consider introducing lifetime `'a` here: `'a,`

error[E0046]: not all trait items implemented, missing: `const_chunks_exact`
 --> /tmp/icemaker_global_tempdir.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:5:1
  |
2 |     fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'a, T, { N }>;
  |     ------------------------------------------------------------------------------- `const_chunks_exact` from trait
...
5 | impl<T> ConstChunksExactTrait<T> for [T] {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `const_chunks_exact` in implementation

error[E0392]: lifetime parameter `'rem` is never used
 --> /tmp/icemaker_global_tempdir.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:7:25
  |
7 | struct ConstChunksExact<'rem, T: 'a, const N: usize> {}
  |                         ^^^^ unused lifetime parameter
  |
  = help: consider removing `'rem`, 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.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:7:31
  |
7 | struct ConstChunksExact<'rem, T: 'a, const N: 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.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:9:13
  |
9 | impl<'a, T, 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[E0308]: mismatched types
 --> /tmp/icemaker_global_tempdir.vydRDKClcHJ4/rustc_testrunner_tmpdir_reporting.YGOeGphNiRlB/mvce.rs:9:66
  |
9 | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> {
  |                                                                  ^^ expected `usize`, found `()`

thread 'rustc' panicked at compiler/rustc_borrowck/src/type_check/relate_tys.rs:362:9:
unexpected inference var std::option::Option<&'?16 [i32; ?0c: usize]>
stack backtrace:
   0:     0x7ff8073a4912 - std::backtrace_rs::backtrace::libunwind::trace::h2da6c6ec1776ed1b
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7ff8073a4912 - std::backtrace_rs::backtrace::trace_unsynchronized::h0cb696e9cf0107ba
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff8073a4912 - std::sys_common::backtrace::_print_fmt::hfb11ed7a7d38a028
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ff8073a4912 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1048d052a888b26c
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ff8073f5c8c - core::fmt::rt::Argument::fmt::hcf8265a03a389e34
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/core/src/fmt/rt.rs:142:9
   5:     0x7ff8073f5c8c - core::fmt::write::hd12c3a84e62e1cec
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/core/src/fmt/mod.rs:1153:17
   6:     0x7ff80739980f - std::io::Write::write_fmt::h236993be0d5d91de
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/io/mod.rs:1843:15
   7:     0x7ff8073a46e4 - std::sys_common::backtrace::_print::he44e9b7b149d34c3
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ff8073a46e4 - std::sys_common::backtrace::print::h6f8e8e3b9f052551
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ff8073a73eb - std::panicking::default_hook::{{closure}}::h321d04c9179dccca
  10:     0x7ff8073a7143 - std::panicking::default_hook::hd949d1362c2e5565
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/panicking.rs:292:9
  11:     0x7ff803fa68ef - std[8d86c5c35c0bd7fb]::panicking::update_hook::<alloc[b74d3dbad420fbd6]::boxed::Box<rustc_driver_impl[724f095572d73222]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ff8073a7b50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4f6c988be7bdee68
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/alloc/src/boxed.rs:2034:9
  13:     0x7ff8073a7b50 - std::panicking::rust_panic_with_hook::hb71de646be3b3469
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/panicking.rs:783:13
  14:     0x7ff8073a7892 - std::panicking::begin_panic_handler::{{closure}}::hbca15a8a0a3dee72
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/panicking.rs:657:13
  15:     0x7ff8073a4de6 - std::sys_common::backtrace::__rust_end_short_backtrace::h885125d06f4d13f0
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7ff8073a75c4 - rust_begin_unwind
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/panicking.rs:645:5
  17:     0x7ff8073f21a5 - core::panicking::panic_fmt::ha3facef8c988a935
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/core/src/panicking.rs:72:14
  18:     0x7ff80529d0a8 - <rustc_borrowck[3ad0b086a2cf7c0e]::type_check::relate_tys::NllTypeRelating as rustc_middle[35d2191f4cbfc53b]::ty::relate::TypeRelation>::tys
  19:     0x7ff80608d936 - <rustc_borrowck[3ad0b086a2cf7c0e]::type_check::TypeChecker>::typeck_mir
  20:     0x7ff802afa5fa - rustc_borrowck[3ad0b086a2cf7c0e]::type_check::type_check
  21:     0x7ff802b34257 - rustc_borrowck[3ad0b086a2cf7c0e]::nll::compute_regions
  22:     0x7ff80601edc1 - rustc_borrowck[3ad0b086a2cf7c0e]::do_mir_borrowck
  23:     0x7ff806011128 - rustc_borrowck[3ad0b086a2cf7c0e]::mir_borrowck
  24:     0x7ff806010c17 - rustc_query_impl[5406894609d381a6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5406894609d381a6]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7ff80540ff2e - rustc_query_system[40cbee46219fc421]::query::plumbing::try_execute_query::<rustc_query_impl[5406894609d381a6]::DynamicConfig<rustc_query_system[40cbee46219fc421]::query::caches::VecCache<rustc_span[6c3fee00dc2a924e]::def_id::LocalDefId, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5406894609d381a6]::plumbing::QueryCtxt, false>
  26:     0x7ff80540fa4c - rustc_query_impl[5406894609d381a6]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7ff80599919e - rustc_interface[62605c20d0dc0fef]::passes::analysis
  28:     0x7ff805998425 - rustc_query_impl[5406894609d381a6]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5406894609d381a6]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7ff806006165 - rustc_query_system[40cbee46219fc421]::query::plumbing::try_execute_query::<rustc_query_impl[5406894609d381a6]::DynamicConfig<rustc_query_system[40cbee46219fc421]::query::caches::SingleCache<rustc_middle[35d2191f4cbfc53b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5406894609d381a6]::plumbing::QueryCtxt, false>
  30:     0x7ff806005ec9 - rustc_query_impl[5406894609d381a6]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7ff805d5e284 - rustc_interface[62605c20d0dc0fef]::interface::run_compiler::<core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>, rustc_driver_impl[724f095572d73222]::run_compiler::{closure#0}>::{closure#0}
  32:     0x7ff806223805 - std[8d86c5c35c0bd7fb]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_with_globals<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_pool_with_globals<rustc_interface[62605c20d0dc0fef]::interface::run_compiler<core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>, rustc_driver_impl[724f095572d73222]::run_compiler::{closure#0}>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>
  33:     0x7ff806223632 - <<std[8d86c5c35c0bd7fb]::thread::Builder>::spawn_unchecked_<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_with_globals<rustc_interface[62605c20d0dc0fef]::util::run_in_thread_pool_with_globals<rustc_interface[62605c20d0dc0fef]::interface::run_compiler<core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>, rustc_driver_impl[724f095572d73222]::run_compiler::{closure#0}>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d25ee0c10dd6dc91]::result::Result<(), rustc_span[6c3fee00dc2a924e]::ErrorGuaranteed>>::{closure#1} as core[d25ee0c10dd6dc91]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7ff8073b11e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hab5d072bb143d8fe
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/alloc/src/boxed.rs:2020:9
  35:     0x7ff8073b11e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he1f566ad483a8fda
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/alloc/src/boxed.rs:2020:9
  36:     0x7ff8073b11e5 - std::sys::pal::unix::thread::Thread::new::thread_start::h23d47a8da771b95c
                               at /rustc/d7723b21910075a3c38c2b6e64b2467394c93724/library/std/src/sys/pal/unix/thread.rs:108:17
  37:     0x7ff800ea955a - <unknown>
  38:     0x7ff800f26a3c - <unknown>
  39:                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.78.0-nightly (d7723b219 2024-03-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 7 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Mar 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 15, 2024
@matthiaskrgr
Copy link
Member Author

#121154 cc @oli-obk

@jieyouxu jieyouxu added A-const-generics Area: const generics (parameters and arguments) S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 15, 2024
@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 21, 2024
Rollup of 6 pull requests

Successful merges:

 - rust-lang#121881 (std::net: adding acceptfilter feature for netbsd/freebsd.)
 - rust-lang#122817 (Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order)
 - rust-lang#122829 (Implement `FusedIterator` for `gen` block)
 - rust-lang#122831 (make failure logs less verbose)
 - rust-lang#122837 (add test for rust-lang#122549)
 - rust-lang#122838 (Avoid noop rewrite of issues.txt)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#121881 (std::net: adding acceptfilter feature for netbsd/freebsd.)
 - rust-lang#122817 (Doc Guarantee: BTree(Set|Map):  `IntoIter` Iterate in Sorted by key Order)
 - rust-lang#122826 (Add tests for shortcomings of associated type bounds)
 - rust-lang#122829 (Implement `FusedIterator` for `gen` block)
 - rust-lang#122831 (make failure logs less verbose)
 - rust-lang#122837 (add test for rust-lang#122549)
 - rust-lang#122838 (Avoid noop rewrite of issues.txt)
 - rust-lang#122841 (add 2 more tests for issues fixed by rust-lang#122749)
 - rust-lang#122843 (Add a never type option to make diverging blocks `()`)
 - rust-lang#122844 (add test for ice "cannot relate region: LUB(ReErased, ReError)")
 - rust-lang#122845 (Clippy subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
Rollup merge of rust-lang#122837 - matthiaskrgr:fix_122549, r=petrochenkov

add test for rust-lang#122549

Fixes rust-lang#122549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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.

3 participants