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 with generics. #94680

Closed
10maurycy10 opened this issue Mar 6, 2022 · 3 comments · Fixed by #96806
Closed

ICE with generics. #94680

10maurycy10 opened this issue Mar 6, 2022 · 3 comments · Fixed by #96806
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@10maurycy10
Copy link

10maurycy10 commented Mar 6, 2022

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=3f6d8b903da8b01348137330371e7ff5

fn main() {
   println!("{:?}", {
   type T = ();

     pub fn cloneit (it: &'_ mut T) -> (&'_ mut T, &'_ mut T)
where
    for<'any> &'any mut T : Clone, {
        (it.clone(), it)
    }
}); }

Meta

rustc --version --verbose:

1.61.0-nightly (2022-03-05 c274e4969f058b1c6442)

Error output

Compiling playground v0.0.1 (/playground)
warning: type alias is never used: `T`
 [--> src/main.rs:3:4
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=4c9140e1c57f836e8185361ea26f0541#)  |
3 |    type T = ();
  |    ^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: function is never used: `clone`
 [--> src/main.rs:5:13
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=4c9140e1c57f836e8185361ea26f0541#)  |
5 |      pub fn clone (it: &'_ mut T) -> (&'_ mut T, &'_ mut T)
  |             ^^^^^

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<&mut () as std::clone::Clone>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:69:32

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1266:13
stack backtrace:
   0:     0x7fce63604d2c - std::backtrace_rs::backtrace::libunwind::trace::hd9d6c66ed2138bb0
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fce63604d2c - std::backtrace_rs::backtrace::trace_unsynchronized::ha4edb04af5a111d2
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fce63604d2c - std::sys_common::backtrace::_print_fmt::h34bfe6ef54352a7f
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fce63604d2c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h91638cd7890644b7
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fce6365ebec - core::fmt::write::h407f77bceaf22b75
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/core/src/fmt/mod.rs:1190:17
   5:     0x7fce635f5801 - std::io::Write::write_fmt::h85de75cd3cb86034
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/io/mod.rs:1655:15
   6:     0x7fce63607c65 - std::sys_common::backtrace::_print::h9303e0f315439c4b
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fce63607c65 - std::sys_common::backtrace::print::h278cbd6c00b20bf7
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fce63607c65 - std::panicking::default_hook::{{closure}}::h66dc8e0c0481f9ac
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/panicking.rs:295:22
   9:     0x7fce63607908 - std::panicking::default_hook::h3732f22170eb6fcb
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/panicking.rs:314:9
  10:     0x7fce63d9d4a1 - rustc_driver[a243c3d9738e9cda]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fce63608501 - std::panicking::rust_panic_with_hook::hfa6a9afb1a6b2eff
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/panicking.rs:702:17
  12:     0x7fce64e2dfb1 - std[54a224735ab911a]::panicking::begin_panic::<rustc_errors[e9d593471e7e5a86]::ExplicitBug>::{closure#0}
  13:     0x7fce64e2dea6 - std[54a224735ab911a]::sys_common::backtrace::__rust_end_short_backtrace::<std[54a224735ab911a]::panicking::begin_panic<rustc_errors[e9d593471e7e5a86]::ExplicitBug>::{closure#0}, !>
  14:     0x7fce64e348ef - std[54a224735ab911a]::panicking::begin_panic::<rustc_errors[e9d593471e7e5a86]::ExplicitBug>
  15:     0x7fce64e41756 - std[54a224735ab911a]::panic::panic_any::<rustc_errors[e9d593471e7e5a86]::ExplicitBug>
  16:     0x7fce664bd16e - <rustc_errors[e9d593471e7e5a86]::HandlerInner as core[f66f8263def5172a]::ops::drop::Drop>::drop
  17:     0x7fce65bfb338 - core[f66f8263def5172a]::ptr::drop_in_place::<rustc_session[7e14f15cd8696afc]::parse::ParseSess>
  18:     0x7fce65bfde8a - <alloc[16beeacba2f7b906]::rc::Rc<rustc_session[7e14f15cd8696afc]::session::Session> as core[f66f8263def5172a]::ops::drop::Drop>::drop
  19:     0x7fce65be652d - core[f66f8263def5172a]::ptr::drop_in_place::<rustc_interface[ee304f5e577cf6b9]::interface::Compiler>
  20:     0x7fce65be6033 - rustc_span[1b916fa4cb305af0]::with_source_map::<core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>, rustc_interface[ee304f5e577cf6b9]::interface::create_compiler_and_run<core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>, rustc_driver[a243c3d9738e9cda]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7fce65bd3f24 - rustc_interface[ee304f5e577cf6b9]::interface::create_compiler_and_run::<core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>, rustc_driver[a243c3d9738e9cda]::run_compiler::{closure#1}>
  22:     0x7fce65bd1f42 - <scoped_tls[a76d38c46f15ed9e]::ScopedKey<rustc_span[1b916fa4cb305af0]::SessionGlobals>>::set::<rustc_interface[ee304f5e577cf6b9]::interface::run_compiler<core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>, rustc_driver[a243c3d9738e9cda]::run_compiler::{closure#1}>::{closure#0}, core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>>
  23:     0x7fce65bd021f - std[54a224735ab911a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee304f5e577cf6b9]::util::run_in_thread_pool_with_globals<rustc_interface[ee304f5e577cf6b9]::interface::run_compiler<core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>, rustc_driver[a243c3d9738e9cda]::run_compiler::{closure#1}>::{closure#0}, core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>>::{closure#0}, core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>>
  24:     0x7fce65bd0509 - <<std[54a224735ab911a]::thread::Builder>::spawn_unchecked_<rustc_interface[ee304f5e577cf6b9]::util::run_in_thread_pool_with_globals<rustc_interface[ee304f5e577cf6b9]::interface::run_compiler<core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>, rustc_driver[a243c3d9738e9cda]::run_compiler::{closure#1}>::{closure#0}, core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>>::{closure#0}, core[f66f8263def5172a]::result::Result<(), rustc_errors[e9d593471e7e5a86]::ErrorGuaranteed>>::{closure#1} as core[f66f8263def5172a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7fce636128c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb7ce1f9a74daab59
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/alloc/src/boxed.rs:1854:9
  26:     0x7fce636128c3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc28d1f774d95b80d
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/alloc/src/boxed.rs:1854:9
  27:     0x7fce636128c3 - std::sys::unix::thread::Thread::new::thread_start::h7c8916b17d3c6d45
                               at /rustc/c274e4969f058b1c644243181ece9f829efa7594/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7fce63542609 - start_thread
  29:     0x7fce6345b163 - clone
  30:                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.61.0-nightly (c274e4969 2022-03-05) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
warning: `playground` (bin "playground") generated 2 warnings
error: could not compile `playground`; 2 warnings emitted
@10maurycy10 10maurycy10 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 6, 2022
@10maurycy10 10maurycy10 changed the title ICE with generics.i ICE with generics. Mar 6, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Mar 6, 2022

This is due to an (almost) trivially unsatisfiable bound. Minimized:

pub fn clone(it: &mut ()) -> &mut ()
where
    for<'any> &'any mut (): Clone,
{
    it.clone()
}

@eignnx
Copy link

eignnx commented Mar 9, 2022

Played around a little and found that:

  1. The same ICE is generated on version 1.59.0 stable.

  2. If a 'static lifetime is used, no ICE is generated:
    https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eba7813b633302c60221d58389a58468
    Instead you get this error (which seems to be correct):

Compiling playground v0.0.1 (/playground)
error[[E0277]](https://doc.rust-lang.org/stable/error-index.html#E0277): the trait bound `&'static mut (): Clone` is not satisfied
 [--> src/lib.rs:3:5
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eba7813b633302c60221d58389a58468#)  |
3 |     &'static mut (): Clone,
  |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&'static mut ()`
  |
  = help: see issue #48214

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

@compiler-errors
Copy link
Member

Gonna claim this because I've been thinking about it recently: #93008, https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/What.20to.20do.20with.20trivially-false.20trivial_bounds

@rustbot claim

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 11, 2022
@bors bors closed this as completed in cb9cb4d May 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 18, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 22, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 22, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
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. glacier ICE tracked in rust-lang/glacier. 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
4 participants