Skip to content

Compiler panicked when tried to do something silly #58557

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

Closed
bartsmykla opened this issue Feb 18, 2019 · 7 comments
Closed

Compiler panicked when tried to do something silly #58557

bartsmykla opened this issue Feb 18, 2019 · 7 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@bartsmykla
Copy link

bartsmykla commented Feb 18, 2019

Hi everyone!

When I was working on solving one of katas from codewars I did something silly. When I was implementing PartialOrd:

impl PartialOrd for Word {
    fn partial_cmp(&self, other: &Word) -> Option<Ordering> {
        match self.length.cmp(&other.length) {
            Greater => Some(Less),
            Less    => Some(Greater),
            Equal   => Self(self.format().cmp(&other.format())),
        }
    }
}

instead of writing (yes, now I know that I should just use .partial_cmp() instead of .cmp and then wrapping it into Some)

Some(self.format().cmp(&other.format()))

by mistake I wrote:

Self(self.format().cmp(&other.format()))

and I received error:

error: internal compiler error: src/librustc/hir/def.rs:267: attempted .def_id() on invalid def: SelfCtor(DefId(0/0:81 ~ codewars[7ad7]::katas[0]::strings_mix[0]::{{impl}}[2]))

thread 'main' panicked at 'Box<Any>', src/librustc_errors/lib.rs:600:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::bug_fmt
  14: rustc::hir::def::Def::def_id::{{closure}}
  15: rustc::hir::def::Def::def_id
  16: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call
  17: rustc_typeck::check::FnCtxt::check_expr_kind
  18: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  19: rustc_typeck::check::FnCtxt::check_expr_kind
  20: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  21: rustc_typeck::check::FnCtxt::check_block_with_expected
  22: rustc_typeck::check::FnCtxt::check_expr_kind
  23: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  24: rustc_typeck::check::FnCtxt::check_return_expr
  25: rustc_typeck::check::check_fn
  26: rustc::ty::context::tls::with_related_context
  27: rustc::infer::InferCtxtBuilder::enter
  28: rustc_typeck::check::typeck_tables_of
  29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
  30: rustc::ty::context::tls::with_context
  31: rustc::dep_graph::graph::DepGraph::with_task_impl
  32: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  36: rustc::session::Session::track_errors
  37: rustc_typeck::check::typeck_item_bodies
  38: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute
  39: rustc::ty::context::tls::with_context
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  41: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  44: rustc::util::common::time
  45: rustc_typeck::check_crate
  46: rustc::ty::context::tls::enter_context
  47: <std::thread::local::LocalKey<T>>::with
  48: rustc::ty::context::TyCtxt::create_and_enter
  49: rustc_driver::driver::compile_input
  50: rustc_driver::run_compiler_with_pool
  51: <scoped_tls::ScopedKey<T>>::set
  52: rustc_driver::run_compiler
  53: syntax::with_globals
  54: __rust_maybe_catch_panic
  55: rustc_driver::run
  56: rustc_driver::main
  57: std::rt::lang_start::{{closure}}
  58: std::panicking::try::do_call
  59: __rust_maybe_catch_panic
  60: std::rt::lang_start_internal
  61: main
query stack during panic:
#0 [typeck_tables_of] processing `<katas::strings_mix::Word as std::cmp::PartialOrd>::partial_cmp`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to previous error


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.33.0-nightly (96d1334e5 2018-12-14) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental

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

as the error says, I'm opening this issue (even if it's just my silly mistake).

@jonas-schievink
Copy link
Contributor

Please try again on the current nightly. If it still happens, can you post a reproducer?

@bartsmykla
Copy link
Author

I'm on it

@bartsmykla
Copy link
Author

I can't update nightly because of that: #57771

➜  findlinks rustup update
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-x86_64-apple-darwin'
info: latest update on 2019-02-18, rust version 1.34.0-nightly (9a3392e17 2019-02-17)
error: component 'rls' for target 'x86_64-apple-darwin' is unavailable for download
info: checking for self-updates

       stable-x86_64-apple-darwin unchanged - rustc 1.32.0 (9fda7c223 2019-01-16)
  nightly-x86_64-apple-darwin update failed - rustc 1.33.0-nightly (96d1334e5 2018-12-14)

@hellow554
Copy link
Contributor

You could use the playground to check if it works or not

@hellow554
Copy link
Contributor

Can you try to provide a MCVE for that? Your code is realtivly spare. Try to use the plaground and share the code with us by using the share button in the upper right corner.

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

oli-obk commented Feb 18, 2019

You can get a nightly without all the components by updating to a concrete nightly (e.g. rustup override set nightly-2019-02-17)

@bartsmykla
Copy link
Author

After updating to 1.34 (nightly) problem disappeared (it also didn't appear on playground with the newest nightly). Sorry guys for bothering you.

@oli-obk oli-obk closed this as completed Feb 18, 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

5 participants