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: could not fully normalize fn with -Z mir-opt-level=3 #67639

Closed
matthiaskrgr opened this issue Dec 26, 2019 · 1 comment · Fixed by #67800
Closed

ICE: could not fully normalize fn with -Z mir-opt-level=3 #67639

matthiaskrgr opened this issue Dec 26, 2019 · 1 comment · Fixed by #67800
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

rustc src/test/ui/issues/issue-38033.rs -Zmir-opt-level=3

file:

// run-pass
use std::marker;
use std::mem;

fn main() {
    let workers = (0..0).map(|_| result::<u32, ()>());
    drop(join_all(workers).poll());
}

trait Future {
    type Item;
    type Error;

    fn poll(&mut self) -> Result<Self::Item, Self::Error>;
}

trait IntoFuture {
    type Future: Future<Item=Self::Item, Error=Self::Error>;
    type Item;
    type Error;

    fn into_future(self) -> Self::Future;
}

impl<F: Future> IntoFuture for F {
    type Future = F;
    type Item = F::Item;
    type Error = F::Error;

    fn into_future(self) -> F {
        self
    }
}

struct FutureResult<T, E> {
    _inner: marker::PhantomData<(T, E)>,
}

fn result<T, E>() -> FutureResult<T, E> {
    loop {}
}

impl<T, E> Future for FutureResult<T, E> {
    type Item = T;
    type Error = E;

    fn poll(&mut self) -> Result<T, E> {
        loop {}
    }
}

struct JoinAll<I>
    where I: IntoIterator,
          I::Item: IntoFuture,
{
    elems: Vec<<I::Item as IntoFuture>::Item>,
}

fn join_all<I>(_: I) -> JoinAll<I>
    where I: IntoIterator,
          I::Item: IntoFuture,
{
    JoinAll { elems: vec![] }
}

impl<I> Future for JoinAll<I>
    where I: IntoIterator,
          I::Item: IntoFuture,
{
    type Item = Vec<<I::Item as IntoFuture>::Item>;
    type Error = <I::Item as IntoFuture>::Error;

    fn poll(&mut self) -> Result<Self::Item, Self::Error> {
        let elems = mem::replace(&mut self.elems, Vec::new());
        Ok(elems.into_iter().map(|e| {
            e
        }).collect::<Vec<_>>())
    }
}
error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:34: could not fully normalize `fn() -> alloc::raw_vec::RawVec<<<I as std::iter::IntoIterator>::Item as IntoFuture>::Item> {alloc::raw_vec::RawVec::<<<I as std::iter::IntoIterator>::Item as IntoFuture>::Item>::new}`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:891:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /home/matthias/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /home/matthias/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   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:1057
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   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:195
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:215
  10: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call
             at /home/matthias/vcs/github/rust_debug_assertions/src/liballoc/boxed.rs:1029
  11: rustc_driver::report_ice
             at src/librustc_driver/lib.rs:1160
  12: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:476
  13: std::panicking::begin_panic
             at /home/matthias/vcs/github/rust_debug_assertions/src/libstd/panicking.rs:401
  14: rustc_errors::HandlerInner::bug
             at src/librustc_errors/lib.rs:891
  15: rustc_errors::Handler::bug
             at src/librustc_errors/lib.rs:651
  16: rustc::util::bug::opt_span_bug_fmt::{{closure}}
             at src/librustc/util/bug.rs:36
  17: rustc::ty::context::tls::with_opt::{{closure}}
             at src/librustc/ty/context.rs:1875
  18: rustc::ty::context::tls::with_context_opt
             at src/librustc/ty/context.rs:1827
  19: rustc::ty::context::tls::with_opt
             at src/librustc/ty/context.rs:1875
  20: rustc::util::bug::opt_span_bug_fmt
             at src/librustc/util/bug.rs:32
  21: rustc::util::bug::bug_fmt
             at src/librustc/util/bug.rs:12
  22: rustc_traits::normalize_erasing_regions::normalize_ty_after_erasing_regions::{{closure}}
             at src/librustc_traits/normalize_erasing_regions.rs:34
  23: rustc::infer::InferCtxtBuilder::enter::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/infer/mod.rs:535
  24: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1545
  25: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
  26: rustc::ty::context::tls::set_tlv
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1699
  27: rustc::ty::context::tls::enter_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
  28: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1545
  29: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1854
  30: rustc::ty::context::tls::with_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
  31: rustc::ty::context::tls::with_context_opt
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1827
  32: rustc::ty::context::tls::with_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
  33: rustc::ty::context::tls::with_related_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1851
  34: rustc::ty::context::GlobalCtxt::enter_local
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1537
  35: rustc::infer::InferCtxtBuilder::enter
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/infer/mod.rs:534
  36: rustc_traits::normalize_erasing_regions::normalize_ty_after_erasing_regions
             at src/librustc_traits/normalize_erasing_regions.rs:19
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::normalize_ty_after_erasing_regions>::compute::{{closure}}
             at src/librustc/ty/query/plumbing.rs:971
  38: rustc::ty::query::__query_compute::normalize_ty_after_erasing_regions
             at src/librustc/ty/query/plumbing.rs:922
  39: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::normalize_ty_after_erasing_regions>::compute
             at src/librustc/ty/query/plumbing.rs:963
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
             at src/librustc/dep_graph/graph.rs:325
  41: rustc::dep_graph::graph::DepGraph::with_task
             at src/librustc/dep_graph/graph.rs:193
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at src/librustc/ty/query/plumbing.rs:543
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at src/librustc/ty/query/plumbing.rs:267
  44: rustc::ty::context::tls::enter_context::{{closure}}
             at src/librustc/ty/context.rs:1766
  45: rustc::ty::context::tls::set_tlv
             at src/librustc/ty/context.rs:1699
  46: rustc::ty::context::tls::enter_context
             at src/librustc/ty/context.rs:1766
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at src/librustc/ty/query/plumbing.rs:267
  48: rustc::ty::context::tls::with_related_context::{{closure}}
             at src/librustc/ty/context.rs:1854
  49: rustc::ty::context::tls::with_context::{{closure}}
             at src/librustc/ty/context.rs:1838
  50: rustc::ty::context::tls::with_context_opt
             at src/librustc/ty/context.rs:1827
  51: rustc::ty::context::tls::with_context
             at src/librustc/ty/context.rs:1838
  52: rustc::ty::context::tls::with_related_context
             at src/librustc/ty/context.rs:1851
  53: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at src/librustc/ty/query/plumbing.rs:256
  54: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at src/librustc/ty/query/plumbing.rs:533
  55: rustc::ty::query::plumbing::with_diagnostics
             at src/librustc/ty/query/plumbing.rs:201
  56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at src/librustc/ty/query/plumbing.rs:532
  57: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at src/librustc/ty/query/plumbing.rs:369
  58: rustc::ty::query::TyCtxtAt::normalize_ty_after_erasing_regions
             at src/librustc/ty/query/plumbing.rs:1048
  59: rustc::ty::query::<impl rustc::ty::context::TyCtxt>::normalize_ty_after_erasing_regions
             at src/librustc/ty/query/plumbing.rs:1040
  60: <rustc::traits::query::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc::ty::fold::TypeFolder>::fold_ty
             at src/librustc/traits/query/normalize_erasing_regions.rs:76
  61: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::fold_with
             at src/librustc/ty/structural_impls.rs:929
  62: rustc::traits::query::normalize_erasing_regions::<impl rustc::ty::context::TyCtxt>::normalize_erasing_regions
             at src/librustc/traits/query/normalize_erasing_regions.rs:36
  63: rustc::traits::codegen::<impl rustc::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
             at src/librustc/traits/codegen/mod.rs:100
  64: rustc::ty::instance::Instance::ty
             at src/librustc/ty/instance.rs:67
  65: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
             at src/librustc_mir/interpret/terminator.rs:208
  66: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_terminator
             at src/librustc_mir/interpret/terminator.rs:73
  67: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::terminator
             at src/librustc_mir/interpret/step.rs:284
  68: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::step
             at src/librustc_mir/interpret/step.rs:72
  69: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
             at src/librustc_mir/interpret/step.rs:34
  70: rustc_mir::const_eval::eval_body_using_ecx
             at src/librustc_mir/const_eval.rs:167
  71: rustc_mir::const_eval::const_eval_raw_provider::{{closure}}
             at src/librustc_mir/const_eval.rs:713
  72: core::result::Result<T,E>::and_then
             at /home/matthias/vcs/github/rust_debug_assertions/src/libcore/result.rs:720
  73: rustc_mir::const_eval::const_eval_raw_provider
             at src/librustc_mir/const_eval.rs:713
  74: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:971
  75: rustc::ty::query::__query_compute::const_eval_raw
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:922
  76: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:963
  77: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/dep_graph/graph.rs:325
  78: rustc::dep_graph::graph::DepGraph::with_task
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/dep_graph/graph.rs:193
  79: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:543
  80: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:267
  81: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
  82: rustc::ty::context::tls::set_tlv
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1699
  83: rustc::ty::context::tls::enter_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
  84: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:267
  85: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1854
  86: rustc::ty::context::tls::with_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
  87: rustc::ty::context::tls::with_context_opt
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1827
  88: rustc::ty::context::tls::with_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
  89: rustc::ty::context::tls::with_related_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1851
  90: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:256
  91: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:533
  92: rustc::ty::query::plumbing::with_diagnostics
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:201
  93: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:532
  94: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:369
  95: rustc::ty::query::TyCtxtAt::const_eval_raw
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:1048
  96: rustc_mir::interpret::eval_context::InterpCx<M>::const_eval_raw
             at src/librustc_mir/interpret/eval_context.rs:771
  97: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_const_to_op
             at src/librustc_mir/interpret/operand.rs:581
  98: rustc_mir::transform::const_prop::ConstPropagator::eval_constant
             at src/librustc_mir/transform/const_prop.rs:414
  99: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_constant
             at src/librustc_mir/transform/const_prop.rs:751
 100: rustc::mir::visit::MutVisitor::super_operand
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:678
 101: rustc::mir::visit::MutVisitor::visit_operand
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:141
 102: rustc::mir::visit::MutVisitor::super_rvalue
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:0
 103: rustc::mir::visit::MutVisitor::visit_rvalue
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:135
 104: rustc::mir::visit::MutVisitor::super_assign
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:423
 105: rustc::mir::visit::MutVisitor::visit_assign
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:111
 106: rustc::mir::visit::MutVisitor::super_statement
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:358
 107: <rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor>::visit_statement
             at src/librustc_mir/transform/const_prop.rs:801
 108: rustc::mir::visit::MutVisitor::super_basic_block_data
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:322
 109: rustc::mir::visit::MutVisitor::visit_basic_block_data
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:93
 110: rustc::mir::visit::MutVisitor::super_body
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:275
 111: rustc::mir::visit::MutVisitor::visit_body
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/mir/visit.rs:87
 112: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
             at src/librustc_mir/transform/const_prop.rs:97
 113: rustc_mir::transform::run_passes::{{closure}}
             at src/librustc_mir/transform/mod.rs:171
 114: rustc_mir::transform::run_passes
             at src/librustc_mir/transform/mod.rs:178
 115: rustc_mir::transform::run_optimization_passes
             at src/librustc_mir/transform/mod.rs:273
 116: rustc_mir::transform::optimized_mir
             at src/librustc_mir/transform/mod.rs:343
 117: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:971
 118: rustc::ty::query::__query_compute::optimized_mir
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:922
 119: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:963
 120: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/dep_graph/graph.rs:325
 121: rustc::dep_graph::graph::DepGraph::with_task
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/dep_graph/graph.rs:193
 122: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:543
 123: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:267
 124: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
 125: rustc::ty::context::tls::set_tlv
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1699
 126: rustc::ty::context::tls::enter_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
 127: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:267
 128: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1854
 129: rustc::ty::context::tls::with_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
 130: rustc::ty::context::tls::with_context_opt
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1827
 131: rustc::ty::context::tls::with_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
 132: rustc::ty::context::tls::with_related_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1851
 133: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:256
 134: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:533
 135: rustc::ty::query::plumbing::with_diagnostics
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:201
 136: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:532
 137: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:369
 138: rustc::ty::query::TyCtxtAt::optimized_mir
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:1048
 139: rustc::ty::query::<impl rustc::ty::context::TyCtxt>::optimized_mir
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:1040
 140: rustc_mir::transform::inline::Inliner::run_pass
             at src/librustc_mir/transform/inline.rs:108
 141: <rustc_mir::transform::inline::Inline as rustc_mir::transform::MirPass>::run_pass
             at src/librustc_mir/transform/inline.rs:43
 142: rustc_mir::transform::run_passes::{{closure}}
             at src/librustc_mir/transform/mod.rs:171
 143: rustc_mir::transform::run_passes
             at src/librustc_mir/transform/mod.rs:178
 144: rustc_mir::transform::run_optimization_passes
             at src/librustc_mir/transform/mod.rs:273
 145: rustc_mir::transform::optimized_mir
             at src/librustc_mir/transform/mod.rs:343
 146: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
             at src/librustc/ty/query/plumbing.rs:963
 147: rustc::dep_graph::graph::DepGraph::with_task_impl
             at src/librustc/dep_graph/graph.rs:325
 148: rustc::dep_graph::graph::DepGraph::with_task
             at src/librustc/dep_graph/graph.rs:193
 149: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at src/librustc/ty/query/plumbing.rs:543
 150: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at src/librustc/ty/query/plumbing.rs:267
 151: rustc::ty::context::tls::enter_context::{{closure}}
             at src/librustc/ty/context.rs:1766
 152: rustc::ty::context::tls::set_tlv
             at src/librustc/ty/context.rs:1699
 153: rustc::ty::context::tls::enter_context
             at src/librustc/ty/context.rs:1766
 154: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at src/librustc/ty/query/plumbing.rs:267
 155: rustc::ty::context::tls::with_related_context::{{closure}}
             at src/librustc/ty/context.rs:1854
 156: rustc::ty::context::tls::with_context::{{closure}}
             at src/librustc/ty/context.rs:1838
 157: rustc::ty::context::tls::with_context_opt
             at src/librustc/ty/context.rs:1827
 158: rustc::ty::context::tls::with_context
             at src/librustc/ty/context.rs:1838
 159: rustc::ty::context::tls::with_related_context
             at src/librustc/ty/context.rs:1851
 160: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at src/librustc/ty/query/plumbing.rs:256
 161: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at src/librustc/ty/query/plumbing.rs:533
 162: rustc::ty::query::plumbing::with_diagnostics
             at src/librustc/ty/query/plumbing.rs:201
 163: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at src/librustc/ty/query/plumbing.rs:532
 164: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at src/librustc/ty/query/plumbing.rs:369
 165: rustc::ty::query::TyCtxtAt::optimized_mir
             at src/librustc/ty/query/plumbing.rs:1048
 166: rustc::ty::query::<impl rustc::ty::context::TyCtxt>::optimized_mir
             at src/librustc/ty/query/plumbing.rs:1040
 167: rustc::ty::<impl rustc::ty::context::TyCtxt>::instance_mir
             at src/librustc/ty/mod.rs:2955
 168: rustc_mir::monomorphize::collector::collect_neighbours
             at src/librustc_mir/monomorphize/collector.rs:1221
 169: rustc_mir::monomorphize::collector::collect_items_rec
             at src/librustc_mir/monomorphize/collector.rs:381
 170: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}::{{closure}}
             at src/librustc_mir/monomorphize/collector.rs:306
 171: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/libcore/iter/traits/iterator.rs:652
 172: core::iter::traits::iterator::Iterator::fold::ok::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/libcore/iter/traits/iterator.rs:1900
 173: core::iter::traits::iterator::Iterator::try_fold
             at /home/matthias/vcs/github/rust_debug_assertions/src/libcore/iter/traits/iterator.rs:1776
 174: core::iter::traits::iterator::Iterator::fold
             at /home/matthias/vcs/github/rust_debug_assertions/src/libcore/iter/traits/iterator.rs:1903
 175: core::iter::traits::iterator::Iterator::for_each
             at /home/matthias/vcs/github/rust_debug_assertions/src/libcore/iter/traits/iterator.rs:655
 176: rustc_mir::monomorphize::collector::collect_crate_mono_items::{{closure}}
             at src/librustc_mir/monomorphize/collector.rs:304
 177: rustc::util::common::time_ext
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/util/common.rs:54
 178: rustc::util::common::time
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/util/common.rs:46
 179: rustc_mir::monomorphize::collector::collect_crate_mono_items
             at src/librustc_mir/monomorphize/collector.rs:303
 180: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items::{{closure}}
             at src/librustc_mir/monomorphize/partitioning.rs:870
 181: rustc::util::common::time_ext
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/util/common.rs:54
 182: rustc::util::common::time
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/util/common.rs:46
 183: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
             at src/librustc_mir/monomorphize/partitioning.rs:869
 184: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_and_partition_mono_items>::compute::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:971
 185: rustc::ty::query::__query_compute::collect_and_partition_mono_items
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:922
 186: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/dep_graph/graph.rs:325
 187: rustc::dep_graph::graph::DepGraph::with_eval_always_task
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/dep_graph/graph.rs:372
 188: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:535
 189: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:267
 190: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
 191: rustc::ty::context::tls::set_tlv
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1699
 192: rustc::ty::context::tls::enter_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
 193: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:267
 194: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1854
 195: rustc::ty::context::tls::with_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
 196: rustc::ty::context::tls::with_context_opt
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1827
 197: rustc::ty::context::tls::with_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1838
 198: rustc::ty::context::tls::with_related_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1851
 199: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:256
 200: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:533
 201: rustc::ty::query::plumbing::with_diagnostics
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:201
 202: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:532
 203: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:369
 204: rustc::ty::query::TyCtxtAt::collect_and_partition_mono_items
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:1048
 205: rustc::ty::query::<impl rustc::ty::context::TyCtxt>::collect_and_partition_mono_items
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/query/plumbing.rs:1040
 206: rustc_codegen_ssa::base::codegen_crate
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_codegen_ssa/base.rs:532
 207: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
             at src/librustc_codegen_llvm/lib.rs:263
 208: rustc_interface::passes::start_codegen::{{closure}}
             at src/librustc_interface/passes.rs:985
 209: rustc::util::common::time_ext
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/util/common.rs:54
 210: rustc::util::common::time
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/util/common.rs:46
 211: rustc_interface::passes::start_codegen
             at src/librustc_interface/passes.rs:983
 212: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
             at src/librustc_interface/queries.rs:282
 213: rustc_interface::passes::QueryContext::enter::{{closure}}
             at src/librustc_interface/passes.rs:711
 214: rustc::ty::context::tls::enter_global::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1789
 215: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
 216: rustc::ty::context::tls::set_tlv
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1699
 217: rustc::ty::context::tls::enter_context
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1766
 218: rustc::ty::context::tls::enter_global
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1789
 219: rustc_interface::passes::QueryContext::enter
             at src/librustc_interface/passes.rs:711
 220: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
             at src/librustc_interface/queries.rs:276
 221: rustc_interface::queries::Query<T>::compute
             at src/librustc_interface/queries.rs:34
 222: rustc_interface::queries::Queries::ongoing_codegen
             at src/librustc_interface/queries.rs:274
 223: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at src/librustc_driver/lib.rs:404
 224: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/queries.rs:332
 225: rustc_driver::run_compiler::{{closure}}
             at src/librustc_driver/lib.rs:295
 226: rustc_interface::interface::run_compiler_in_existing_thread_pool
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/interface.rs:184
 227: rustc_interface::interface::run_compiler::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/interface.rs:193
 228: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/util.rs:154
 229: rustc::ty::context::tls::with_thread_locals::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1755
 230: std::thread::local::LocalKey<T>::try_with
             at /home/matthias/vcs/github/rust_debug_assertions/src/libstd/thread/local.rs:262
 231: std::thread::local::LocalKey<T>::with
             at /home/matthias/vcs/github/rust_debug_assertions/src/libstd/thread/local.rs:239
 232: rustc::ty::context::tls::with_thread_locals::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1747
 233: std::thread::local::LocalKey<T>::try_with
             at /home/matthias/vcs/github/rust_debug_assertions/src/libstd/thread/local.rs:262
 234: std::thread::local::LocalKey<T>::with
             at /home/matthias/vcs/github/rust_debug_assertions/src/libstd/thread/local.rs:239
 235: rustc::ty::context::tls::with_thread_locals
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc/ty/context.rs:1739
 236: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/util.rs:154
 237: scoped_tls::ScopedKey<T>::set
             at /home/matthias/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
 238: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/util.rs:150
 239: scoped_tls::ScopedKey<T>::set
             at /home/matthias/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
 240: syntax::with_globals::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/libsyntax/lib.rs:60
 241: scoped_tls::ScopedKey<T>::set
             at /home/matthias/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
 242: syntax::with_globals
             at /home/matthias/vcs/github/rust_debug_assertions/src/libsyntax/lib.rs:60
 243: rustc_interface::util::spawn_thread_pool::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/util.rs:149
 244: rustc_interface::util::scoped_thread::{{closure}}
             at /home/matthias/vcs/github/rust_debug_assertions/src/librustc_interface/util.rs:126
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.42.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3

query stack during panic:
#0 [normalize_ty_after_erasing_regions] normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: fn() -> alloc::raw_vec::RawVec<<<I as std::iter::IntoIterator>::Item as IntoFuture>::Item> {alloc::raw_vec::RawVec::<<<I as std::iter::IntoIterator>::Item as IntoFuture>::Item>::new} }`
#1 [const_eval_raw] const-evaluating `alloc::raw_vec::RawVec::<T>::NEW`
#2 [optimized_mir] processing `<JoinAll<I> as Future>::poll`
#3 [optimized_mir] processing `main`
#4 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

rustc @ bbf1372

@jonas-schievink jonas-schievink added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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. requires-nightly This issue requires a nightly compiler in some way. labels Dec 27, 2019
@wesleywiser
Copy link
Member

I spent some time today looking into this and I have a cut down version of the above test:

fn main() {
    join_all::<u32>();
}

trait Foo {
    type Item;
}

impl Foo for u32 {
    type Item = u8;
}

trait Bar {
    type Item2;
}

impl Bar for u8 {
    type Item2 = u64;
}

fn join_all<I>()
where I: Foo,
    I::Item: Bar
{
    Vec::<<I::Item as Bar>::Item2>::new(); // ICE occurs processing this line
}

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jan 6, 2020
… r=oli-obk

Fix ICE involving calling `Instance.ty` during const evaluation

Fixes rust-lang#67639

`Instance.ty` assumes that we are in a fully monomorphic context (e.g.
codegen), and can therefore use an empty `ParamEnv` when performing
normalization. Howver, the MIR constant evaluator code ends up calling
`Instance.ty` as a result of us attemptign to 'speculatively'
const-evaluate generic functions during const propagation.

As a result,
we may end up with projections involving type parameters
(e.g. <T as MyTrait>::Bar>) in the type we are trying to normalize.
Normalization expects us to have proper predicates in the `ParamEnv` for
such projections, and will ICE if we don't.

This commit adds a new method `Instance.ty_env`, which takes a
`ParamEnv` for use during normalization. The MIR const-evaluator code is
changed to use this method, passing in the proper `ParamEnv` for the
context at hand.
@bors bors closed this as completed in ee922d4 Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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