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: TyKind::Error constructed but no error reported #112201

Open
matthiaskrgr opened this issue Jun 2, 2023 · 3 comments
Open

ice: TyKind::Error constructed but no error reported #112201

matthiaskrgr opened this issue Jun 2, 2023 · 3 comments
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) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

pub fn compose(
    f1: impl FnOnce(f64) -> f64 + Clone,
    f2: impl FnOnce(f64) -> f64 + Clone,
) -> impl FnOnce(f64) -> f64 + Clone {
    move |x| f1(f2(x))
}

fn repeat_helper(
    f: impl FnOnce(f64) -> f64 + Clone,
    res: impl FnOnce(f64) -> f64 + Clone,
    times: usize,
) -> impl FnOnce(f64) -> f64 + Clone {
    return res;
    repeat_helper(f.clone(), compose(f, res), times - 1)
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (d59363ad0 2023-06-01)
binary: rustc
commit-hash: d59363ad0b6391b7fc5bbb02c9ccf9300eef3753
commit-date: 2023-06-01
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.4

Error output

warning: unreachable expression
  --> treereduce.out:14:5
   |
13 |     return res;
   |     ---------- any code following this expression is unreachable
14 |     repeat_helper(f.clone(), compose(f, res), times - 1)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable expression
   |
   = note: `#[warn(unreachable_code)]` on by default

warning: unused variable: `f`
 --> treereduce.out:9:5
  |
9 |     f: impl FnOnce(f64) -> f64 + Clone,
  |     ^ help: if this is intentional, prefix it with an underscore: `_f`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `times`
  --> treereduce.out:11:5
   |
11 |     times: usize,
   |     ^^^^^ help: if this is intentional, prefix it with an underscore: `_times`

warning: function `repeat_helper` is never used
 --> treereduce.out:8:4
  |
8 | fn repeat_helper(
  |    ^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default
Backtrace

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

error: internal compiler error: TyKind::Error constructed but no error reported
  |
  = note: delayed at compiler/rustc_middle/src/ty/opaque_types.rs:189:41
             0: <rustc_errors::HandlerInner>::emit_diagnostic
             1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
             2: <rustc_middle::ty::context::TyCtxt>::ty_error_misc
             3: <rustc_middle::ty::opaque_types::ReverseMapper as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
             4: <rustc_middle::ty::OpaqueHiddenType>::remap_generic_params_to_declaration_params
             5: rustc_hir_analysis::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
             6: rustc_hir_analysis::collect::type_of::type_of
             7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
             8: <rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
             9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            10: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
            11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
            12: rustc_hir_analysis::check::check::check_mod_item_types
            13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
            14: <rustc_query_impl::query_impl::check_mod_item_types::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
            15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            16: rustc_query_impl::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
            17: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
            18: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#6}>
            19: rustc_hir_analysis::check_crate
            20: rustc_interface::passes::analysis
            21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            22: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
            23: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            24: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            25: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            26: <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>>
            27: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<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>>
            28: 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>>
            29: <<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}
            30: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/alloc/src/boxed.rs:1985:9
            31: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/alloc/src/boxed.rs:1985:9
            32: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/std/src/sys/unix/thread.rs:108:17
            33: <unknown>
            34: <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.72.0-nightly (d59363ad0 2023-06-01) running on x86_64-unknown-linux-gnu

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

@matthiaskrgr matthiaskrgr 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. C-bug Category: This is a bug. labels Jun 2, 2023
@matthiaskrgr
Copy link
Member Author

#111980 cc @compiler-errors

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 11, 2023
@matthiaskrgr
Copy link
Member Author

trait Trait {}
impl Trait for () {}

fn foo<T: Trait, U: Trait>() -> impl Trait {
    let a: T = foo::<T, U>();
    loop {}
    let _: T = foo::<U, U>();
}

fn main() {}

@gurry
Copy link
Contributor

gurry commented Dec 19, 2023

Reduced a tiny bit further by removing the first recursive foo() call:

trait Trait {}
impl Trait for () {}

fn foo<T: Trait, U: Trait>() -> impl Trait {
    loop {}
    let _: T = foo::<U, U>();
}

fn main() {}

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
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) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

3 participants