Skip to content

cannot relate bound region #107359

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

Closed
matiu2 opened this issue Jan 27, 2023 · 10 comments
Closed

cannot relate bound region #107359

matiu2 opened this issue Jan 27, 2023 · 10 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue

Comments

@matiu2
Copy link

matiu2 commented Jan 27, 2023

❯ cargo run
warning: Both `/home/matt/.cargo/config` and `/home/matt/.cargo/config.toml` exist. Using `/home/matt/.cargo/config`
warning: Both `/home/matt/.cargo/config` and `/home/matt/.cargo/config.toml` exist. Using `/home/matt/.cargo/config`
   Compiling tutorial v0.1.0 (/home/matt/tmp/bevy_fun/tutorial)
error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/mod.rs:568:17: cannot relate bound region: ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed(DefId(0:100 ~ tutorial[6788]::tower_shooting::'_#1), '_) }) <= '_#6r

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/compiler/rustc_errors/src/lib.rs:987:33
stack backtrace:
   0:     0x7f5fbf88d37a - std::backtrace_rs::backtrace::libunwind::trace::ha290699541004f30
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f5fbf88d37a - std::backtrace_rs::backtrace::trace_unsynchronized::h4c12963c7e95ab11
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5fbf88d37a - std::sys_common::backtrace::_print_fmt::h2b3eaa30ddc0ee2d
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f5fbf88d37a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h900e2c13a0fcda75
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5fbf8ef54e - core::fmt::write::h1241c45300ec0a98
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/core/src/fmt/mod.rs:1232:17
   5:     0x7f5fbf87d9c5 - std::io::Write::write_fmt::h1fa3d809305fde12
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/io/mod.rs:1682:15
   6:     0x7f5fbf88d145 - std::sys_common::backtrace::_print::h37ad70ae3ed5e392
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f5fbf88d145 - std::sys_common::backtrace::print::hb18fae09aae86706
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f5fbf88ff0f - std::panicking::default_hook::{{closure}}::h61e8501d4cade4d7
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/panicking.rs:267:22
   9:     0x7f5fbf88fc4b - std::panicking::default_hook::h7df67ced13e02472
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/panicking.rs:286:9
  10:     0x7f5fc2bfafa4 - <rustc_driver[4f4c005fc6b930b3]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[2098946a533c2ab6]::ops::function::FnOnce<(&core[2098946a533c2ab6]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f5fbf89074a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h26b1b208c06f143d
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/alloc/src/boxed.rs:2002:9
  12:     0x7f5fbf89074a - std::panicking::rust_panic_with_hook::hf0a2947b8c702055
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/panicking.rs:692:13
  13:     0x7f5fc2ec25d1 - std[461ac1d5315fb0d7]::panicking::begin_panic::<rustc_errors[46efac55c92811ef]::ExplicitBug>::{closure#0}
  14:     0x7f5fc2ebb3c6 - std[461ac1d5315fb0d7]::sys_common::backtrace::__rust_end_short_backtrace::<std[461ac1d5315fb0d7]::panicking::begin_panic<rustc_errors[46efac55c92811ef]::ExplicitBug>::{closure#0}, !>
  15:     0x7f5fc2f4f746 - std[461ac1d5315fb0d7]::panicking::begin_panic::<rustc_errors[46efac55c92811ef]::ExplicitBug>
  16:     0x7f5fc2f4f736 - std[461ac1d5315fb0d7]::panic::panic_any::<rustc_errors[46efac55c92811ef]::ExplicitBug>
  17:     0x7f5fc2f4e042 - <rustc_errors[46efac55c92811ef]::HandlerInner>::span_bug::<rustc_span[b1b056f3db188264]::span_encoding::Span, &alloc[63176bf10fb73169]::string::String>
  18:     0x7f5fc2f4dee7 - <rustc_errors[46efac55c92811ef]::Handler>::span_bug::<rustc_span[b1b056f3db188264]::span_encoding::Span, &alloc[63176bf10fb73169]::string::String>
  19:     0x7f5fc2f224eb - rustc_middle[cbbe7a1012a9822]::util::bug::opt_span_bug_fmt::<rustc_span[b1b056f3db188264]::span_encoding::Span>::{closure#0}
  20:     0x7f5fc2f2253a - rustc_middle[cbbe7a1012a9822]::ty::context::tls::with_opt::<rustc_middle[cbbe7a1012a9822]::util::bug::opt_span_bug_fmt<rustc_span[b1b056f3db188264]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f5fc2f20d5a - rustc_middle[cbbe7a1012a9822]::ty::context::tls::with_context_opt::<rustc_middle[cbbe7a1012a9822]::ty::context::tls::with_opt<rustc_middle[cbbe7a1012a9822]::util::bug::opt_span_bug_fmt<rustc_span[b1b056f3db188264]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f5fc2f20d06 - rustc_middle[cbbe7a1012a9822]::util::bug::opt_span_bug_fmt::<rustc_span[b1b056f3db188264]::span_encoding::Span>
  23:     0x7f5fc2f20cc4 - rustc_middle[cbbe7a1012a9822]::util::bug::span_bug_fmt::<rustc_span[b1b056f3db188264]::span_encoding::Span>
  24:     0x7f5fc0b5852b - <rustc_middle[cbbe7a1012a9822]::ty::sty::Region as rustc_middle[cbbe7a1012a9822]::ty::relate::Relate>::relate::<rustc_infer[2e465ab884afa1e4]::infer::equate::Equate>
  25:     0x7f5fc0b53405 - rustc_middle[cbbe7a1012a9822]::ty::relate::super_relate_tys::<rustc_infer[2e465ab884afa1e4]::infer::equate::Equate>
  26:     0x7f5fc0b507de - <rustc_infer[2e465ab884afa1e4]::infer::equate::Equate as rustc_middle[cbbe7a1012a9822]::ty::relate::TypeRelation>::tys
  27:     0x7f5fc1460d53 - <rustc_infer[2e465ab884afa1e4]::infer::InferCtxt>::commit_if_ok::<rustc_infer[2e465ab884afa1e4]::infer::InferOk<()>, rustc_middle[cbbe7a1012a9822]::ty::error::TypeError, <rustc_infer[2e465ab884afa1e4]::infer::at::Trace>::eq<rustc_middle[cbbe7a1012a9822]::ty::Ty>::{closure#0}>
  28:     0x7f5fc1460c47 - <rustc_infer[2e465ab884afa1e4]::infer::at::At>::eq::<rustc_middle[cbbe7a1012a9822]::ty::Ty>
  29:     0x7f5fc37ee4bd - <rustc_infer[2e465ab884afa1e4]::infer::InferCtxt>::can_eq::<rustc_middle[cbbe7a1012a9822]::ty::Ty>
  30:     0x7f5fc37c3531 - rustc_trait_selection[758794050b515043]::traits::error_reporting::suggestions::hint_missing_borrow
  31:     0x7f5fc387e7e4 - <rustc_infer[2e465ab884afa1e4]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[758794050b515043]::traits::error_reporting::suggestions::TypeErrCtxtExt>::report_closure_arg_mismatch
  32:     0x7f5fc388e7c4 - <rustc_infer[2e465ab884afa1e4]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[758794050b515043]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  33:     0x7f5fc3898174 - <rustc_infer[2e465ab884afa1e4]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[758794050b515043]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  34:     0x7f5fc388b80f - <rustc_infer[2e465ab884afa1e4]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[758794050b515043]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  35:     0x7f5fc0cf66a5 - <rustc_hir_typeck[ceb93022495db012]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  36:     0x7f5fc0d27296 - <rustc_hir_typeck[ceb93022495db012]::fn_ctxt::FnCtxt>::check_block_with_expected
  37:     0x7f5fc0cee7a0 - <rustc_hir_typeck[ceb93022495db012]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  38:     0x7f5fc14f75ba - <rustc_hir_typeck[ceb93022495db012]::fn_ctxt::FnCtxt>::check_return_expr
  39:     0x7f5fc14ef228 - rustc_hir_typeck[ceb93022495db012]::check::check_fn
  40:     0x7f5fc14d9041 - <rustc_hir_typeck[ceb93022495db012]::inherited::InheritedBuilder>::enter::<rustc_hir_typeck[ceb93022495db012]::typeck_with_fallback<rustc_hir_typeck[ceb93022495db012]::typeck::{closure#0}>::{closure#0}::{closure#1}, &rustc_middle[cbbe7a1012a9822]::ty::typeck_results::TypeckResults>
  41:     0x7f5fc14d221b - rustc_hir_typeck[ceb93022495db012]::typeck
  42:     0x7f5fc14d6f07 - <rustc_query_system[eb520fa8adeac350]::dep_graph::graph::DepGraph<rustc_middle[cbbe7a1012a9822]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[cbbe7a1012a9822]::ty::context::TyCtxt, rustc_span[b1b056f3db188264]::def_id::LocalDefId, &rustc_middle[cbbe7a1012a9822]::ty::typeck_results::TypeckResults>
  43:     0x7f5fc14cc03b - rustc_query_system[eb520fa8adeac350]::query::plumbing::try_execute_query::<rustc_query_impl[84a096d6d037a5dc]::queries::typeck, rustc_query_impl[84a096d6d037a5dc]::plumbing::QueryCtxt>
  44:     0x7f5fc234cccd - rustc_data_structures[52ff836d32708050]::sync::par_for_each_in::<&[rustc_span[b1b056f3db188264]::def_id::LocalDefId], <rustc_middle[cbbe7a1012a9822]::hir::map::Map>::par_body_owners<rustc_hir_typeck[ceb93022495db012]::typeck_item_bodies::{closure#0}>::{closure#0}>
  45:     0x7f5fc234ca63 - rustc_hir_typeck[ceb93022495db012]::typeck_item_bodies
  46:     0x7f5fc2362617 - <rustc_query_system[eb520fa8adeac350]::dep_graph::graph::DepGraph<rustc_middle[cbbe7a1012a9822]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[cbbe7a1012a9822]::ty::context::TyCtxt, (), ()>
  47:     0x7f5fc2175016 - rustc_query_system[eb520fa8adeac350]::query::plumbing::try_execute_query::<rustc_query_impl[84a096d6d037a5dc]::queries::typeck_item_bodies, rustc_query_impl[84a096d6d037a5dc]::plumbing::QueryCtxt>
  48:     0x7f5fc25b1a1b - <rustc_query_impl[84a096d6d037a5dc]::Queries as rustc_middle[cbbe7a1012a9822]::ty::query::QueryEngine>::typeck_item_bodies
  49:     0x7f5fc12600b2 - <rustc_session[fb8c882b67069fba]::session::Session>::time::<(), rustc_hir_analysis[6e380b641fa4c075]::check_crate::{closure#7}>
  50:     0x7f5fc125ecbc - rustc_hir_analysis[6e380b641fa4c075]::check_crate
  51:     0x7f5fc125e8eb - rustc_interface[1fb19c72a897d5ec]::passes::analysis
  52:     0x7f5fc23867b6 - <rustc_query_system[eb520fa8adeac350]::dep_graph::graph::DepGraph<rustc_middle[cbbe7a1012a9822]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[cbbe7a1012a9822]::ty::context::TyCtxt, (), core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>
  53:     0x7f5fc2385dc1 - rustc_query_system[eb520fa8adeac350]::query::plumbing::try_execute_query::<rustc_query_impl[84a096d6d037a5dc]::queries::analysis, rustc_query_impl[84a096d6d037a5dc]::plumbing::QueryCtxt>
  54:     0x7f5fc25aaa2a - <rustc_query_impl[84a096d6d037a5dc]::Queries as rustc_middle[cbbe7a1012a9822]::ty::query::QueryEngine>::analysis
  55:     0x7f5fc22b7370 - <rustc_interface[1fb19c72a897d5ec]::passes::QueryContext>::enter::<rustc_driver[4f4c005fc6b930b3]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>
  56:     0x7f5fc1e00f76 - rustc_span[b1b056f3db188264]::with_source_map::<core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>, rustc_interface[1fb19c72a897d5ec]::interface::run_compiler<core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>, rustc_driver[4f4c005fc6b930b3]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  57:     0x7f5fc1df93e4 - <scoped_tls[325847e5b688dec6]::ScopedKey<rustc_span[b1b056f3db188264]::SessionGlobals>>::set::<rustc_interface[1fb19c72a897d5ec]::interface::run_compiler<core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>, rustc_driver[4f4c005fc6b930b3]::run_compiler::{closure#1}>::{closure#0}, core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>
  58:     0x7f5fc1df8ae2 - std[461ac1d5315fb0d7]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1fb19c72a897d5ec]::util::run_in_thread_pool_with_globals<rustc_interface[1fb19c72a897d5ec]::interface::run_compiler<core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>, rustc_driver[4f4c005fc6b930b3]::run_compiler::{closure#1}>::{closure#0}, core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>
  59:     0x7f5fc1df888a - <<std[461ac1d5315fb0d7]::thread::Builder>::spawn_unchecked_<rustc_interface[1fb19c72a897d5ec]::util::run_in_thread_pool_with_globals<rustc_interface[1fb19c72a897d5ec]::interface::run_compiler<core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>, rustc_driver[4f4c005fc6b930b3]::run_compiler::{closure#1}>::{closure#0}, core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2098946a533c2ab6]::result::Result<(), rustc_errors[46efac55c92811ef]::ErrorGuaranteed>>::{closure#1} as core[2098946a533c2ab6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  60:     0x7f5fbf89a813 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3c13af4dc753235c
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/alloc/src/boxed.rs:1988:9
  61:     0x7f5fbf89a813 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0cec7c2c35746e2e
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/alloc/src/boxed.rs:1988:9
  62:     0x7f5fbf89a813 -
[files.zip](https://github.com/rust-lang/rust/files/10518504/files.zip)
 std::sys::unix::thread::Thread::new::thread_start::heea3e3f3ff9e2de9
                               at /rustc/d7948c843de94245c794e8c63dd4301a78bb5ba3/library/std/src/sys/unix/thread.rs:108:17
  63:     0x7f5fbf749609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  64:     0x7f5fbf66c133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  65:                0x0 - <unknown>

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.69.0-nightly (d7948c843 2023-01-26) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=lld -Z share-generics=y

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

query stack during panic:
#0 [typeck] type-checking `tower_shooting`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `tutorial`
@matiu2
Copy link
Author

matiu2 commented Jan 27, 2023

Linux HSTAU-PF2W4WMD 5.14.0-1054-oem #61-Ubuntu SMP Fri Oct 14 13:05:50 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux```

@Rageking8
Copy link
Contributor

@rustbot label +I-ICE +C-bug +E-needs-mcve

@rustbot rustbot added C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 27, 2023
@matiu2
Copy link
Author

matiu2 commented Jan 27, 2023

On stable it gives this compile error instead of crashing:

error[E0631]: type mismatch in closure arguments
   --> src/main.rs:97:10
    |
97  |         .filter(|tower: &mut bevy::prelude::Mut<'_, Tower>| {
    |          ^^^^^^ ------------------------------------------- found signature defined here
    |          |
    |          expected due to this
    |
    = note: expected closure signature `for<'a> fn(&'a Mut<'_, Tower>) -> _`
               found closure signature `for<'a, 'b> fn(&'a mut Mut<'b, Tower>) -> _`
note: required by a bound in `std::iter::Iterator::filter`
   --> /home/matt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:899:12
    |
899 |         P: FnMut(&Self::Item) -> bool,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::filter`

error[E0599]: the method `for_each` exists for struct `Filter<QueryIter<'_, '_, &mut Tower, ()>, [closure@src/main.rs:97:17: 97:60]>`, but its trait bounds were not satisfied
   --> src/main.rs:101:10
    |
97  |         .filter(|tower: &mut bevy::prelude::Mut<'_, Tower>| {
    |                 -------------------------------------------
    |                 |
    |                 doesn't satisfy `<_ as FnOnce<(&Mut<'_, Tower>,)>>::Output = bool`
    |                 doesn't satisfy `_: FnMut<(&Mut<'_, Tower>,)>`
...
101 |         .for_each(|tower| {
    |          ^^^^^^^^ method cannot be called on `Filter<QueryIter<'_, '_, &mut Tower, ()>, [closure@src/main.rs:97:17: 97:60]>` due to unsatisfied trait bounds
    |
   ::: /home/matt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/filter.rs:15:1
    |
15  | pub struct Filter<I, P> {
    | ----------------------- doesn't satisfy `_: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `<[closure@src/main.rs:97:17: 97:60] as FnOnce<(&Mut<'_, Tower>,)>>::Output = bool`
            which is required by `Filter<QueryIter<'_, '_, &mut Tower, ()>, [closure@src/main.rs:97:17: 97:60]>: Iterator`
            `[closure@src/main.rs:97:17: 97:60]: FnMut<(&Mut<'_, Tower>,)>`
            which is required by `Filter<QueryIter<'_, '_, &mut Tower, ()>, [closure@src/main.rs:97:17: 97:60]>: Iterator`
            `Filter<QueryIter<'_, '_, &mut Tower, ()>, [closure@src/main.rs:97:17: 97:60]>: Iterator`
            which is required by `&mut Filter<QueryIter<'_, '_, &mut Tower, ()>, [closure@src/main.rs:97:17: 97:60]>: Iterator`

Some errors have detailed explanations: E0599, E0631.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `tutorial` due to 2 previous errors

@VelvetToroyashi
Copy link

VelvetToroyashi commented Feb 11, 2023

Ran into this issue myself, and finally managed to get a minimal repo:

struct H<'a, T> {
    _marker: std::marker::PhantomData<&'a T>,
}

pub fn breaks<'a, F>(_: F)
    where F: core::ops::Fn(H<u8>) + 'a {}

For some reason, calling this with a func that takes a mutable reference to the argument causes an ICE.

For example:

let func = |should_not_be_mutable: &mut H<u8>| { };

breaks(func); // Oops! ICE!

N.B: Breaks in cargo 1.69.0-nightly (3c5af6bed 2023-01-24) and perhaps a few versions after; crashes on beta, but works fine on nightly. playground link

@sourcefrog
Copy link
Contributor

I found this could also happen on a closure that's inferred to take a value type but is expected to take a reference. On stable (rustc 1.68.0-beta.5 (003b6f2 2023-02-15)) this fails with

error[E0631]: type mismatch in closure arguments
   --> src/bin/conserve.rs:435:70
    |
425 |                 let observer = |event| match event {
    |                                ------- found signature defined here
...
435 |                 let stats = restore(&archive, destination, &options, observer)?;
    |                             -------                                  ^^^^^^^^ expected due to this
    |                             |
    |                             required by a bound introduced by this call
    |
    = note: expected closure signature `for<'a, 'b> fn(&'a conserve::restore::Event<'b>) -> _`
               found closure signature `fn(conserve::restore::Event<'_>) -> _`
note: required by a bound in `conserve::restore`
   --> /Users/mbp/src/conserve/src/restore.rs:79:8
    |
79  |     O: Fn(&Event),
    |        ^^^^^^^^^^ required by this bound in `conserve::restore`

For more information about this error, try `rustc --explain E0631`.
error: could not compile `conserve` due to previous error

I can try to minimize this if it would help beyond Velvet's example.

@Noratrieb Noratrieb removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 11, 2023
@Noratrieb
Copy link
Member

Noratrieb commented Mar 11, 2023

I also hit this while working on the compiler where I annotate closure argument types to get some more precise error messages because I needed help, the ICE was quite unhelpful :D
@rustbot label +I-prioritize

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 11, 2023
@lqd
Copy link
Member

lqd commented Mar 11, 2023

The MCVE seems fixed on beta/nightly.

@Noratrieb
Copy link
Member

I guess the fix isn't in the bootstrap compiler yet (2023-01-25).
@rustbot label -I-prioritize

@rustbot rustbot removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 11, 2023
@langston-barrett
Copy link
Contributor

@rustbot label +S-bug-has-mcve

@rustbot rustbot added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Mar 18, 2023
@Noratrieb Noratrieb added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 18, 2023
@aliemjay aliemjay removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 21, 2023
@aliemjay
Copy link
Member

This is fixed with sufficient tests, I believe. Closing in favor of #109361 which has an MCVE and to track a possible stable backport.

@aliemjay aliemjay closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2023
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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue
Projects
None yet
Development

No branches or pull requests

9 participants