rust-lang/rust

ICE: `reached the recursion limit finding the struct tail for`

matthiaskrgr opened this issue · 1 comments

Code

Could perhaps be an error instead of ice?

#![recursion_limit = "10"]
macro_rules! link {
    ($outer:ident, $inner:ident) => {
        struct $outer($inner);
        impl $outer {
            fn new() -> $outer {
                $outer($inner::new())
            }
        }
        impl std::ops::Deref for $outer {
            type Target = $inner;
            fn deref(&self) -> &$inner {
                &self.0
            }
        }
    };
}

struct Bottom;

impl Bottom {
    fn new() -> Bottom {
        Bottom
    }
}

link!(Top, A);
link!(A, B);
link!(B, C);
link!(C, D);
link!(D, E);
link!(E, F);
link!(F, G);
link!(G, H);
link!(H, I);
link!(I, J);
link!(J, K);
link!(K, Bottom);

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (13afbdaa0 2023-03-17)
binary: rustc
commit-hash: 13afbdaa0655dda23d7129e59ac48f1ec88b2084
commit-date: 2023-03-17
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

warning: associated function `new` is never used
  --> treereduce.out:22:8
   |
22 |     fn new() -> Bottom {
   |        ^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
27 | link!(Top, A);
   | ------------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
28 | link!(A, B);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
29 | link!(B, C);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
30 | link!(C, D);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
31 | link!(D, E);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
32 | link!(E, F);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
33 | link!(F, G);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
34 | link!(G, H);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
35 | link!(H, I);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
36 | link!(I, J);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
37 | link!(J, K);
   | ----------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: associated function `new` is never used
  --> treereduce.out:6:16
   |
6  |             fn new() -> $outer {
   |                ^^^
...
38 | link!(K, Bottom);
   | ---------------- in this macro invocation
   |
   = note: this warning originates in the macro `link` (in Nightly builds, run with -Z macro-backtrace for more info)
Backtrace


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

error: internal compiler error: reached the recursion limit finding the struct tail for Bottom
  |
  = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
             3: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_call
             4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
             6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
             7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
             8: rustc_hir_typeck::check::check_fn
             9: rustc_hir_typeck::typeck
            10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
            11: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_hir_typeck::typeck_item_bodies::{closure#0}>::{closure#0}>
            12: rustc_hir_typeck::typeck_item_bodies
            13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
            14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
            15: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#7}>
            16: rustc_hir_analysis::check_crate
            17: rustc_interface::passes::analysis
            18: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
            19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
            20: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            21: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
            22: rustc_span::with_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
            23: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            24: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            25: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/alloc/src/boxed.rs:1988:9
            26: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/alloc/src/boxed.rs:1988:9
            27: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/sys/unix/thread.rs:108:17
            28: <unknown>
            29: <unknown>


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.70.0-nightly (13afbdaa0 2023-03-17) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack
error: aborting due to 2 previous errors; 13 warnings emitted

@rustbot label +S-bug-has-mcve