Skip to content

Nightly ICE: 'no errors encountered even though delay_span_bug issued' and 'unresolved inference variable in outlives: ?8t' #114783

Closed
@burtonageo

Description

@burtonageo

Code

use smallvec::{SmallVec};
use std::marker::PhantomData;

struct Element {}

trait AsBufferView {
    type Device: Device;
    type View;
    fn as_raw_buffer(&self) -> &<Self::Device as Device>::Buffer;
    fn as_buffer_view(&self) -> &Self::View;
}

trait InputLayoutArray {
    const LAYOUTS: &'static [&'static [Element]];
}

impl<V: InputLayout> InputLayoutArray for V {
    const LAYOUTS: &'static [&'static [Element]] = &[<V as InputLayout>::LAYOUT];
}

trait InputLayout {
    const LAYOUT: &'static [Element];
}

macro_rules! impl_input_layout_array {
    () => {};
    (($vtx_id:ident $(,)?)) => {};
    (($vtx_id:ident, $($rest:ident),+ $(,)?)) => {
        impl_input_layout_array! { ($($rest),+ ) }
        impl<$vtx_id, $($rest),+> InputLayoutArray for ($vtx_id, $($rest),+)
        where
            $vtx_id: InputLayout,
            $($rest: InputLayout),+
        {
            const LAYOUTS: &'static [&'static [Element]] = &[];
        }
    };
}

impl_input_layout_array! { (V16, V15, V14, V13, V12, V11, V10, V9, V8, V7, V6, V5, V4, V3, V2, V1, V0,) }

impl<V: InputLayout> InputLayout for (V,) {
    const LAYOUT: &'static [Element] = <V as InputLayout>::LAYOUT;
}

trait Device {
    type Buffer;
}

trait VertexBufferInputs {
    type VertexInput: InputLayoutArray;
    type Device: Device;
    fn buffers(&self) -> SmallVec<[&<Self::Device as Device>::Buffer; MAX_VERTEX_BUFFERS]>;
}

const MAX_VERTEX_BUFFERS: usize = 8;

struct VertexBufferView<V, Device> {
    _boo: PhantomData<(V, Device)>,
}

macro_rules! impl_vertex_buffer_inputs {
    (($vtx_id:ident : $vbuf_id:ident $(,)?)) => {
        impl<D: Device, $vtx_id, $vbuf_id> VertexBufferInputs for (&'_ $vbuf_id,)
        where
            $vtx_id: InputLayout,
            $vbuf_id: AsBufferView<Device = D, View = VertexBufferView<$vtx_id, D>>,
        {
            type VertexInput = ($vtx_id,);
            type Device = D;

            fn buffers(&self) -> SmallVec<[&<Self::Device as Device>::Buffer; MAX_VERTEX_BUFFERS]> {
                loop {}
            }
        }
    };
    (($vtx_id:ident : $vbuf_id:ident , $($vtx_id_rest:ident : $vbuf_id_rest:ident ),+ $(,)?)) => {
        impl_vertex_buffer_inputs!{ ( $( $vtx_id_rest : $vbuf_id_rest ),+ ) }

        impl<D, $vtx_id, $($vtx_id_rest),+, $vbuf_id, $($vbuf_id_rest),+,> VertexBufferInputs for (
            &'_ $vbuf_id, $( &'_ $vbuf_id_rest ),+ ,
        )
        where
            D: Device,
            $vtx_id: InputLayout,
            $( $vtx_id_rest: InputLayout ),+ ,
            $vbuf_id: AsBufferView<Device = D, View = VertexBufferView<$vtx_id, D>>,
            $( $vbuf_id_rest: AsBufferView<Device = D, View = VertexBufferView<$vtx_id_rest, D>> ),+
        {
            type VertexInput = ($vtx_id, $($vtx_id_rest),+ ,);
            type Device = D;

            fn buffers(&self) -> SmallVec<[&<Self::Device as Device>::Buffer; MAX_VERTEX_BUFFERS]> {
                loop {}
            }
        }
    };
}

impl_vertex_buffer_inputs! {
    (V7: VBuf7, V6: VBuf6, V5: VBuf5, V4: VBuf4, V3: VBuf3, V2: VBuf2, V1: VBuf1, V0: VBuf0,)
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=45cbad8e49524de87a2501a6c9704eee

Meta

This code compiles on the stable and beta channels, but crashes with an ICE on the nightly channel.

rustc --version --verbose:

Build using the Nightly version: 1.73.0-nightly
(2023-08-12 28eb857b9504bd05bbed)

Error output

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

error: internal compiler error: unresolved inference variable in outlives: ?8t
   --> src/lib.rs:72:13
    |
72  |               fn buffers(&self) -> SmallVec<[&<Self::Device as Device>::Buffer; MAX_VERTEX_BUFFERS]> {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
100 | / impl_vertex_buffer_inputs! {
101 | |     (V7: VBuf7, V6: VBuf6, V5: VBuf5, V4: VBuf4, V3: VBuf3, V2: VBuf2, V1: VBuf1, V0: VBuf0,)
102 | | }
    | |_- in this macro invocation
    |

(Backtrace omitted)

   --> src/lib.rs:72:13
    |
72  |               fn buffers(&self) -> SmallVec<[&<Self::Device as Device>::Buffer; MAX_VERTEX_BUFFERS]> {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
100 | / impl_vertex_buffer_inputs! {
101 | |     (V7: VBuf7, V6: VBuf6, V5: VBuf5, V4: VBuf4, V3: VBuf3, V2: VBuf2, V1: VBuf1, V0: VBuf0,)
102 | | }
    | |_- in this macro invocation
    = note: this error: internal compiler error originates in the macro `impl_vertex_buffer_inputs` (in Nightly builds, run with -Z macro-backtrace for more info)

.. And so on for ?10t, ?11t, etc.

Backtrace

note: delayed at compiler/rustc_infer/src/infer/outlives/obligations.rs:254:35
         0: <rustc_errors::HandlerInner>::emit_diagnostic
         1: <rustc_session::session::Session>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         2: <rustc_infer::infer::outlives::obligations::TypeOutlives<&rustc_infer::infer::InferCtxt>>::components_must_outlive
         3: <rustc_infer::infer::InferCtxt>::resolve_regions
         4: rustc_hir_analysis::check::compare_impl_item::compare_method_predicate_entailment
         5: rustc_hir_analysis::check::check::check_mod_item_types
         6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
         7: <rustc_query_impl::query_impl::check_mod_item_types::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
         8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         9: rustc_query_impl::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
        10: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
        11: rustc_hir_analysis::check_crate
        12: rustc_interface::passes::analysis
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        14: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        16: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        17: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#6}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        18: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
        19: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        20: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/28eb857b9504bd05bbed0cf8af8e825fbdbb1fa1/library/alloc/src/boxed.rs:2007:9
        22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/28eb857b9504bd05bbed0cf8af8e825fbdbb1fa1/library/alloc/src/boxed.rs:2007:9
        23: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/28eb857b9504bd05bbed0cf8af8e825fbdbb1fa1/library/std/src/sys/unix/thread.rs:108:17
        24: start_thread
        25: clone

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions