- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
Code
#[derive(Debug)]
pub struct HalSetLayouts {
    vertex_layout: <B as hal::Backend>::DescriptorSetLayout,
    fragment_layout: <B as hal::Backend>::DescriptorSetLayout,
    fragment_sampler_layout: <B as hal::Backend>::DescriptorSetLayout,
}
impl HalSetLayouts {
    fn iter<DSL>(&self) -> impl ExactSizeIterator<Item = &DSL> + '_
    where
        // rust 1.37 fails to typecheck `iter` without this. This is fixed in nightly.
        B: hal::Backend<DescriptorSetLayout = DSL>,
        DSL: std::fmt::Debug + Send + Sync + 'static,
    {
        std::iter::once(&self.vertex_layout)
            .chain(std::iter::once(&self.fragment_layout))
            .chain(std::iter::once(&self.fragment_sampler_layout))
            .exact(3)
    }
}Meta
rustc --version --verbose:
rustc 1.64.0-nightly (2643b1646 2022-07-27)
binary: rustc
commit-hash: 2643b16468fda787470340890212591d8bc832b7
commit-date: 2022-07-27
host: x86_64-apple-darwin
release: 1.64.0-nightly
LLVM version: 14.0.6
Error output
error: internal compiler error: no errors encountered even though `delay_span_bug` issued
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3021 ~ renderer[c01e]::shader::{impl#11}::iter), const_param_did: None }) (end of phase transition to Optimized) at bb0[0]:
                                Field projection `(*_1).field[0]` specified type `DSL`, but actual type is <gfx_backend_metal::Backend as gfx_hal::Backend>::DescriptorSetLayout
   --> brainstorm/src/renderer/src/shader.rs:642:25
    |
642 |         std::iter::once(&self.vertex_layout)
    |                         ^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:129:36
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3021 ~ renderer[c01e]::shader::{impl#11}::iter), const_param_did: None }) (end of phase transition to Optimized) at bb1[0]:
                                Field projection `(*_1).field[1]` specified type `DSL`, but actual type is <gfx_backend_metal::Backend as gfx_hal::Backend>::DescriptorSetLayout
   --> brainstorm/src/renderer/src/shader.rs:643:36
    |
643 |             .chain(std::iter::once(&self.fragment_layout))
    |                                    ^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:129:36
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3021 ~ renderer[c01e]::shader::{impl#11}::iter), const_param_did: None }) (end of phase transition to Optimized) at bb3[0]:
                                Field projection `(*_1).field[2]` specified type `DSL`, but actual type is <gfx_backend_metal::Backend as gfx_hal::Backend>::DescriptorSetLayout
   --> brainstorm/src/renderer/src/shader.rs:644:36
    |
644 |             .chain(std::iter::once(&self.fragment_sampler_layout))
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:129:36
Backtrace
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1426:13
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   3: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   4: <alloc::rc::Rc<rustc_session::session::Session> as core::ops::drop::Drop>::drop
   5: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   6: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
   7: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
   8: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
This came from a workaround for what seems to be an old compiler bug. removing the workaround gets ride of the ICE:
#[derive(Debug)]
pub struct HalSetLayouts {
    vertex_layout: <B as hal::Backend>::DescriptorSetLayout,
    fragment_layout: <B as hal::Backend>::DescriptorSetLayout,
    fragment_sampler_layout: <B as hal::Backend>::DescriptorSetLayout,
}
impl HalSetLayouts {
    fn iter(
        &self,
    ) -> impl ExactSizeIterator<Item = &<B as hal::Backend>::DescriptorSetLayout> + '_ {
        std::iter::once(&self.vertex_layout)
            .chain(std::iter::once(&self.fragment_layout))
            .chain(std::iter::once(&self.fragment_sampler_layout))
            .exact(3)
    }
}Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.