Skip to content

Nightly 2022-03-30 ICE: Collection VecMap(...) should have just one matching element #95538

Closed
@nicholasbishop

Description

@nicholasbishop

Code

I ran into this error when compiling the fatfs crate with nightly. I reduced the example down to this, no external deps needed:

use core::marker::PhantomData;

pub struct ConcreteError {}
pub trait IoBase {}
struct X {}
impl IoBase for X {}

pub struct ClusterIterator<B, E, S = B> {
    pub fat: B,
    phantom_s: PhantomData<S>,
    phantom_e: PhantomData<E>,
}

pub struct FileSystem<IO: IoBase> {
    pub disk: IO,
}

impl<IO: IoBase> FileSystem<IO> {
    pub fn cluster_iter(&self) -> ClusterIterator<impl IoBase + '_, ConcreteError> {
        ClusterIterator {
            fat: X {},
            phantom_s: PhantomData::default(),
            phantom_e: PhantomData::default(),
        }
    }
}

Playground link

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (c5cf08d37 2022-03-30)
binary: rustc
commit-hash: c5cf08d37b85f953b132951e868df5b924250fdc
commit-date: 2022-03-30
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Compiles without errors on current stable/beta.

Error output

thread 'rustc' panicked at 'Collection VecMap(
    [
        (
            OpaqueTypeKey {
                def_id: DefId(0:23 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter::{opaque#0}),
                substs: [
                    IO,
                    ReFree(DefId(0:22 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter), BrAnon(0)),
                ],
            },
            OpaqueHiddenType {
                span: src/lib.rs:20:9: 24:10 (#0),
                ty: X,
            },
        ),
        (
            OpaqueTypeKey {
                def_id: DefId(0:23 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter::{opaque#0}),
                substs: [
                    IO,
                    ReFree(DefId(0:22 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter), BrAnon(0)),
                ],
            },
            OpaqueHiddenType {
                span: src/lib.rs:20:9: 24:10 (#0),
                ty: X,
            },
        ),
    ],
) should have just one matching element', /rustc/c5cf08d37b85f953b132951e868df5b924250fdc/compiler/rustc_data_structures/src/vec_map.rs:73:9
Backtrace

   Compiling fatfs-ice-bug v0.0.0 (/var/home/nbishop/src/fatfs-ice-bug)
thread 'rustc' panicked at 'Collection VecMap(
    [
        (
            OpaqueTypeKey {
                def_id: DefId(0:23 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter::{opaque#0}),
                substs: [
                    IO,
                    ReFree(DefId(0:22 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter), BrAnon(0)),
                ],
            },
            OpaqueHiddenType {
                span: src/lib.rs:20:9: 24:10 (#0),
                ty: X,
            },
        ),
        (
            OpaqueTypeKey {
                def_id: DefId(0:23 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter::{opaque#0}),
                substs: [
                    IO,
                    ReFree(DefId(0:22 ~ fatfs_ice_bug[684c]::{impl#1}::cluster_iter), BrAnon(0)),
                ],
            },
            OpaqueHiddenType {
                span: src/lib.rs:20:9: 24:10 (#0),
                ty: X,
            },
        ),
    ],
) should have just one matching element', /rustc/c5cf08d37b85f953b132951e868df5b924250fdc/compiler/rustc_data_structures/src/vec_map.rs:73:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c5cf08d37b85f953b132951e868df5b924250fdc/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/c5cf08d37b85f953b132951e868df5b924250fdc/library/core/src/panicking.rs:143:14
   2: rustc_typeck::collect::type_of::type_of
   3: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId, rustc_middle::ty::Ty>
   4: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
   5: rustc_typeck::check::check::check_item_type
   6: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck::check::CheckItemTypesVisitor>
   7: rustc_typeck::check::check::check_mod_item_types
   8: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, ()>
   9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  10: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  11: <rustc_middle::hir::map::Map>::for_each_module::<rustc_typeck::check_crate::{closure#6}::{closure#0}>
  12: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#6}>
  13: rustc_typeck::check_crate
  14: rustc_interface::passes::analysis
  15: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  17: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  18: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  19: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  20: 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}>
  21: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  22: <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.

error: internal compiler error: unexpected panic

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.61.0-nightly (c5cf08d37 2022-03-30) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [type_of] computing type of `<impl at src/lib.rs:18:1: 26:2>::cluster_iter::{opaque#0}`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `fatfs-ice-bug`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions