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

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

Closed
nicholasbishop opened this issue Mar 31, 2022 · 7 comments · Fixed by #95731
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@nicholasbishop
Copy link
Contributor

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`

@nicholasbishop nicholasbishop 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 Mar 31, 2022
@nicholasbishop
Copy link
Contributor Author

Bisected:

searched nightlies: from nightly-2022-03-29 to nightly-2022-03-31
regressed nightly: nightly-2022-03-31
searched commit range: 9c06e1b...c5cf08d
regressed commit: f132bcf

bisected with cargo-bisect-rustc v0.6.1

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc 

@compiler-errors
Copy link
Member

cc @oli-obk and #94081

@oli-obk
Copy link
Contributor

oli-obk commented Mar 31, 2022

Huh how did we miss this on crater?

Either way, I know how to fix this. Maybe i'll even get it in before the beta cutoff. But even if not, the fix will be small and easily backported

@oli-obk oli-obk added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Mar 31, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 31, 2022
@nicholasbishop
Copy link
Contributor Author

Huh how did we miss this on crater?

I ran into the compilation error testing against the master branch of fatfs, the latest version released on crates.io doesn't trigger the issue.

nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Apr 1, 2022
The nightly rust compiler is currently unable to compile the version of
fatfs we are using in xtask. Rust bug:
rust-lang/rust#95538. But we don't need to use
nightly to compile xtask. In the CI, install both stable and nightly
toolchains. The stable toolchain will be used by default, and xtask
already knows to insert `+nightly` when building uefi-rs, so there's no
need to set `override: true` for the nightly toolchain anymore.

Fixes #397
nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Apr 1, 2022
The nightly rust compiler is currently unable to compile the version of
fatfs we are using in xtask. Rust bug:
rust-lang/rust#95538. But we don't need to use
nightly to compile xtask. In the CI, install both stable and nightly
toolchains. The stable toolchain will be used by default, and xtask
already knows to insert `+nightly` when building uefi-rs, so there's no
need to set `override: true` for the nightly toolchain anymore.

Fixes #397
nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Apr 1, 2022
The nightly rust compiler is currently unable to compile the version of
fatfs we are using in xtask. Rust bug:
rust-lang/rust#95538. But we don't need to use
nightly to compile xtask. In the CI, install both stable and nightly
toolchains. The stable toolchain will be used by default, and xtask
already knows to insert `+nightly` when building uefi-rs, so there's no
need to set `override: true` for the nightly toolchain anymore.

Fixes #397
nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Apr 1, 2022
The nightly rust compiler is currently unable to compile the version of
fatfs we are using in xtask. Rust bug:
rust-lang/rust#95538. But we don't need to use
nightly to compile xtask. In the CI, install both stable and nightly
toolchains. The stable toolchain will be used by default, and xtask
already knows to insert `+nightly` when building uefi-rs, so there's no
need to set `override: true` for the nightly toolchain anymore.

Fixes #397
nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Apr 1, 2022
The nightly rust compiler is currently unable to compile the version of
fatfs we are using in xtask. Rust bug:
rust-lang/rust#95538. But we don't need to use
nightly to compile xtask. In the CI, install both stable and nightly
toolchains. The stable toolchain will be used by default, and xtask
already knows to insert `+nightly` when building uefi-rs, so there's no
need to set `override: true` for the nightly toolchain anymore.

Fixes #397
@oli-obk oli-obk added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Apr 6, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Apr 6, 2022
…piler-errors

Check that all hidden types are the same and then deduplicate them.

fixes rust-lang#95538

This used to trigger a sanity check. Now we accept that there may be multiple places where a hidden type is constrained and we merge all of these at the end.

Ideally we'd merge eagerly, but that is a larger refactoring that I don't want to put into a backport
@apiraino
Copy link
Contributor

apiraino commented Apr 6, 2022

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 6, 2022
@pietroalbini pietroalbini added this to the 1.61.0 milestone Apr 6, 2022
@bors bors closed this as completed in ebba894 Apr 6, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Apr 7, 2022

Still in beta, leaving open until we backport the PR

@oli-obk oli-obk reopened this Apr 7, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Apr 28, 2022

Backported in #96367

@oli-obk oli-obk closed this as completed Apr 28, 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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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.

6 participants