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 thread 'main' panicked at 'expected fn type' or at 'Box<Any>', #56197

Closed
RGates94 opened this issue Nov 24, 2018 · 2 comments
Closed

ICE thread 'main' panicked at 'expected fn type' or at 'Box<Any>', #56197

RGates94 opened this issue Nov 24, 2018 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@RGates94
Copy link

RGates94 commented Nov 24, 2018

The following code produces two different ICEs when compiling with stable and nightly respectively:

use std::path::Path;
use std::thread;
use std::ffi::OsStr;

pub struct Music {
    path: String,
}

fn main() {
}

impl Music {
    fn start(&mut self, time: Option<i32>) {
        if let Some(time) = time {
            let path = self.path.clone();
            thread::spawn(move || match Path::new(&self.path).extension() {
                Some(OsStr::new("ogg")) => {},
                _ => {}
            });
        }
        ()
    }
}

On stable 1.30.1 x86_64-pc-windows-msvc this produces:

thread 'main' panicked at 'expected fn type', libcore\option.rs:1000:5
stack backtrace:
   0: <std::sys::windows::args::Args as core::ops::drop::Drop>::drop
   1: <std::ffi::os_str::OsString as std::sys_common::IntoInner<std::sys::windows::os_str::Buf>>::into_inner
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::option::expect_failed
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <rustc_typeck::check::method::suggest::TraitInfo as core::cmp::PartialOrd>::partial_cmp
  15: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  16: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  17: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  18: <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_pat
  19: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  20: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  21: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  22: <unknown>
  23: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  24: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  25: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  26: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  27: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  28: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  29: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  30: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  31: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  32: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  33: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  34: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::record_ty
  35: <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_pat
  36: <rustc_typeck::check::method::suggest::TraitInfo as core::cmp::PartialOrd>::partial_cmp
  37: <rustc_typeck::astconv::Bounds<'tcx> as core::fmt::Debug>::fmt
  38: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
  39: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  40: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  41: rustc::ty::context::tls::track_diagnostic
  42: rustc::dep_graph::graph::DepGraph::assert_ignored
  43: rustc::ty::context::tls::track_diagnostic
  44: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  47: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
  48: rustc::ty::query::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::query::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  49: rustc::ty::context::tls::track_diagnostic
  50: rustc::dep_graph::graph::DepGraph::assert_ignored
  51: rustc::ty::context::tls::track_diagnostic
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  53: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  54: rustc_typeck::check_crate
  55: <unknown>
  56: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty::HirPrinterSupport<'hir>>::sess
  57: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  58: rustc_driver::driver::compile_input
  59: rustc_driver::run_compiler
  60: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  61: rustc_driver::run_compiler
  62: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  63: _rust_maybe_catch_panic
  64: rustc_driver::profile::dump
  65: rustc_driver::main
  66: <unknown>
  67: std::panicking::update_panic_count
  68: _rust_maybe_catch_panic
  69: std::rt::lang_start_internal
  70: <unknown>
  71: <unknown>
  72: BaseThreadInitThunk
  73: RtlUserThreadStart
query stack during panic:
#0 [typeck_tables_of] processing `Music::start`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.30.1 (1433507eb 2018-11-07) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: Could not compile `ICE_test`.

To learn more, run the command again with --verbose.

On nightly 1.32.0 x86_64-pc-windows-msvc this produces:

error[E0164]: expected tuple struct/variant, found method `<OsStr>::new`
  --> src\main.rs:17:22
   |
17 |                 Some(OsStr::new("ogg")) => {},
   |                      ^^^^^^^^^^^^^^^^^ not a tuple variant or struct

error: internal compiler error: src\librustc\middle\mem_categorization.rs:1302: tuple struct pattern didn't resolve to variant or struct Method(DefId(1/0:1527 ~ std[8a2d]::ffi[0]::os_str[0]::{{impl}}[17]::new[0]))
  --> src\main.rs:17:22
   |
17 |                 Some(OsStr::new("ogg")) => {},
   |                      ^^^^^^^^^^^^^^^^^

thread 'main' panicked at 'Box<Any>', src\librustc_errors\lib.rs:538:9
stack backtrace:
   0: std::sys_common::alloc::realloc_fallback
   1: std::panicking::take_hook
   2: std::panicking::take_hook
   3: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::ty::instance::InstanceDef<'a>>::lift_to_tcx
   4: std::panicking::rust_panic_with_hook
   5: <rustc::hir::intravisit::IdRange as core::fmt::Debug>::fmt
   6: rustc::session::CrateDisambiguator::to_fingerprint
   7: rustc::ty::context::tls::track_diagnostic
   8: rustc::ty::context::tls::track_diagnostic
   9: rustc::ty::context::tls::track_diagnostic
  10: rustc::ty::context::tls::track_diagnostic
  11: rustc::util::bug::bug_fmt
  12: rustc::util::bug::bug_fmt
  13: rustc::middle::mem_categorization::MemCategorizationContext::cat_rvalue
  14: rustc::middle::mem_categorization::MemCategorizationContext::cat_rvalue
  15: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  16: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
  17: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_body
  18: <rustc_typeck::collect::ItemCtxt<'a, 'tcx> as rustc_typeck::astconv::AstConv<'tcx, 'tcx>>::set_tainted_by_errors
  19: <rustc_typeck::check::upvar::InferBorrowKindVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  20: <rustc_typeck::check::PathSeg as core::fmt::Debug>::fmt
  21: <rustc_typeck::check::PathSeg as core::fmt::Debug>::fmt
  22: <rustc_typeck::check::PathSeg as core::fmt::Debug>::fmt
  23: <rustc_typeck::check::PathSeg as core::fmt::Debug>::fmt
  24: <rustc_typeck::namespace::Namespace as core::fmt::Debug>::fmt
  25: <rustc_typeck::outlives::implicit_infer::IgnoreSelfTy as core::fmt::Debug>::fmt
  26: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
  27: <rustc::traits::query::type_op::subtype::Subtype<'tcx> as core::fmt::Debug>::fmt
  28: rustc::ty::context::tls::track_diagnostic
  29: rustc::ty::context::tls::track_diagnostic
  30: rustc::dep_graph::graph::DepGraph::assert_ignored
  31: rustc::ty::context::tls::track_diagnostic
  32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  35: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
  36: rustc::ty::context::tls::track_diagnostic
  37: rustc::ty::context::tls::track_diagnostic
  38: rustc::dep_graph::graph::DepGraph::assert_ignored
  39: rustc::ty::context::tls::track_diagnostic
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  42: rustc_typeck::check_crate
  43: <humantime::wrapper::Duration as core::convert::Into<core::time::Duration>>::into
  44: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty::HirPrinterSupport<'hir>>::sess
  45: <humantime::wrapper::Duration as core::convert::Into<core::time::Duration>>::into
  46: rustc_driver::driver::compile_input
  47: rustc_driver::run_compiler
  48: rustc_driver::driver::build_output_filenames
  49: rustc_driver::run_compiler
  50: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_item
  51: _rust_maybe_catch_panic
  52: rustc_driver::profile::dump
  53: rustc_driver::main
  54: <unknown>
  55: std::panicking::update_panic_count
  56: _rust_maybe_catch_panic
  57: std::rt::lang_start_internal
  58: <unknown>
  59: <unknown>
  60: BaseThreadInitThunk
  61: RtlUserThreadStart
query stack during panic:
#0 [typeck_tables_of] processing `Music::start`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0164`.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.32.0-nightly (1f57e4841 2018-11-23) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: Could not compile `ICE_test`.

To learn more, run the command again with --verbose.

I have tried to minimize the code required to produce this, but it may be possible to simplify further.

@RGates94 RGates94 changed the title thread 'main' panicked at 'expected fn type' or at 'Box<Any>', ICE thread 'main' panicked at 'expected fn type' or at 'Box<Any>', Nov 24, 2018
@RGates94
Copy link
Author

I found a more minimal example that produces the same set of errors:

use std::ffi::OsStr;
use std::path::Path;
use std::thread;

fn main() {}

fn start(p: String) {
    thread::spawn(move || match Path::new(&p).extension() {
        Some(OsStr::new("ogg")) => {}
        _ => {}
    });
}

This seems like it may be related to #55513 in the stable case and #55913 in nightly, but the situations producing it are sufficiently different that I am not sure.

@Centril Centril added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 25, 2018
@oli-obk
Copy link
Contributor

oli-obk commented Jan 14, 2019

Now tracked in #57240

@oli-obk oli-obk closed this as completed Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants