Skip to content

ICE with Bevy on nightly #87531

Closed
Closed
@deontologician

Description

@deontologician

Code

use bevy::{
    ecs::query::{Fetch, FilterFetch, WorldQuery},
    prelude::*,
};

pub(crate) fn get_children_mut<Q, F, C>(children: &Children, q: &mut Query<Q, F>, mut callback: C)
where
    C: FnMut(<<Q as WorldQuery>::Fetch as Fetch>::Item),
    Q: WorldQuery,
    F: WorldQuery,
    F::Fetch: FilterFetch,
{
    children.iter().for_each(move |child_id| {
        if let Ok(result) = q.get_mut(*child_id) {
            callback(result);
        }
    });
}

fn query_children_system(children: Query<&Children>, mut selections: Query<Entity>) {
    for children in children.iter() {
        get_children_mut(children, &mut selections, |_| {})
    }
}

fn main() {
    App::build().add_system(query_children_system.system());
}
Cargo.toml

[package]
name = "ice_repro"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = {version="0.5.0", default-features=false}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (08095fc1f 2021-07-26)
binary: rustc
commit-hash: 08095fc1f875c89e507f17cf6c6a780c8ffa4c01
commit-date: 2021-07-26
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Additionally, I have the following .cargo/config.toml

[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]

Error output

error: internal compiler error: compiler/rustc_trait_selection/src/traits/codegen.rs:78:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:23:53: 23:59] as std::ops::FnMut<(<bevy::ecs::query::EntityFetch as bevy::ecs::query::Fetch<'_>>::Item,)>>, [Region(BrAnon(0))]), Binder(<[closure@src/main.rs:23:53: 23:59] as std::ops::FnMut<(bevy::prelude::Entity,)>>, []), Sorts(ExpectedFound { expected: bevy::prelude::Entity, found: <bevy::ecs::query::EntityFetch as bevy::ecs::query::Fetch<'_>>::Item }))` selecting `Binder(<[closure@src/main.rs:23:53: 23:59] as std::ops::FnMut<(bevy::prelude::Entity,)>>, [])` during codegen

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.56.0-nightly (08095fc1f 2021-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z share-generics=y -C opt-level=3 -C embed-bitcode=no -C linker=/usr/bin/clang -C link-arg=-fuse-ld=lld --crate-type bin

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

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `std::ops::FnMut` fulfills its obligations
#1 [resolve_instance] resolving instance `<[closure@src/main.rs:23:53: 23:59] as std::ops::FnMut<(bevy::prelude::Entity,)>>::call_mut`
end of query stack
error: could not compile `ice_repro`
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1034:9
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_infer::infer::InferCtxtBuilder::enter
   8: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation
   9: rustc_query_system::query::plumbing::get_query_impl
  10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::codegen_fulfill_obligation
  11: rustc_ty_utils::instance::inner_resolve_instance
  12: rustc_ty_utils::instance::resolve_instance
  13: rustc_query_system::query::plumbing::get_query_impl
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_instance
  15: rustc_middle::ty::instance::Instance::resolve_opt_const_arg
  16: rustc_middle::ty::instance::Instance::resolve
  17: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
  18: rustc_mir::monomorphize::collector::collect_neighbours
  19: rustc_mir::monomorphize::collector::collect_items_rec
  20: rustc_mir::monomorphize::collector::collect_items_rec
  21: rustc_mir::monomorphize::collector::collect_items_rec
  22: rustc_mir::monomorphize::collector::collect_items_rec
  23: rustc_mir::monomorphize::collector::collect_items_rec
  24: rustc_mir::monomorphize::collector::collect_items_rec
  25: rustc_mir::monomorphize::collector::collect_items_rec
  26: rustc_mir::monomorphize::collector::collect_items_rec
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_mir::monomorphize::collector::collect_items_rec
  30: rustc_mir::monomorphize::collector::collect_items_rec
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_items_rec
  33: rustc_mir::monomorphize::collector::collect_items_rec
  34: rustc_mir::monomorphize::collector::collect_items_rec
  35: rustc_mir::monomorphize::collector::collect_crate_mono_items
  36: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  37: rustc_query_system::query::plumbing::get_query_impl
  38: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
  39: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  40: rustc_interface::passes::QueryContext::enter
  41: rustc_interface::queries::Queries::ongoing_codegen
  42: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  43: rustc_span::with_source_map
  44: rustc_interface::interface::create_compiler_and_run
  45: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-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