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 with generic_const_exprs and adt_const_params #97047

Closed
Kixiron opened this issue May 14, 2022 · 5 comments · Fixed by #98715
Closed

ICE with generic_const_exprs and adt_const_params #97047

Kixiron opened this issue May 14, 2022 · 5 comments · Fixed by #98715
Labels
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. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` 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

@Kixiron
Copy link
Member

Kixiron commented May 14, 2022

Code

pub struct Changes<const CHANGES: &'static [&'static str]>
where
    [(); CHANGES.len()]:,
{
    changes: [usize; CHANGES.len()],
    has_changed: bool,
}

impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
where
    [(); CHANGES.len()]:,
{
    pub const fn new() -> Self {
        Self {
            changes: [0; CHANGES.len()],
            has_changed: false,
        }
    }

    pub const fn did_change(&self) -> bool {
        self.has_changed
    }

    pub fn reset(&mut self) {
        self.has_changed = false;
    }

    pub fn combine(&mut self, other: &Self) {
        self.has_changed |= other.has_changed;

        // Sum up all changes
        self.changes
            .iter_mut()
            .zip(&other.changes)
            .for_each(|(total, &additional)| *total += additional);
    }

    pub fn inc<const NAME: &'static str>(&mut self)
    where
        Assert<{ contains(CHANGES, NAME) }>: True,
    {
        self.has_changed = true;

        let index = index_of(CHANGES, NAME);
        self.changes[index] += 1;
    }
}

pub struct Assert<const COND: bool> {}

pub trait True {}

impl True for Assert<true> {}

pub const fn contains(changes: &[&str], name: &str) -> bool {
    let mut idx = 0;
    while idx < changes.len() {
        if str_eq(changes[idx], name) {
            return true;
        }

        idx += 1;
    }

    false
}

const fn index_of(changes: &[&str], name: &str) -> usize {
    let mut idx = 0;
    while idx < changes.len() {
        if str_eq(changes[idx], name) {
            return idx;
        }

        idx += 1;
    }

    panic!()
}

const fn str_eq(lhs: &str, rhs: &str) -> bool {
    let (lhs, rhs) = (lhs.as_bytes(), rhs.as_bytes());

    if lhs.len() != rhs.len() {
        return false;
    }

    let mut idx = 0;
    while idx < lhs.len() {
        if lhs[idx] != rhs[idx] {
            return false;
        }

        idx += 1;
    }

    true
}

Meta

rustc --version --verbose:

rustc 1.62.0-nightly (6dd68402c 2022-05-11)
binary: rustc
commit-hash: 6dd68402c5d7da168f87d8551dd9aed1d8a21893
commit-date: 2022-05-11
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

Error output

warning: Error finalizing incremental compilation session directory `\\?\G:\Users\Chase\Code\Rust\cranial-coitus\target\debug\incremental\cranial_coitus-2hk2617a5lyqj\s-g9s3rzollv-1ifjoz6-working`: The system cannot find the file specified. (os error 2)

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:7398 ~ cranial_coitus[a396]::passes::utils::changes::{impl#1}::new) (NoSolution): could not prove Binder(ConstEvaluatable(WithOptConstParam { did: DefId(0:7391 ~ cranial_coitus[a396]::passes::utils::changes::Changes2::{constant#0}), const_param_did: None }, [Const { ty: &[&str], val: Param(CHANGES/#0) }]), [])
  --> src\passes\utils\changes.rs:78:9
   |
78 | /         Self {
79 | |             changes: [0; CHANGES.len()],
80 | |             has_changed: false,
81 | |         }
   | |_________^
   |
   = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

error: internal compiler error: broken MIR in DefId(0:7402 ~ cranial_coitus[a396]::passes::utils::changes::{impl#1}::combine) (NoSolution): could not prove Binder(WellFormed(&[usize; _]), [])
  --> src\passes\utils\changes.rs:98:18
   |
98 |             .zip(&other.changes)
   |                  ^^^^^^^^^^^^^^
   |
   = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

error: internal compiler error: broken MIR in DefId(0:7402 ~ cranial_coitus[a396]::passes::utils::changes::{impl#1}::combine) (NoSolution): could not prove Binder(ConstEvaluatable(WithOptConstParam { did: DefId(0:7397 ~ cranial_coitus[a396]::passes::utils::changes::{impl#1}::{constant#0}), const_param_did: None }, [Const { ty: &[&str], val: Param(CHANGES/#0) }]), [])
  --> src\passes\utils\changes.rs:99:23
   |
99 |             .for_each(|(total, &additional)| *total += additional);
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1369:13
stack backtrace:
   0:     0x7ff8fe65988f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h19d347d7cfe5cdb5
   1:     0x7ff8fe69496a - core::fmt::write::ha4c3b8e240caf9f6
   2:     0x7ff8fe64bea9 - <std::io::IoSlice as core::fmt::Debug>::fmt::hc3dee57d919433ff
   3:     0x7ff8fe65d07b - std::panicking::default_hook::h4544884403d9be85
   4:     0x7ff8fe65cc6e - std::panicking::default_hook::h4544884403d9be85
   5:     0x7ff8cb47e8c9 - <rustc_middle[dba4d5507afbab0d]::ty::SymbolName as core[eee2e1d8d36d089]::fmt::Debug>::fmt
   6:     0x7ff8fe65d95a - std::panicking::rust_panic_with_hook::hc1cc4992a4b6ec1b
   7:     0x7ff8cfbe3055 - <rustc_errors[a795d8b482c20b3d]::diagnostic_builder::DiagnosticBuilderInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
   8:     0x7ff8cfbe3009 - <rustc_errors[a795d8b482c20b3d]::diagnostic_builder::DiagnosticBuilderInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
   9:     0x7ff8cff29399 - rustc_query_system[a0b9f5f0299a8a38]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff8cfbd5629 - <rustc_feature[ea871e0fc9abb418]::builtin_attrs::AttributeType as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  11:     0x7ff8cfbd9288 - <rustc_errors[a795d8b482c20b3d]::HandlerInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
  12:     0x7ff8cb4a5794 - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  13:     0x7ff8cb4a8bca - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  14:     0x7ff8cb493ecd - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  15:     0x7ff8cb491bf9 - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  16:     0x7ff8cb42f540 - <rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::PtxLinker as rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::Linker>::no_default_libraries
  17:     0x7ff8cb432c27 - <rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::PtxLinker as rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::Linker>::no_default_libraries
  18:     0x7ff8cb43c876 - <rustc_driver[dba66f49bbdf914a]::args::Error as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  19:     0x7ff8cb43d998 - <rustc_driver[dba66f49bbdf914a]::args::Error as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  20:     0x7ff8fe66edec - std::sys::windows::thread::Thread::new::h1883b00da4b4f517
  21:     0x7ff95ba97034 - BaseThreadInitThunk
  22:     0x7ff95d2a2651 - RtlUserThreadStart

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.62.0-nightly (6dd68402c 2022-05-11) running on x86_64-pc-windows-msvc

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:
end of query stack
warning: `cranial-coitus` (bin "cranial-coitus") generated 56 warnings
error: could not compile `cranial-coitus`; 56 warnings emitted
Backtrace

warning: Error finalizing incremental compilation session directory `\\?\G:\Users\Chase\Code\Rust\cranial-coitus\target\debug\incremental\cranial_coitus-2hk2617a5lyqj\s-g9s4782zug-1fg2gpo-working`: The system cannot find the file specified. (os error 2)

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:7410 ~ cranial_coitus[a396]::passes::utils::changes::const_checked::{impl#0}::new) (NoSolution): could not prove Binder(ConstEvaluatable(WithOptConstParam { did: DefId(0:7403 ~ cranial_coitus[a396]::passes::utils::changes::const_checked::Changes2::{constant#0}), const_param_did: None }, [Const { ty: &[&str], val: Param(CHANGES/#0) }]), [])
  --> src\passes\utils\changes.rs:84:13
   |
84 | /             Self {
85 | |                 changes: [0; CHANGES.len()],
86 | |                 has_changed: false,
87 | |             }
   | |_____________^
   |
   = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

error: internal compiler error: broken MIR in DefId(0:7414 ~ cranial_coitus[a396]::passes::utils::changes::const_checked::{impl#0}::combine) (NoSolution): could not prove Binder(WellFormed(&[usize; _]), [])
   --> src\passes\utils\changes.rs:104:22
    |
104 |                 .zip(&other.changes)
    |                      ^^^^^^^^^^^^^^
    |
    = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

error: internal compiler error: broken MIR in DefId(0:7414 ~ cranial_coitus[a396]::passes::utils::changes::const_checked::{impl#0}::combine) (NoSolution): could not prove Binder(ConstEvaluatable(WithOptConstParam { did: DefId(0:7409 ~ cranial_coitus[a396]::passes::utils::changes::const_checked::{impl#0}::{constant#0}), const_param_did: None }, [Const { ty: &[&str], val: Param(CHANGES/#0) }]), [])
   --> src\passes\utils\changes.rs:105:27
    |
105 |                 .for_each(|(total, &additional)| *total += additional);
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1369:13
stack backtrace:
   0:     0x7ff8fe65988f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h19d347d7cfe5cdb5
   1:     0x7ff8fe69496a - core::fmt::write::ha4c3b8e240caf9f6
   2:     0x7ff8fe64bea9 - <std::io::IoSlice as core::fmt::Debug>::fmt::hc3dee57d919433ff
   3:     0x7ff8fe65d07b - std::panicking::default_hook::h4544884403d9be85
   4:     0x7ff8fe65cc6e - std::panicking::default_hook::h4544884403d9be85
   5:     0x7ff8cb47e8c9 - <rustc_middle[dba4d5507afbab0d]::ty::SymbolName as core[eee2e1d8d36d089]::fmt::Debug>::fmt
   6:     0x7ff8fe65d95a - std::panicking::rust_panic_with_hook::hc1cc4992a4b6ec1b
   7:     0x7ff8cfbe3055 - <rustc_errors[a795d8b482c20b3d]::diagnostic_builder::DiagnosticBuilderInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
   8:     0x7ff8cfbe3009 - <rustc_errors[a795d8b482c20b3d]::diagnostic_builder::DiagnosticBuilderInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
   9:     0x7ff8cff29399 - rustc_query_system[a0b9f5f0299a8a38]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff8cfbd5629 - <rustc_feature[ea871e0fc9abb418]::builtin_attrs::AttributeType as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  11:     0x7ff8cfbd9288 - <rustc_errors[a795d8b482c20b3d]::HandlerInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
  12:     0x7ff8cb4a5794 - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  13:     0x7ff8cb4a8bca - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  14:     0x7ff8cb493ecd - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  15:     0x7ff8cb491bf9 - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  16:     0x7ff8cb42f540 - <rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::PtxLinker as rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::Linker>::no_default_libraries
  17:     0x7ff8cb432c27 - <rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::PtxLinker as rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::Linker>::no_default_libraries
  18:     0x7ff8cb43c876 - <rustc_driver[dba66f49bbdf914a]::args::Error as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  19:     0x7ff8cb43d998 - <rustc_driver[dba66f49bbdf914a]::args::Error as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  20:     0x7ff8fe66edec - std::sys::windows::thread::Thread::new::h1883b00da4b4f517
  21:     0x7ff95ba97034 - BaseThreadInitThunk
  22:     0x7ff95d2a2651 - RtlUserThreadStart

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.62.0-nightly (6dd68402c 2022-05-11) running on x86_64-pc-windows-msvc

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:
end of query stack
warning: `cranial-coitus` (bin "cranial-coitus") generated 56 warnings
error: could not compile `cranial-coitus`; 56 warnings emitted

@Kixiron Kixiron 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 May 14, 2022
@rodrimati1992
Copy link
Contributor

rodrimati1992 commented May 14, 2022

A reduced version:

#![feature(adt_const_params, generic_const_exprs)]

pub struct Changes<const CHANGES: &'static [&'static str]>
where
    [(); CHANGES.len()]:,
{
    changes: [usize; CHANGES.len()],
}

impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
where
    [(); CHANGES.len()]:,
{
    pub const fn new() -> Self {
        Self {
            changes: [0; CHANGES.len()],
        }
    }
}

Error message

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:11 ~ playground[c737]::{impl#0}::new) (NoSolution): could not prove Binder(ConstEvaluatable(WithOptConstParam { did: DefId(0:5 ~ playground[c737]::Changes::{constant#0}), const_param_did: None }, [Const { ty: &[&str], val: Param(CHANGES/#0) }]), [])
  [--> src/lib.rs:15:9
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#)   |
15 | /         Self {
16 | |             changes: [0; CHANGES.len()],
17 | |         }
   | |_________^
   |
   = note: delayed at compiler/rustc_borrowck/src/type_check/canonical.rs:149:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1369:13
stack backtrace:
   0:     0x7f2991265fbd - std::backtrace_rs::backtrace::libunwind::trace::hfff13da9629808b3
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f2991265fbd - std::backtrace_rs::backtrace::trace_unsynchronized::h574c052d104edbb2
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2991265fbd - std::sys_common::backtrace::_print_fmt::hdec7c42a9aaff178
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f2991265fbd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7b437db464fe2eae
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f29912c1c4c - core::fmt::write::ha127ca1dd987811c
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f2991257731 - std::io::Write::write_fmt::haed364b23f647916
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/io/mod.rs:1654:15
   6:     0x7f2991268cd5 - std::sys_common::backtrace::_print::hb1db8a563e06b2cc
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f2991268cd5 - std::sys_common::backtrace::print::h16e06d5c2185a605
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f2991268cd5 - std::panicking::default_hook::{{closure}}::hc4512ccdd0ac08a5
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/panicking.rs:295:22
   9:     0x7f2991268949 - std::panicking::default_hook::hf0d6585cd7a26bd4
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/panicking.rs:314:9
  10:     0x7f2991a2dff1 - rustc_driver[8ee73bb5f36af3de]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f29912694a6 - std::panicking::rust_panic_with_hook::hb5d5e6f805719e75
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/panicking.rs:702:17
  12:     0x7f2992ba9cd1 - std[ac1b39edc8935404]::panicking::begin_panic::<rustc_errors[7358869d503cdbaa]::ExplicitBug>::{closure#0}
  13:     0x7f2992ba9c36 - std[ac1b39edc8935404]::sys_common::backtrace::__rust_end_short_backtrace::<std[ac1b39edc8935404]::panicking::begin_panic<rustc_errors[7358869d503cdbaa]::ExplicitBug>::{closure#0}, !>
  14:     0x7f2992bad906 - std[ac1b39edc8935404]::panicking::begin_panic::<rustc_errors[7358869d503cdbaa]::ExplicitBug>
  15:     0x7f2992bb19e6 - std[ac1b39edc8935404]::panic::panic_any::<rustc_errors[7358869d503cdbaa]::ExplicitBug>
  16:     0x7f2994370c41 - <rustc_errors[7358869d503cdbaa]::HandlerInner as core[295e1f7691ff5442]::ops::drop::Drop>::drop
  17:     0x7f2993ac4198 - core[295e1f7691ff5442]::ptr::drop_in_place::<rustc_session[ff20e138b897b605]::parse::ParseSess>
  18:     0x7f2993ac64b3 - <alloc[94313895c08d63e9]::rc::Rc<rustc_session[ff20e138b897b605]::session::Session> as core[295e1f7691ff5442]::ops::drop::Drop>::drop
  19:     0x7f2993ac306d - core[295e1f7691ff5442]::ptr::drop_in_place::<rustc_interface[d033f7e4bca3d7ee]::interface::Compiler>
  20:     0x7f2993ac29d4 - rustc_span[14222bfc8ecd5677]::with_source_map::<core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>, rustc_interface[d033f7e4bca3d7ee]::interface::create_compiler_and_run<core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>, rustc_driver[8ee73bb5f36af3de]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7f2993aae0c4 - rustc_interface[d033f7e4bca3d7ee]::interface::create_compiler_and_run::<core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>, rustc_driver[8ee73bb5f36af3de]::run_compiler::{closure#1}>
  22:     0x7f2993a98692 - <scoped_tls[2d60114f458dc383]::ScopedKey<rustc_span[14222bfc8ecd5677]::SessionGlobals>>::set::<rustc_interface[d033f7e4bca3d7ee]::interface::run_compiler<core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>, rustc_driver[8ee73bb5f36af3de]::run_compiler::{closure#1}>::{closure#0}, core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>>
  23:     0x7f2993aaf7bf - std[ac1b39edc8935404]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d033f7e4bca3d7ee]::util::run_in_thread_pool_with_globals<rustc_interface[d033f7e4bca3d7ee]::interface::run_compiler<core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>, rustc_driver[8ee73bb5f36af3de]::run_compiler::{closure#1}>::{closure#0}, core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>>::{closure#0}, core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>>
  24:     0x7f2993aaf8f9 - <<std[ac1b39edc8935404]::thread::Builder>::spawn_unchecked_<rustc_interface[d033f7e4bca3d7ee]::util::run_in_thread_pool_with_globals<rustc_interface[d033f7e4bca3d7ee]::interface::run_compiler<core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>, rustc_driver[8ee73bb5f36af3de]::run_compiler::{closure#1}>::{closure#0}, core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>>::{closure#0}, core[295e1f7691ff5442]::result::Result<(), rustc_errors[7358869d503cdbaa]::ErrorGuaranteed>>::{closure#1} as core[295e1f7691ff5442]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f29912733c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h54f496eb95d11bdf
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/alloc/src/boxed.rs:1872:9
  26:     0x7f29912733c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6d49434441582c00
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/alloc/src/boxed.rs:1872:9
  27:     0x7f29912733c3 - std::sys::unix::thread::Thread::new::thread_start::hbff7f546b16d10d6
                               at /rustc/f1f721e64014863f41c1a386b04af04c2de25321/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f29911a3609 - start_thread
  29:     0x7f29910bc133 - clone
  30:                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.62.0-nightly (f1f721e64 2022-05-13) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack

Rust version

Tested in play.rust-lang.org using 1.62.0-nightly (2022-05-13 f1f721e64014863f41c1)

@Kixiron
Copy link
Member Author

Kixiron commented May 14, 2022

The other ICE block is also standalone

#![feature(adt_const_params, generic_const_exprs)]

pub struct Changes<const CHANGES: &'static [&'static str]>
where
    [(); CHANGES.len()]:,
{
    changes: [usize; CHANGES.len()],
}

impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
where
    [(); CHANGES.len()]:,
{
    pub fn combine(&mut self, other: &Self) {
        for _change in &self.changes {}
    }
}
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:7397 ~ cranial_coitus[a396]::passes::utils::changes::{impl#1}::combine) (NoSolution): could not prove Binder(WellFormed(&[usize; _]), [])
  --> src\passes\utils\changes.rs:75:24
   |
75 |         for _change in &self.changes {}
   |                        ^^^^^^^^^^^^^
   |
   = note: delayed at compiler\rustc_borrowck\src\type_check\canonical.rs:149:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1369:13
stack backtrace:
   0:     0x7ff8fe65988f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h19d347d7cfe5cdb5
   1:     0x7ff8fe69496a - core::fmt::write::ha4c3b8e240caf9f6
   2:     0x7ff8fe64bea9 - <std::io::IoSlice as core::fmt::Debug>::fmt::hc3dee57d919433ff
   3:     0x7ff8fe65d07b - std::panicking::default_hook::h4544884403d9be85
   4:     0x7ff8fe65cc6e - std::panicking::default_hook::h4544884403d9be85
   5:     0x7ff8cb47e8c9 - <rustc_middle[dba4d5507afbab0d]::ty::SymbolName as core[eee2e1d8d36d089]::fmt::Debug>::fmt
   6:     0x7ff8fe65d95a - std::panicking::rust_panic_with_hook::hc1cc4992a4b6ec1b
   7:     0x7ff8cfbe3055 - <rustc_errors[a795d8b482c20b3d]::diagnostic_builder::DiagnosticBuilderInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
   8:     0x7ff8cfbe3009 - <rustc_errors[a795d8b482c20b3d]::diagnostic_builder::DiagnosticBuilderInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
   9:     0x7ff8cff29399 - rustc_query_system[a0b9f5f0299a8a38]::query::plumbing::incremental_verify_ich_cold
  10:     0x7ff8cfbd5629 - <rustc_feature[ea871e0fc9abb418]::builtin_attrs::AttributeType as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  11:     0x7ff8cfbd9288 - <rustc_errors[a795d8b482c20b3d]::HandlerInner as core[eee2e1d8d36d089]::ops::drop::Drop>::drop
  12:     0x7ff8cb4a5794 - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  13:     0x7ff8cb4a8bca - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  14:     0x7ff8cb493ecd - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  15:     0x7ff8cb491bf9 - rustc_driver[dba66f49bbdf914a]::pretty::print_after_hir_lowering
  16:     0x7ff8cb42f540 - <rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::PtxLinker as rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::Linker>::no_default_libraries
  17:     0x7ff8cb432c27 - <rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::PtxLinker as rustc_codegen_ssa[a427f0aa3144ff71]::back::linker::Linker>::no_default_libraries
  18:     0x7ff8cb43c876 - <rustc_driver[dba66f49bbdf914a]::args::Error as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  19:     0x7ff8cb43d998 - <rustc_driver[dba66f49bbdf914a]::args::Error as core[eee2e1d8d36d089]::fmt::Debug>::fmt
  20:     0x7ff8fe66edec - std::sys::windows::thread::Thread::new::h1883b00da4b4f517
  21:     0x7ff95ba97034 - BaseThreadInitThunk
  22:     0x7ff95d2a2651 - RtlUserThreadStart

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.62.0-nightly (6dd68402c 2022-05-11) running on x86_64-pc-windows-msvc

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:
end of query stack

@matthiaskrgr
Copy link
Member

matthiaskrgr commented May 15, 2022

for the first example:

#![feature(adt_const_params, generic_const_exprs)]

pub struct Changes<const CHANGES: &'static [&'static str]>
where
    [(); CHANGES.len()]:,
{
    changes: [usize; CHANGES.len()],
}

impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
where
    [(); CHANGES.len()]:,
{
    pub const fn new() -> Self {
        Self {
            changes: [0; CHANGES.len()],
        }
    }
}
searched toolchains nightly-2021-12-01 through nightly-2022-05-12
Regression in nightly-2021-12-06
searched toolchains efec545293b9263be9edfb283a7aa66350b3acbf through e2116acae59654bfab2a9729a024f3e2fd6d4b02

Regression in 772d51f 🤔

EDIT: same for the second snippet.

@b-naber
Copy link
Contributor

b-naber commented May 16, 2022

This is caused by #90529. Seems as if this issue takes care of this FIXME ^^.

Not sure what the right solution is, we originally tried to skip reborrows because implicit autorefs/autoderefs lead to confusing error messages given that we don't support derefs and refs in abstract consts. Maybe the right solution is to just clarify that autorefs/autoderefs happen there. Thoughts @lcnr?

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 21, 2022
@BoxyUwU BoxyUwU added F-generic_const_exprs `#![feature(generic_const_exprs)]` F-adt_const_params `#![feature(adt_const_params)]` labels Jun 24, 2022
@Alexendoo
Copy link
Member

No longer ICEs since #98669 (perhaps due to #98499?)

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 30, 2022
RalfJung added a commit to RalfJung/rust that referenced this issue Jul 2, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 2, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#98701 (Add regression test for rust-lang#50439)
 - rust-lang#98715 (add ice test for rust-lang#97047)
 - rust-lang#98753 (Fix `x dist rust-dev` on a fresh checkout)
 - rust-lang#98805 (Add rust-lang#95469 to the release notes)
 - rust-lang#98812 (feat: Add a documentation problem issue template)
 - rust-lang#98819 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in d067cb4 Jul 2, 2022
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-adt_const_params `#![feature(adt_const_params)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` 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.

7 participants