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: called Option::unwrap() on a None value in collector.rs:934:13 #105488

Closed
EqualMa opened this issue Dec 9, 2022 · 2 comments · Fixed by #123579
Closed

ICE: called Option::unwrap() on a None value in collector.rs:934:13 #105488

EqualMa opened this issue Dec 9, 2022 · 2 comments · Fixed by #123579
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

@EqualMa
Copy link
Contributor

EqualMa commented Dec 9, 2022

Code

pub trait MyFnOnce {
    type Output;

    fn call_my_fn_once(self) -> Self::Output;
}

pub struct WrapFnOnce<F>(F);

impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
    type Output = D::Output;

    fn call_my_fn_once(self) -> Self::Output {
        D::call_my_fn_once(self.0())
    }
}

impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for F {
    type Output = D::Output;

    fn call_my_fn_once(self) -> Self::Output {
        D::call_my_fn_once(self())
    }
}

pub fn my_fn_1() -> impl MyFnOnce {
    my_fn_2
}

pub fn my_fn_2() -> impl MyFnOnce {
    WrapFnOnce(my_fn_1)
}

fn main() {
    let v = my_fn_1();

    let _ = v.call_my_fn_once();
}

Meta

rustc --version --verbose:

rustc 1.67.0-nightly (7632db0e8 2022-12-08)
binary: rustc
commit-hash: 7632db0e87d8adccc9a83a47795c9411b1455855
commit-date: 2022-12-08
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.6

Error output

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_monomorphize/src/collector.rs:934:13
Backtrace

   Compiling playground v0.0.1 (/playground)
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_monomorphize/src/collector.rs:934:13
stack backtrace:
   0:     0x7f3aa13546fa - std::backtrace_rs::backtrace::libunwind::trace::hd10eda5ab6cb4cdc
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f3aa13546fa - std::backtrace_rs::backtrace::trace_unsynchronized::hc2d933a1d87136b7
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f3aa13546fa - std::sys_common::backtrace::_print_fmt::hbc6e39d05cece0e1
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f3aa13546fa - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4e096cc08b8f7ff2
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f3aa13b725e - core::fmt::write::hc749f618e420865d
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f3aa1344b85 - std::io::Write::write_fmt::hcc30ae83ad852555
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/io/mod.rs:1682:15
   6:     0x7f3aa13544c5 - std::sys_common::backtrace::_print::h959485d45136857a
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f3aa13544c5 - std::sys_common::backtrace::print::h0230b8f1225098e1
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f3aa135720f - std::panicking::default_hook::{{closure}}::h8a33a3e829ffa1d9
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/panicking.rs:267:22
   9:     0x7f3aa1356f4b - std::panicking::default_hook::hf47ea80dd34c42c2
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/panicking.rs:286:9
  10:     0x7f3aa1357a2c - std::panicking::rust_panic_with_hook::h35768f1f6cd02ad1
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/panicking.rs:688:13
  11:     0x7f3aa1357782 - std::panicking::begin_panic_handler::{{closure}}::h170be62b62ce816d
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/panicking.rs:577:13
  12:     0x7f3aa1354bac - std::sys_common::backtrace::__rust_end_short_backtrace::h4da703bbf123f25f
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x7f3aa13574d2 - rust_begin_unwind
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/panicking.rs:575:5
  14:     0x7f3aa13b3c43 - core::panicking::panic_fmt::hd20232bc69d718fb
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/core/src/panicking.rs:64:14
  15:     0x7f3aa13b3d1d - core::panicking::panic::h2f5d8547ea5d8675
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/core/src/panicking.rs:111:5
  16:     0x7f3aa2f77181 - rustc_monomorphize[ac07385237987836]::collector::collect_neighbours
  17:     0x7f3aa2f6bcf3 - rustc_monomorphize[ac07385237987836]::collector::collect_items_rec
  18:     0x7f3aa393618b - <rustc_session[fff9c52cf8bf58c5]::session::Session>::time::<(), rustc_monomorphize[ac07385237987836]::collector::collect_crate_mono_items::{closure#1}>
  19:     0x7f3aa3935cc4 - rustc_monomorphize[ac07385237987836]::collector::collect_crate_mono_items
  20:     0x7f3aa3934eb2 - rustc_monomorphize[ac07385237987836]::partitioning::collect_and_partition_mono_items
  21:     0x7f3aa3df1d60 - rustc_query_system[ddabab1eafb597f0]::query::plumbing::try_execute_query::<rustc_query_impl[441135ee144544b6]::plumbing::QueryCtxt, rustc_query_system[ddabab1eafb597f0]::query::caches::DefaultCache<(), (&std[9caeed11b21f461c]::collections::hash::set::HashSet<rustc_span[408aba7b93829b91]::def_id::DefId, core[295bdcd7e201aec9]::hash::BuildHasherDefault<rustc_hash[2ab1c81de4210e6f]::FxHasher>>, &[rustc_middle[a177af8518e4397e]::mir::mono::CodegenUnit])>>
  22:     0x7f3aa3df1a24 - rustc_query_system[ddabab1eafb597f0]::query::plumbing::get_query::<rustc_query_impl[441135ee144544b6]::queries::collect_and_partition_mono_items, rustc_query_impl[441135ee144544b6]::plumbing::QueryCtxt>
  23:     0x7f3aa3df195e - <rustc_query_impl[441135ee144544b6]::Queries as rustc_middle[a177af8518e4397e]::ty::query::QueryEngine>::collect_and_partition_mono_items
  24:     0x7f3aa3cf444b - rustc_codegen_ssa[ec46c1e35304f29e]::base::codegen_crate::<rustc_codegen_llvm[c5895aada7efadbf]::LlvmCodegenBackend>
  25:     0x7f3aa3cf41f9 - <rustc_codegen_llvm[c5895aada7efadbf]::LlvmCodegenBackend as rustc_codegen_ssa[ec46c1e35304f29e]::traits::backend::CodegenBackend>::codegen_crate
  26:     0x7f3aa3803c81 - <rustc_session[fff9c52cf8bf58c5]::session::Session>::time::<alloc[101a34d45fdb044a]::boxed::Box<dyn core[295bdcd7e201aec9]::any::Any>, rustc_interface[c8c7d65f4d7c863b]::passes::start_codegen::{closure#0}>
  27:     0x7f3aa38037a9 - rustc_interface[c8c7d65f4d7c863b]::passes::start_codegen
  28:     0x7f3aa38026b6 - <rustc_interface[c8c7d65f4d7c863b]::passes::QueryContext>::enter::<<rustc_interface[c8c7d65f4d7c863b]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[295bdcd7e201aec9]::result::Result<alloc[101a34d45fdb044a]::boxed::Box<dyn core[295bdcd7e201aec9]::any::Any>, rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>
  29:     0x7f3aa37ffed6 - <rustc_interface[c8c7d65f4d7c863b]::queries::Queries>::ongoing_codegen
  30:     0x7f3aa37ff3b1 - <rustc_interface[c8c7d65f4d7c863b]::interface::Compiler>::enter::<rustc_driver[a56d989e388971fc]::run_compiler::{closure#1}::{closure#2}, core[295bdcd7e201aec9]::result::Result<core[295bdcd7e201aec9]::option::Option<rustc_interface[c8c7d65f4d7c863b]::queries::Linker>, rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>
  31:     0x7f3aa37fa358 - rustc_span[408aba7b93829b91]::with_source_map::<core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>, rustc_interface[c8c7d65f4d7c863b]::interface::run_compiler<core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>, rustc_driver[a56d989e388971fc]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  32:     0x7f3aa37f9e45 - <scoped_tls[c17d4fcbe085de89]::ScopedKey<rustc_span[408aba7b93829b91]::SessionGlobals>>::set::<rustc_interface[c8c7d65f4d7c863b]::interface::run_compiler<core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>, rustc_driver[a56d989e388971fc]::run_compiler::{closure#1}>::{closure#0}, core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>
  33:     0x7f3aa37f9432 - std[9caeed11b21f461c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c8c7d65f4d7c863b]::util::run_in_thread_pool_with_globals<rustc_interface[c8c7d65f4d7c863b]::interface::run_compiler<core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>, rustc_driver[a56d989e388971fc]::run_compiler::{closure#1}>::{closure#0}, core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>
  34:     0x7f3aa3f31518 - <<std[9caeed11b21f461c]::thread::Builder>::spawn_unchecked_<rustc_interface[c8c7d65f4d7c863b]::util::run_in_thread_pool_with_globals<rustc_interface[c8c7d65f4d7c863b]::interface::run_compiler<core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>, rustc_driver[a56d989e388971fc]::run_compiler::{closure#1}>::{closure#0}, core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[295bdcd7e201aec9]::result::Result<(), rustc_errors[a151aa0c6b700682]::ErrorGuaranteed>>::{closure#1} as core[295bdcd7e201aec9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f3aa5434b33 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0e5495d7a0467227
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/alloc/src/boxed.rs:2000:9
  36:     0x7f3aa5434b33 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf2dc136765fe433b
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/alloc/src/boxed.rs:2000:9
  37:     0x7f3aa5434b33 - std::sys::unix::thread::Thread::new::thread_start::h249747de8b82cef9
                               at /rustc/7632db0e87d8adccc9a83a47795c9411b1455855/library/std/src/sys/unix/thread.rs:108:17
  38:     0x7f3aa1226609 - start_thread
  39:     0x7f3aa1149133 - clone
  40:                0x0 - <unknown>
error: could not compile `playground`

@EqualMa EqualMa 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 Dec 9, 2022
@chenyukang
Copy link
Member

@rustbot claim

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 22, 2022
@chenyukang chenyukang removed their assignment Dec 23, 2022
@chenyukang
Copy link
Member

@compiler-errors
this ICE now triggered with this error message:

error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:411:25: failed to resolve instance for <fn() -> impl MyFnOnce {my_fn_2} as MyFnOnce>::call_my_fn_once: Ok(
                                    None,
                                )

thread 'rustc' panicked at /Users/yukang/rust/compiler/rustc_errors/src/lib.rs:1635:9:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
             at ./library/std/src/panicking.rs:649:12
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
             at ./library/std/src/panic.rs:63:5
   2: <rustc_errors::HandlerInner>::bug::<alloc::string::String>
             at ./compiler/rustc_errors/src/lib.rs:1635:9
   3: <rustc_errors::Handler>::bug::<alloc::string::String>
             at ./compiler/rustc_errors/src/lib.rs:1048:9
   4: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
             at ./compiler/rustc_middle/src/util/bug.rs:35:34
   5: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
             at ./compiler/rustc_middle/src/ty/context/tls.rs:154:36
   6: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
             at ./compiler/rustc_middle/src/ty/context/tls.rs:100:18
   7: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>
             at ./compiler/rustc_middle/src/ty/context/tls.rs:154:5
   8: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
             at ./compiler/rustc_middle/src/util/bug.rs:31:5
   9: rustc_middle::util::bug::bug_fmt
             at ./compiler/rustc_middle/src/util/bug.rs:15:5
  10: <rustc_middle::ty::instance::Instance>::expect_resolve
             at ./compiler/rustc_middle/src/ty/instance.rs:411:25
  11: rustc_monomorphize::collector::visit_fn_use
             at ./compiler/rustc_monomorphize/src/collector.rs:880:13
  12: <rustc_monomorphize::collector::MirUsedCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
             at ./compiler/rustc_monomorphize/src/collector.rs:744:17

since your PR #105569 landed.

do you any idea on how to resolve it?
I'm not sure whether this is a valid program...

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 7, 2024
@bors bors closed this as completed in 7836909 Apr 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 7, 2024
Rollup merge of rust-lang#123579 - matthiaskrgr:I_Love_Tests, r=jieyouxu

add some more tests

Fixes rust-lang#115806
Fixes rust-lang#116710
Fixes rust-lang#123145
Fixes rust-lang#105488
Fixes rust-lang#122488
Fixes rust-lang#123078
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
Development

Successfully merging a pull request may close this issue.

3 participants