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

assertion failed !ty::type_needs_infer when infering type of closure with a reference argument #14038

Closed
huonw opened this issue May 8, 2014 · 2 comments
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@huonw
Copy link
Member

huonw commented May 8, 2014

fn main() {
    let mut p: proc(&()) = match () {
        _ => proc(_) {}
    };
}
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'assertion failed: !ty::type_needs_infer(ty)', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/middle/typeck/mod.rs:251
stack backtrace:
   1:     0x7f5ab0346240 - rt::backtrace::imp::write::h47fe109ac3049adffza::v0.11.pre
   2:     0x7f5ab02975d0 - rt::unwind::begin_unwind_inner::h6061c949133dceeek99::v0.11.pre
   3:     0x7f5ab0297250 - rt::unwind::begin_unwind_fmt::h40112ecebfab41f4u89::v0.11.pre
   4:     0x7f5ab11aa940 - middle::typeck::write_ty_to_tcx::hf3e3ebe0cc028e99JNv::v0.11.pre
   5:     0x7f5ab11a4f50 - middle::typeck::check::writeback::resolve_type_vars_for_node::h05a8139df2037e2dcP2::v0.11.pre
   6:     0x7f5ab11ab890 - middle::typeck::check::writeback::visit_expr::hc3fe28c41c92bb09612::v0.11.pre
   7:     0x7f5ab11ad690 - middle::typeck::check::writeback::visit_local::hd2a7e1d446c15515w72::v0.11.pre
   8:     0x7f5ab11ab590 - middle::typeck::check::writeback::visit_stmt::h5a3eb6a3a123bc2bw12::v0.11.pre
   9:     0x7f5ab11ace40 - visit::walk_block::h774050335718882335::v0.11.pre
  10:     0x7f5ab11b0380 - middle::typeck::check::writeback::resolve_type_vars_in_fn::h14075a7c48abb418Fk3::v0.11.pre
  11:     0x7f5ab12035a0 - middle::typeck::check::check_bare_fn::h276d49bccf79d6cbib8::v0.11.pre
  12:     0x7f5ab11fb3e0 - middle::typeck::check::check_item::hf4303c618e67640ejI8::v0.11.pre
  13:     0x7f5ab12033a0 - middle::typeck::check::check_item_types::h3a12f8481de3c645Aa8::v0.11.pre
  14:     0x7f5ab134fe70 - util::common::time::h14771813586294062655::v0.11.pre
  15:     0x7f5ab134ebd0 - middle::typeck::check_crate::ha64d37049d8764a6L7v::v0.11.pre
  16:     0x7f5ab177a1d0 - driver::driver::phase_3_run_analysis_passes::hfcc0f62a0837a3f1ZDh::v0.11.pre
  17:     0x7f5ab177fa80 - driver::driver::compile_input::h109dae099456ee6aO3h::v0.11.pre
  18:     0x7f5ab17a4da0 - run_compiler::h05fa0a47a6b6f28bzwp::v0.11.pre
  19:     0x7f5ab17c13d0 - main_args::closure.93793
  20:     0x7f5ab17bf8d0 - monitor::closure.93668
  21:     0x7f5ab17ba090 - task::TaskBuilder::try::closure.93434
  22:     0x7f5ab09e10b0 - task::spawn_opts::closure.7161
  23:     0x7f5ab033bc70 - rt::task::Task::run::closure.40355
  24:     0x7f5ab034c5b0 - rust_try
  25:     0x7f5ab033bab0 - rt::task::Task::run::hf886fab2982b08c7nZ7::v0.11.pre
  26:     0x7f5ab09e0e80 - task::spawn_opts::closure.7134
  27:     0x7f5ab0344d80 - rt::thread::thread_start::h7d20e7f4bce06592AE8::v0.11.pre
  28:     0x7f5aae020fa0 - start_thread
  29:     0x7f5aaff6ba09 - __clone
  30:                0x0 - <unknown>

See #14037 for a similar scenario with let (this one also works when changing the argument type to something without a reference).

cc @nikomatsakis @pnkfelix

@kmcallister
Copy link
Contributor

In Rust master this would be something like

#![feature(default_type_params)]

use std::thunk::Thunk;

fn main() {
    let mut p: Thunk<&()> = match () {
        _ => Thunk::with_arg(move |_| {})
    };
}

which compiles without error.

@steveklabnik
Copy link
Member

Yes, with proc gone, this seems resolved.

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
Don't fail workspace loading if sysroot can't be found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants