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

ICE in codegen_fulfill_obligation #86884

Closed
TethysSvensson opened this issue Jul 5, 2021 · 2 comments
Closed

ICE in codegen_fulfill_obligation #86884

TethysSvensson opened this issue Jul 5, 2021 · 2 comments
Labels
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.

Comments

@TethysSvensson
Copy link
Contributor

Code

trait AddLifetime<'a> {
    type Output: Apply;
}

impl<'a> AddLifetime<'a> for () {
    type Output = &'a ();
}

trait Apply {
    fn apply<F>(f: F)
    where
        for<'a> F: Fn(&'a mut Self);
}

impl<'a> Apply for &'a () {
    fn apply<F>(f: F)
    where
        for<'b> F: Fn(&'b mut &'a ()),
    {
        f(&mut &())
    }
}

fn crash<T, F>(f: F)
where
    for<'a> T: AddLifetime<'a>,
    for<'outer, 'inner> F: Fn(&'outer mut <T as AddLifetime<'inner>>::Output),
{
    <T as AddLifetime<'static>>::Output::apply(f);
}

fn main() {
    crash::<(), _>(|_| {});
}

Meta

I get an ICE on 1.21.0, 1.53.0 and current nightly:

rustc --version --verbose:

rustc 1.21.0 (3b72af97e 2017-10-09)
binary: rustc
commit-hash: 3b72af97e42989b2fe104d8edbaee123cdf7c58f
commit-date: 2017-10-09
host: x86_64-unknown-linux-gnu
release: 1.21.0
LLVM version: 4.0

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

rustc 1.55.0-nightly (b3d11f95c 2021-07-04)
binary: rustc
commit-hash: b3d11f95cc5dd687fdd185ce91e02ebe40e6f46b
commit-date: 2021-07-04
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

I do not get an ICE on 1.20 (though it does not compile either).

Error output

error: internal compiler error: compiler/rustc_trait_selection/src/traits/codegen.rs:78:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut <() as AddLifetime<'_>>::Output,)>>, [Region(BrAnon(0)), Region(BrAnon(1))]), Binder(<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut &(),)>>, []), Sorts(ExpectedFound { expected: &(), found: <() as AddLifetime<'_>>::Output }))` selecting `Binder(<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut &(),)>>, [])` during codegen
Backtrace

error: internal compiler error: compiler/rustc_trait_selection/src/traits/codegen.rs:78:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut <() as AddLifetime<'_>>::Output,)>>, [Region(BrAnon(0)), Region(BrAnon(1))]), Binder(<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut &(),)>>, []), Sorts(ExpectedFound { expected: &(), found: <() as AddLifetime<'_>>::Output }))` selecting `Binder(<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut &(),)>>, [])` during codegen

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1006: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_crate_mono_items
  23: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  24: rustc_query_system::query::plumbing::get_query_impl
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items
  26: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  27: rustc_interface::passes::QueryContext::enter
  28: rustc_interface::queries::Queries::ongoing_codegen
  29: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  30: rustc_span::with_source_map
  31: rustc_interface::interface::create_compiler_and_run
  32: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.55.0-nightly (b3d11f95c 2021-07-04) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `std::ops::Fn` fulfills its obligations
#1 [resolve_instance] resolving instance `<[closure@src/main.rs:33:20: 33:26] as std::ops::Fn<(&mut &(),)>>::call`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

@TethysSvensson TethysSvensson 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 Jul 5, 2021
@jonas-schievink
Copy link
Contributor

This is probably #62529

@jackh726
Copy link
Member

jackh726 commented Jul 5, 2021

Yes, closing as duplicate of that issue. There are plenty of MCVEs.

@jackh726 jackh726 closed this as completed Jul 5, 2021
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants