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

Type checker panics on a buggy trait implementation #107545

Closed
magniff opened this issue Feb 1, 2023 · 6 comments
Closed

Type checker panics on a buggy trait implementation #107545

magniff opened this issue Feb 1, 2023 · 6 comments
Labels
A-incr-comp Area: Incremental compilation 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

@magniff
Copy link

magniff commented Feb 1, 2023

Summary

I've been experimenting with the type level Peano arithmetic, and in the process I made a stupid mistake - I incorrectly implemented one of the traits. This in turn led to a panic in the compiler process and seems to be a compiler bug. I will try to come up with a minimal case that reproduces the problem, but so far so.

Version: rustc 1.66.0 (69f9c33d7 2022-12-12) running on x86_64-unknown-linux-gnu

Code

use std::marker::PhantomData;

trait IsNormalForm {}

trait Term {
    type NormalForm: IsNormalForm;
}

struct Zero;
struct Suc<T> {
    _of_what: PhantomData<T>,
}

trait ProvablySame<T> {}

trait DefinitelySame<T> {}

struct Reflection<A, B>
where
    A: ProvablySame<B>,
{
    _a: PhantomData<A>,
    _b: PhantomData<B>,
}

impl<L, R> ProvablySame<L> for R
where
    L: Term,
    R: Term,
    <L as Term>::NormalForm: DefinitelySame<<R as Term>::NormalForm>,
{
}

impl DefinitelySame<Zero> for Zero {}
impl<A, B> DefinitelySame<Suc<A>> for Suc<B>
where
    A: Term,
    B: Term,
    A: DefinitelySame<B>,
{
}

impl IsNormalForm for Zero {}
impl Term for Zero {
    type NormalForm = Zero;
}

impl<T> IsNormalForm for Suc<T> where T: IsNormalForm {}

impl<T> Term for Suc<T>
where
    T: Term,
{
    type NormalForm = Suc<<T as Term>::NormalForm>;
}

struct Add<Left, Right> {
    _left: PhantomData<Left>,
    _right: PhantomData<Right>,
}

struct Mul<Left, Right> {
    _left: PhantomData<Left>,
    _right: PhantomData<Right>,
}

impl<Right> Term for Add<Zero, Right>
where
    Right: Term,
{
    type NormalForm = Right::NormalForm;
}

impl<Left, Right> Term for Add<Suc<Left>, Right>
where
    Left: Term,
    Right: Term,
    Add<Left, Right>: Term,
{
    type NormalForm = Suc<<Add<Left, Right> as Term>::NormalForm>;
}

impl<Right> Term for Mul<Zero, Right>
where
    Right: Term,
{
    type NormalForm = Zero;
}

// This impl block is buggy (inf recursion in trait resolution, see the correct implementation in the next block) and leads to the compiler crash
impl<Left, Right> Term for Mul<Suc<Left>, Right>
where
    Left: Term,
    Right: Term,
{
    type NormalForm =
               // V Here's the bug, should be written as Mul<Left, Right>  instead
        <Add<<Mul<Suc<Left>, Right> as Term>::NormalForm, Right::NormalForm> as Term>::NormalForm;
}

// This impl block is fine
// impl<Left, Right> Term for Mul<Suc<Left>, Right>
// where
//     Left: Term,
//     Right: Term,
//     Mul<Left, Right>: Term,
//     Add<<Mul<Left, Right> as Term>::NormalForm, <Right as Term>::NormalForm>: Term,
// {
//     type NormalForm =
//         <Add<<Mul<Left, Right> as Term>::NormalForm, Right::NormalForm> as Term>::NormalForm;
// }

type One = Suc<Zero>;
type Two = Suc<One>;
type Three = Suc<Two>;
type Four = Suc<Three>;
type Five = Suc<Four>;
type Six = Suc<Five>;

fn main() {
    let _: Reflection<Add<Three, Two>, Five>;
    let _: Reflection<Mul<Two, Two>, Four>;
    let _: Reflection<Mul<Two, Three>, Six>;
    let _: Reflection<Mul<Three, Three>, Add<Six, Three>>;
}

Error message

$ cargo c                                                    
    Checking play-tokio v0.1.0 (/home/magniff/workspace/play-tokio)
thread '<unnamed>' panicked at 'type variables should not be hashed: _#2t', /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/compiler/rustc_type_ir/src/lib.rs:679:17
stack backtrace:
   0:     0x7f7a294e59a0 - std::backtrace_rs::backtrace::libunwind::trace::he615646ea344481f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7a294e59a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h6ea8eaac68705b9c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7a294e59a0 - std::sys_common::backtrace::_print_fmt::h7ac486a935ce0bf7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7a294e59a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b5a095d3db2e28f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7a2954198e - core::fmt::write::h445545b92224a1cd
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f7a294d5b15 - std::io::Write::write_fmt::h55a43474c6520b00
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
   6:     0x7f7a294e5765 - std::sys_common::backtrace::_print::h65d20526fdb736b0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7a294e5765 - std::sys_common::backtrace::print::h6555fbe12a1cc41b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7a294e856f - std::panicking::default_hook::{{closure}}::hbdf58083140e7ac6
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
   9:     0x7f7a294e82aa - std::panicking::default_hook::haef8271c56b74d85
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
  10:     0x7f7a294e8d78 - std::panicking::rust_panic_with_hook::hfd45b6b6c12d9fa5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:688:13
  11:     0x7f7a294e8b17 - std::panicking::begin_panic_handler::{{closure}}::hf591e8609a75bd4b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:579:13
  12:     0x7f7a294e5e4c - std::sys_common::backtrace::__rust_end_short_backtrace::h81899558795e4ff7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f7a294e8832 - rust_begin_unwind
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
  14:     0x7f7a2953e373 - core::panicking::panic_fmt::h4235fa9b4675b332
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
  15:     0x7f7a2cb239e7 - <rustc_type_ir[1fd57c2de0aaa4ec]::InferTy as rustc_data_structures[e8a5264856147ea5]::stable_hasher::HashStable<rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext>>::hash_stable
  16:     0x7f7a2a90b8b3 - <rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext as rustc_data_structures[e8a5264856147ea5]::intern::InternedHashingContext>::with_def_path_and_no_spans::<<rustc_data_structures[e8a5264856147ea5]::intern::WithStableHash<rustc_middle[1bbcd7fc39987e50]::ty::TyS> as rustc_data_structures[e8a5264856147ea5]::stable_hasher::HashStable<rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext>>::hash_stable::{closure#0}>
  17:     0x7f7a2aed8c59 - <&rustc_middle[1bbcd7fc39987e50]::ty::list::List<rustc_middle[1bbcd7fc39987e50]::ty::subst::GenericArg> as rustc_data_structures[e8a5264856147ea5]::stable_hasher::HashStable<rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext>>::hash_stable
  18:     0x7f7a2a90b43e - <rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext as rustc_data_structures[e8a5264856147ea5]::intern::InternedHashingContext>::with_def_path_and_no_spans::<<rustc_data_structures[e8a5264856147ea5]::intern::WithStableHash<rustc_middle[1bbcd7fc39987e50]::ty::TyS> as rustc_data_structures[e8a5264856147ea5]::stable_hasher::HashStable<rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext>>::hash_stable::{closure#0}>
  19:     0x7f7a2b1d45d8 - <rustc_middle[1bbcd7fc39987e50]::ty::Predicate as rustc_data_structures[e8a5264856147ea5]::stable_hasher::HashStable<rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext>>::hash_stable
  20:     0x7f7a2cf8d047 - <(rustc_middle[1bbcd7fc39987e50]::ty::Predicate, rustc_middle[1bbcd7fc39987e50]::traits::WellFormedLoc) as rustc_data_structures[e8a5264856147ea5]::stable_hasher::HashStable<rustc_query_system[330b635d327008f7]::ich::hcx::StableHashingContext>>::hash_stable
  21:     0x7f7a2cece814 - <rustc_query_system[330b635d327008f7]::dep_graph::dep_node::DepNode<rustc_middle[1bbcd7fc39987e50]::dep_graph::dep_node::DepKind>>::construct::<rustc_middle[1bbcd7fc39987e50]::ty::context::TyCtxt, (rustc_middle[1bbcd7fc39987e50]::ty::Predicate, rustc_middle[1bbcd7fc39987e50]::traits::WellFormedLoc)>
  22:     0x7f7a2cdd8cb5 - rustc_query_system[330b635d327008f7]::query::plumbing::try_execute_query::<rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt, rustc_query_system[330b635d327008f7]::query::caches::ArenaCache<(rustc_middle[1bbcd7fc39987e50]::ty::Predicate, rustc_middle[1bbcd7fc39987e50]::traits::WellFormedLoc), core[b97a30f8df81432d]::option::Option<rustc_middle[1bbcd7fc39987e50]::traits::ObligationCause>>>
  23:     0x7f7a2ce118ab - rustc_query_system[330b635d327008f7]::query::plumbing::get_query::<rustc_query_impl[969f89a88b0ee9ca]::queries::diagnostic_hir_wf_check, rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt>
  24:     0x7f7a2ce749fb - <rustc_query_impl[969f89a88b0ee9ca]::Queries as rustc_middle[1bbcd7fc39987e50]::ty::query::QueryEngine>::diagnostic_hir_wf_check
  25:     0x7f7a2d20582a - <rustc_infer[f68b41b576257fe5]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5aec47e3fc81d5cc]::traits::error_reporting::TypeErrCtxtExt>::report_selection_error
  26:     0x7f7a2d20febc - <rustc_infer[f68b41b576257fe5]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5aec47e3fc81d5cc]::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  27:     0x7f7a2d20414d - <rustc_infer[f68b41b576257fe5]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[5aec47e3fc81d5cc]::traits::error_reporting::TypeErrCtxtExt>::report_fulfillment_errors
  28:     0x7f7a2b393d5c - rustc_hir_analysis[ad9e1d48ad6d8787]::check::wfcheck::check_associated_item
  29:     0x7f7a2b389511 - rustc_hir_analysis[ad9e1d48ad6d8787]::check::wfcheck::check_well_formed
  30:     0x7f7a2a86d0c3 - <rustc_query_system[330b635d327008f7]::dep_graph::graph::DepGraph<rustc_middle[1bbcd7fc39987e50]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1bbcd7fc39987e50]::ty::context::TyCtxt, rustc_hir[991b9fb16137de4a]::hir_id::OwnerId, ()>
  31:     0x7f7a2bea1a17 - rustc_query_system[330b635d327008f7]::query::plumbing::try_execute_query::<rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt, rustc_query_system[330b635d327008f7]::query::caches::DefaultCache<rustc_hir[991b9fb16137de4a]::hir_id::OwnerId, ()>>
  32:     0x7f7a2bea1112 - rustc_query_system[330b635d327008f7]::query::plumbing::force_query::<rustc_query_impl[969f89a88b0ee9ca]::queries::check_well_formed, rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt>
  33:     0x7f7a2bea0f80 - rustc_query_impl[969f89a88b0ee9ca]::plumbing::force_from_dep_node::<rustc_query_impl[969f89a88b0ee9ca]::queries::check_well_formed>
  34:     0x7f7a2a835e10 - <rustc_query_system[330b635d327008f7]::dep_graph::graph::DepGraph<rustc_middle[1bbcd7fc39987e50]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt>
  35:     0x7f7a2a86c872 - rustc_query_system[330b635d327008f7]::query::plumbing::ensure_must_run::<rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt, rustc_hir[991b9fb16137de4a]::hir_id::OwnerId, ()>
  36:     0x7f7a2bb21cf5 - rustc_query_system[330b635d327008f7]::query::plumbing::get_query::<rustc_query_impl[969f89a88b0ee9ca]::queries::check_mod_type_wf, rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt>
  37:     0x7f7a2aa85858 - rustc_data_structures[e8a5264856147ea5]::sync::par_for_each_in::<&[rustc_hir[991b9fb16137de4a]::hir_id::OwnerId], <rustc_middle[1bbcd7fc39987e50]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[ad9e1d48ad6d8787]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  38:     0x7f7a2aa85673 - <rustc_session[87e5e219eb43521c]::session::Session>::track_errors::<rustc_hir_analysis[ad9e1d48ad6d8787]::check_crate::{closure#5}, ()>
  39:     0x7f7a2aa84da1 - rustc_hir_analysis[ad9e1d48ad6d8787]::check_crate
  40:     0x7f7a2aa84a4b - rustc_interface[ee1a3f92e887e004]::passes::analysis
  41:     0x7f7a2bec29ce - <rustc_query_system[330b635d327008f7]::dep_graph::graph::DepGraph<rustc_middle[1bbcd7fc39987e50]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[1bbcd7fc39987e50]::ty::context::TyCtxt, (), core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  42:     0x7f7a2bec1d44 - rustc_query_system[330b635d327008f7]::query::plumbing::try_execute_query::<rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt, rustc_query_system[330b635d327008f7]::query::caches::DefaultCache<(), core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>>
  43:     0x7f7a2bec17c7 - rustc_query_system[330b635d327008f7]::query::plumbing::get_query::<rustc_query_impl[969f89a88b0ee9ca]::queries::analysis, rustc_query_impl[969f89a88b0ee9ca]::plumbing::QueryCtxt>
  44:     0x7f7a2ba03acd - <rustc_interface[ee1a3f92e887e004]::passes::QueryContext>::enter::<rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  45:     0x7f7a2b9fff7f - <rustc_interface[ee1a3f92e887e004]::interface::Compiler>::enter::<rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}::{closure#2}, core[b97a30f8df81432d]::result::Result<core[b97a30f8df81432d]::option::Option<rustc_interface[ee1a3f92e887e004]::queries::Linker>, rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  46:     0x7f7a2b9f7ac2 - rustc_span[14998722174c1bca]::with_source_map::<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  47:     0x7f7a2b9f75b9 - <scoped_tls[23afcff80b89ba49]::ScopedKey<rustc_span[14998722174c1bca]::SessionGlobals>>::set::<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  48:     0x7f7a2b9f6bc8 - std[bbad73ae434e23e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  49:     0x7f7a2b9f68ec - <<std[bbad73ae434e23e5]::thread::Builder>::spawn_unchecked_<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#1} as core[b97a30f8df81432d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x7f7a2d3a06a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4273f95ec44459b3
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  51:     0x7f7a2d3a06a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70f28fa4ddc269e5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  52:     0x7f7a2d3a06a3 - std::sys::unix::thread::Thread::new::thread_start::h85a9c16b988e2bd0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys/unix/thread.rs:108:17
  53:     0x7f7a2939b609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  54:     0x7f7a292be133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  55:                0x0 - <unknown>
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: `InferCtxt` incorrectly tainted by errors
  |
  = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1256:27

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1553:13
stack backtrace:
   0:     0x7f7a2d396e20 - std::backtrace_rs::backtrace::libunwind::trace::he615646ea344481f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7a2d396e20 - std::backtrace_rs::backtrace::trace_unsynchronized::h6ea8eaac68705b9c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7a2d396e20 - std::sys_common::backtrace::_print_fmt::h7ac486a935ce0bf7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7a2d396e20 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b5a095d3db2e28f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7a2954198e - core::fmt::write::h445545b92224a1cd
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f7a2d38aad5 - std::io::Write::write_fmt::h55a43474c6520b00
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
   6:     0x7f7a2d396be5 - std::sys_common::backtrace::_print::h65d20526fdb736b0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7a2d396be5 - std::sys_common::backtrace::print::h6555fbe12a1cc41b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7a2d398f3f - std::panicking::default_hook::{{closure}}::hbdf58083140e7ac6
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
   9:     0x7f7a2d398c7a - std::panicking::default_hook::haef8271c56b74d85
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
  10:     0x7f7a2c65ccd4 - <rustc_driver[9c4183344b2d0066]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[b97a30f8df81432d]::ops::function::FnOnce<(&core[b97a30f8df81432d]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f7a2d399729 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h44df53ea2a13204b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:2001:9
  12:     0x7f7a2d399729 - std::panicking::rust_panic_with_hook::hfd45b6b6c12d9fa5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:692:13
  13:     0x7f7a2c68b0b1 - std[bbad73ae434e23e5]::panicking::begin_panic::<rustc_errors[21897ed46328f955]::ExplicitBug>::{closure#0}
  14:     0x7f7a2c689846 - std[bbad73ae434e23e5]::sys_common::backtrace::__rust_end_short_backtrace::<std[bbad73ae434e23e5]::panicking::begin_panic<rustc_errors[21897ed46328f955]::ExplicitBug>::{closure#0}, !>
  15:     0x7f7a2c683636 - std[bbad73ae434e23e5]::panicking::begin_panic::<rustc_errors[21897ed46328f955]::ExplicitBug>
  16:     0x7f7a2c685cc6 - std[bbad73ae434e23e5]::panic::panic_any::<rustc_errors[21897ed46328f955]::ExplicitBug>
  17:     0x7f7a2bbfeb71 - <rustc_errors[21897ed46328f955]::HandlerInner>::flush_delayed::<alloc[d987cf4402e5b40a]::vec::Vec<rustc_errors[21897ed46328f955]::diagnostic::Diagnostic>, &str>
  18:     0x7f7a2bbfdbb2 - <rustc_errors[21897ed46328f955]::HandlerInner as core[b97a30f8df81432d]::ops::drop::Drop>::drop
  19:     0x7f7a2ba46d58 - core[b97a30f8df81432d]::ptr::drop_in_place::<rustc_session[87e5e219eb43521c]::parse::ParseSess>
  20:     0x7f7a2b9f8df8 - core[b97a30f8df81432d]::ptr::drop_in_place::<rustc_session[87e5e219eb43521c]::session::Session>
  21:     0x7f7a2b9f8b19 - core[b97a30f8df81432d]::ptr::drop_in_place::<rustc_interface[ee1a3f92e887e004]::interface::Compiler>
  22:     0x7f7a2b9f7f2e - rustc_span[14998722174c1bca]::with_source_map::<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  23:     0x7f7a2b9f75b9 - <scoped_tls[23afcff80b89ba49]::ScopedKey<rustc_span[14998722174c1bca]::SessionGlobals>>::set::<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  24:     0x7f7a2b9f6bc8 - std[bbad73ae434e23e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  25:     0x7f7a2b9f68ec - <<std[bbad73ae434e23e5]::thread::Builder>::spawn_unchecked_<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#1} as core[b97a30f8df81432d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f7a2d3a06a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4273f95ec44459b3
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  27:     0x7f7a2d3a06a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70f28fa4ddc269e5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  28:     0x7f7a2d3a06a3 - std::sys::unix::thread::Thread::new::thread_start::h85a9c16b988e2bd0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys/unix/thread.rs:108:17
  29:     0x7f7a2939b609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  30:     0x7f7a292be133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  31:                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.66.0 (69f9c33d7 2022-12-12) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
end of query stack
thread '<unnamed>' panicked at 'panic in a function that cannot unwind', library/core/src/panicking.rs:90:58
stack backtrace:
   0:     0x7f7a294e59a0 - std::backtrace_rs::backtrace::libunwind::trace::he615646ea344481f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7a294e59a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h6ea8eaac68705b9c
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7a294e59a0 - std::sys_common::backtrace::_print_fmt::h7ac486a935ce0bf7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7a294e59a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1b5a095d3db2e28f
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7a2954198e - core::fmt::write::h445545b92224a1cd
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f7a294d5b15 - std::io::Write::write_fmt::h55a43474c6520b00
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/io/mod.rs:1682:15
   6:     0x7f7a294e5765 - std::sys_common::backtrace::_print::h65d20526fdb736b0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7a294e5765 - std::sys_common::backtrace::print::h6555fbe12a1cc41b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7a294e856f - std::panicking::default_hook::{{closure}}::hbdf58083140e7ac6
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:267:22
   9:     0x7f7a294e82aa - std::panicking::default_hook::haef8271c56b74d85
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:286:9
  10:     0x7f7a294e8d78 - std::panicking::rust_panic_with_hook::hfd45b6b6c12d9fa5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:688:13
  11:     0x7f7a294e8ad1 - std::panicking::begin_panic_handler::{{closure}}::hf591e8609a75bd4b
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:577:13
  12:     0x7f7a294e5e4c - std::sys_common::backtrace::__rust_end_short_backtrace::h81899558795e4ff7
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f7a294e8832 - rust_begin_unwind
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
  14:     0x7f7a2953e3f3 - core::panicking::panic_str_nounwind::h2959ea310e934ac1
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:93:14
  15:     0x7f7a2953e563 - core::panicking::panic_no_unwind::h31a06247391473ac
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:164:5
  16:     0x7f7a2b9f7f45 - rustc_span[14998722174c1bca]::with_source_map::<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  17:     0x7f7a2b9f75b9 - <scoped_tls[23afcff80b89ba49]::ScopedKey<rustc_span[14998722174c1bca]::SessionGlobals>>::set::<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  18:     0x7f7a2b9f6bc8 - std[bbad73ae434e23e5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>
  19:     0x7f7a2b9f68ec - <<std[bbad73ae434e23e5]::thread::Builder>::spawn_unchecked_<rustc_interface[ee1a3f92e887e004]::util::run_in_thread_pool_with_globals<rustc_interface[ee1a3f92e887e004]::interface::run_compiler<core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>, rustc_driver[9c4183344b2d0066]::run_compiler::{closure#1}>::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b97a30f8df81432d]::result::Result<(), rustc_errors[21897ed46328f955]::ErrorGuaranteed>>::{closure#1} as core[b97a30f8df81432d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:     0x7f7a2d3a06a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4273f95ec44459b3
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  21:     0x7f7a2d3a06a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70f28fa4ddc269e5
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/alloc/src/boxed.rs:1987:9
  22:     0x7f7a2d3a06a3 - std::sys::unix::thread::Thread::new::thread_start::h85a9c16b988e2bd0
                               at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/sys/unix/thread.rs:108:17
  23:     0x7f7a2939b609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  24:     0x7f7a292be133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  25:                0x0 - <unknown>
thread panicked while panicking. aborting.
error: could not compile `play-tokio`

Caused by:
  process didn't exit successfully: `rustc --crate-name play_tokio --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=0d23bc0bab505aee -C extra-filename=-0d23bc0bab505aee --out-dir /home/magniff/workspace/play-tokio/target/debug/deps -C incremental=/home/magniff/workspace/play-tokio/target/debug/incremental -L dependency=/home/magniff/workspace/play-tokio/target/debug/deps --extern play_tokio=/home/magniff/workspace/play-tokio/target/debug/deps/libplay_tokio-337069c26f062a8a.rmeta --extern tracing_attributes=/home/magniff/workspace/play-tokio/target/debug/deps/libtracing_attributes-2c2be4690eec8b6f.so` (signal: 6, SIGABRT: process abort signal)
@magniff magniff added the C-bug Category: This is a bug. label Feb 1, 2023
@chenyukang
Copy link
Member

Please update rustc, this issue can not reproduce in stable.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=98831249aa770a56764af440c3761e94

@magniff
Copy link
Author

magniff commented Feb 1, 2023

Yep, looks like in 1.67^ it's been fixed
Hmm, wait, it seems to be reproducible by invoking the type checker via the cargo check command, could you make sure it would work out this way too? I've just reproduced the described panic on the 1.67.

$ cargo --version
cargo 1.67.0 (8ecd4f20a 2023-01-10)

@magniff
Copy link
Author

magniff commented Feb 1, 2023

Here, the same error in docker - https://github.com/magniff/rustc-trait-bug/tree/master. Better even, the error starts to appear from version 1.66 onwards, so 1.65 worked just fine.

@lukas-code
Copy link
Member

This needs incremental enabled to reproduce, but it seems fixed on nightly/beta: godbolt link.

#105260 looks related

@estebank estebank added 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. A-incr-comp Area: Incremental compilation labels Feb 1, 2023
@Noratrieb
Copy link
Member

Closing as it appears to be fixed. If it isn't, feel free to reopen.

@magniff
Copy link
Author

magniff commented Feb 27, 2023

Thanks! The nightly and beta seem to be good, will come back with reopen if the bug manifest itself on stable 1.68.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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

5 participants