Skip to content

ICE: assertion failed: Binder == Binder #121688

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

const fn cmp(x: fn(), y: for<'a> fn()) -> bool {
    unsafe { x == y }
}

original:

const fn cmp(x: fn(), y: for<'a:> fn()) -> bool {
    unsafe { x == y }
    //~^ ERROR pointers cannot
}

fn main() {}

Version information

rustc 1.78.0-nightly (91cae1dcd 2024-02-27)
binary: rustc
commit-hash: 91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb
commit-date: 2024-02-27
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.lO8UkscWMZw4/rustc_testrunner_tmpdir_reporting.FY4MPNZohBHt/mvce.rs:3:2
  |
3 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.lO8UkscWMZw4/rustc_testrunner_tmpdir_reporting.FY4MPNZohBHt/mvce.rs`

warning: unnecessary `unsafe` block
 --> /tmp/icemaker_global_tempdir.lO8UkscWMZw4/rustc_testrunner_tmpdir_reporting.FY4MPNZohBHt/mvce.rs:2:5
  |
2 |     unsafe { x == y }
  |     ^^^^^^ unnecessary `unsafe` block
  |
  = note: `#[warn(unused_unsafe)]` on by default

thread 'rustc' panicked at compiler/rustc_const_eval/src/transform/check_consts/check.rs:584:21:
assertion `left == right` failed
  left: Binder(fn(), [])
 right: Binder(fn(), [Region(BrNamed(DefId(0:4 ~ mvce[1b90]::cmp::'a), 'a))])
stack backtrace:
   0:     0x7f558238ca06 - std::backtrace_rs::backtrace::libunwind::trace::h6356805a047dd0f1
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f558238ca06 - std::backtrace_rs::backtrace::trace_unsynchronized::h57665ae10084ac28
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f558238ca06 - std::sys_common::backtrace::_print_fmt::h4c0b45ee6513471b
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f558238ca06 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::haf16cf243c101ffd
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f55823dd98c - core::fmt::rt::Argument::fmt::h223db55e42187d80
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/core/src/fmt/rt.rs:142:9
   5:     0x7f55823dd98c - core::fmt::write::h28c126feca2924d9
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f55823813cf - std::io::Write::write_fmt::h2ff3e839822231e6
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/io/mod.rs:1846:15
   7:     0x7f558238c7b4 - std::sys_common::backtrace::_print::hce6ed2eb89fc8621
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f558238c7b4 - std::sys_common::backtrace::print::hb8a6c09f8eb6f6ea
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f558238f4fb - std::panicking::default_hook::{{closure}}::h65070d5fef535888
  10:     0x7f558238f249 - std::panicking::default_hook::he2c4aec701a4c47a
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/panicking.rs:292:9
  11:     0x7f558529f37c - std[219737bc433d5307]::panicking::update_hook::<alloc[4f43f5786e9d4163]::boxed::Box<rustc_driver_impl[17f3281e62eb0b55]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f558238fc60 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h29905d5024db7b5d
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/alloc/src/boxed.rs:2030:9
  13:     0x7f558238fc60 - std::panicking::rust_panic_with_hook::hfbdb5f6b6c699264
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/panicking.rs:783:13
  14:     0x7f558238f9a2 - std::panicking::begin_panic_handler::{{closure}}::h7da42a48e307a26a
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/panicking.rs:657:13
  15:     0x7f558238cee6 - std::sys_common::backtrace::__rust_end_short_backtrace::h48881a1fe3ccdc5b
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f558238f6d4 - rust_begin_unwind
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/panicking.rs:645:5
  17:     0x7f55823d9ea5 - core::panicking::panic_fmt::h75a5fa5cfa653b90
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/core/src/panicking.rs:72:14
  18:     0x7f55823da3eb - core::panicking::assert_failed_inner::h6048d140c707e98d
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/core/src/panicking.rs:342:17
  19:     0x7f5585217223 - core[ab6bada39f0d62f7]::panicking::assert_failed::<rustc_middle[e0d127506c37fb38]::ty::Ty, rustc_middle[e0d127506c37fb38]::ty::Ty>
  20:     0x7f5584599319 - <rustc_const_eval[d118eda0568e17d2]::transform::check_consts::check::Checker as rustc_middle[e0d127506c37fb38]::mir::visit::Visitor>::visit_basic_block_data
  21:     0x7f5586a08635 - <rustc_const_eval[d118eda0568e17d2]::transform::check_consts::check::Checker>::check_body
  22:     0x7f5586f3ee7c - rustc_mir_transform[f9758168ffa250ed]::mir_const_qualif
  23:     0x7f5586f3ec9b - rustc_query_impl[fae3b28032436758]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fae3b28032436758]::query_impl::mir_const_qualif::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 4usize]>>
  24:     0x7f5586f3d744 - rustc_query_system[4cecc0fbb9d54d6e]::query::plumbing::try_execute_query::<rustc_query_impl[fae3b28032436758]::DynamicConfig<rustc_query_system[4cecc0fbb9d54d6e]::query::caches::DefIdCache<rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[fae3b28032436758]::plumbing::QueryCtxt, false>
  25:     0x7f5586f3d149 - rustc_query_impl[fae3b28032436758]::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f5586f3c8e3 - rustc_middle[e0d127506c37fb38]::query::plumbing::query_get_at::<rustc_query_system[4cecc0fbb9d54d6e]::query::caches::DefIdCache<rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 4usize]>>>
  27:     0x7f558478cd16 - rustc_mir_transform[f9758168ffa250ed]::mir_promoted
  28:     0x7f5586b60492 - rustc_query_impl[fae3b28032436758]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fae3b28032436758]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 16usize]>>
  29:     0x7f5586b60750 - rustc_query_system[4cecc0fbb9d54d6e]::query::plumbing::try_execute_query::<rustc_query_impl[fae3b28032436758]::DynamicConfig<rustc_query_system[4cecc0fbb9d54d6e]::query::caches::VecCache<rustc_span[f729f3d7b7758c04]::def_id::LocalDefId, rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[fae3b28032436758]::plumbing::QueryCtxt, false>
  30:     0x7f558740530f - rustc_query_impl[fae3b28032436758]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7f558740540c - rustc_borrowck[d04c300f4bae4997]::mir_borrowck
  32:     0x7f5587405357 - rustc_query_impl[fae3b28032436758]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fae3b28032436758]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 8usize]>>
  33:     0x7f55867701b0 - rustc_query_system[4cecc0fbb9d54d6e]::query::plumbing::try_execute_query::<rustc_query_impl[fae3b28032436758]::DynamicConfig<rustc_query_system[4cecc0fbb9d54d6e]::query::caches::VecCache<rustc_span[f729f3d7b7758c04]::def_id::LocalDefId, rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[fae3b28032436758]::plumbing::QueryCtxt, false>
  34:     0x7f558676fd8c - rustc_query_impl[fae3b28032436758]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f55871c590c - rustc_interface[db8a4e7a90e6d56e]::passes::analysis
  36:     0x7f55871c5419 - rustc_query_impl[fae3b28032436758]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fae3b28032436758]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7f55873345e5 - rustc_query_system[4cecc0fbb9d54d6e]::query::plumbing::try_execute_query::<rustc_query_impl[fae3b28032436758]::DynamicConfig<rustc_query_system[4cecc0fbb9d54d6e]::query::caches::SingleCache<rustc_middle[e0d127506c37fb38]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[fae3b28032436758]::plumbing::QueryCtxt, false>
  38:     0x7f5587334349 - rustc_query_impl[fae3b28032436758]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f558733bed6 - rustc_interface[db8a4e7a90e6d56e]::interface::run_compiler::<core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>, rustc_driver_impl[17f3281e62eb0b55]::run_compiler::{closure#0}>::{closure#0}
  40:     0x7f55875e0a85 - std[219737bc433d5307]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[db8a4e7a90e6d56e]::util::run_in_thread_with_globals<rustc_interface[db8a4e7a90e6d56e]::util::run_in_thread_pool_with_globals<rustc_interface[db8a4e7a90e6d56e]::interface::run_compiler<core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>, rustc_driver_impl[17f3281e62eb0b55]::run_compiler::{closure#0}>::{closure#0}, core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>>::{closure#0}, core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>>
  41:     0x7f55875e08b2 - <<std[219737bc433d5307]::thread::Builder>::spawn_unchecked_<rustc_interface[db8a4e7a90e6d56e]::util::run_in_thread_with_globals<rustc_interface[db8a4e7a90e6d56e]::util::run_in_thread_pool_with_globals<rustc_interface[db8a4e7a90e6d56e]::interface::run_compiler<core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>, rustc_driver_impl[17f3281e62eb0b55]::run_compiler::{closure#0}>::{closure#0}, core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>>::{closure#0}, core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ab6bada39f0d62f7]::result::Result<(), rustc_span[f729f3d7b7758c04]::ErrorGuaranteed>>::{closure#1} as core[ab6bada39f0d62f7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f5582399635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5d5208573d833f07
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/alloc/src/boxed.rs:2016:9
  43:     0x7f5582399635 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc13d38a59b83ddfd
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/alloc/src/boxed.rs:2016:9
  44:     0x7f5582399635 - std::sys::pal::unix::thread::Thread::new::thread_start::he9a07be3a69d4045
                               at /rustc/91cae1dcdcf1a31bd8a92e4a63793d65cfe289bb/library/std/src/sys/pal/unix/thread.rs:108:17
  45:     0x7f558218155a - <unknown>
  46:     0x7f55821fea3c - <unknown>
  47:                0x0 - <unknown>

error: 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.78.0-nightly (91cae1dcd 2024-02-27) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_const_qualif] const checking `cmp`
#1 [mir_promoted] promoting constants in MIR for `cmp`
#2 [mir_borrowck] borrow-checking `cmp`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Feb 27, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 27, 2024
  3. matthiaskrgr commented on Feb 27, 2024

    @matthiaskrgr
    MemberAuthor

    Regression in #118937 cc @lcnr

  4. lcnr commented on Feb 27, 2024

    @lcnr
    Contributor

    that seems off 😅 this PR should not result in behavior differences

  5. matthiaskrgr commented on Feb 27, 2024

    @matthiaskrgr
    MemberAuthor

    ah yes my bad :D
    I left in -Znext-solver=coherenceby accident from a previous bisection and that was the pr that added the flag 😆

  6. lcnr commented on Feb 27, 2024

    @lcnr
    Contributor

    } else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() {
    assert_eq!(lhs_ty, rhs_ty);
    assert!(matches!(
    op,
    BinOp::Eq
    | BinOp::Ne
    | BinOp::Le
    | BinOp::Lt
    | BinOp::Ge
    | BinOp::Gt
    | BinOp::Offset
    ));
    self.check_op(ops::RawPtrComparison);
    } else if lhs_ty.is_floating_point() || rhs_ty.is_floating_point() {

    should exist since pretty much forever 😁 1.48

  7. matthiaskrgr commented on Feb 27, 2024

    @matthiaskrgr
    MemberAuthor

    Regression in nightly-2023-04-20

    fetching (via remote github) commits from max(c609da5, 2023-04-17) to 39c6804
    ending github query because we found starting sha: c609da5
    get_commits_between returning commits, len: 10
    commit[0] 2023-04-18: Auto merge of #109772 - petrochenkov:slimchild, r=cjgillot
    commit[1] 2023-04-18: Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillot
    commit[2] 2023-04-19: Auto merge of #110229 - jyn514:download-rustc-tests, r=albertlarsan68
    commit[3] 2023-04-19: Auto merge of #110477 - miguelraz:canoodling2-electric-boogaloo, r=compiler-errors
    commit[4] 2023-04-19: Auto merge of #110522 - matthiaskrgr:rollup-9m7rw3u, r=matthiaskrgr
    commit[5] 2023-04-19: Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco
    commit[6] 2023-04-19: Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk
    commit[7] 2023-04-19: Auto merge of #110496 - WaffleLapkin:🏳️‍⚧️sound, r=compiler-errors
    commit[8] 2023-04-19: Auto merge of #110546 - matthiaskrgr:rollup-346kik6, r=matthiaskrgr
    commit[9] 2023-04-19: Auto merge of #106704 - ecnelises:big_archive, r=bjorn3

  8. added
    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 27, 2024
  9. matthiaskrgr commented on Feb 28, 2024

    @matthiaskrgr
    MemberAuthor

    This might be related to #110393 cc @fee1-dead

    one nightly before this errors with

    error[E0277]: can't compare `fn()` with `_` in const contexts
     --> a.rs:2:16
      |
    2 |     unsafe { x == y }
      |                ^^ no implementation for `fn() == _`
      |
      = help: the trait `~const PartialEq<_>` is not implemented for `fn()`
    note: the trait `PartialEq<_>` is implemented for `fn()`, but that implementation is not `const`
     --> a.rs:2:16
      |
    2 |     unsafe { x == y }
      |                ^^
    

    so maybe const-related

  10. lcnr commented on Feb 29, 2024

    @lcnr
    Contributor

    the cause is that the assert mentioned in #121688 (comment) is wrong. COmparing pointers with different bound vars is ok. This should either use actual semantic equality or just yeet the assert

  11. added a commit that references this issue on Mar 8, 2024
    3d71bad
  12. added a commit that references this issue on Mar 8, 2024
    079e6df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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