Skip to content

Rustc 1.33 stable panicked on a closure inside a closure #58840

Closed
@julien1619

Description

@julien1619

Rustc 1.33 panicked while compiling a code that was working well on 1.32.

I tried this code:

extern crate chrono;
extern crate dotenv;
extern crate futures;
extern crate hyper;
#[macro_use]
extern crate juniper;
extern crate juniper_hyper;
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
extern crate uuid;

mod context;
mod schema;

use context::Context;
use dotenv::dotenv;
use futures::future;
use hyper::rt::Future;
use hyper::service::service_fn;
use hyper::{Body, Method, Response, Server, StatusCode};
use schema::{Mutation, Query, Schema};
use std::sync::Arc;

fn main() {
    // Load configuration
    dotenv().ok();

    // Prepare logger
    pretty_env_logger::init();

    info!("Starting Cardioid API");

    // Prepare HOST configuration
    let host = std::env::var("HOST").expect("Missing HOST definition in env variables");
    let address = host.parse().expect("Invalid HOST configuration");

    // Prepare context and schema
    let context = Arc::new(Context {});
    let root_node = Arc::new(Schema::new(Query {}, Mutation {}));

    // Define network service
    let new_service = move || {
        let root_node = root_node.clone();
        let ctx = context.clone();
        service_fn(move |req| -> Box<Future<Item = _, Error = _> + Send> {
            let root_node = root_node.clone();
            let ctx = ctx.clone();
            match (req.method(), req.uri().path()) {
                // GraphiQL
                (&Method::GET, "/") => Box::new(juniper_hyper::graphiql("/graphql")),

                // GraphQL
                (&Method::GET, "/graphql") => Box::new(juniper_hyper::graphql(root_node, ctx, req)),
                (&Method::POST, "/graphql") => {
                    Box::new(juniper_hyper::graphql(root_node, ctx, req))
                }

                // Default response
                _ => {
                    let mut response = Response::new(Body::empty());
                    *response.status_mut() = StatusCode::NOT_FOUND;
                    Box::new(future::ok(response))
                }
            }
        })
    };

    // Create server with service
    let server = Server::bind(&address)
        .serve(new_service)
        .map_err(|e| error!("Server error: {}", e));

    info!("Listening on http://{}", address);

    // Run server
    hyper::rt::run(server);
}

This happened: error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:744: cannot convert `ReScope(Node(238))` to a region vid

Meta

rustc --version --verbose:

rustc 1.33.0 (2aa4c46cf 2019-02-28)
binary: rustc
commit-hash: 2aa4c46cfdd726e97360c2734835aa3515e8c858
commit-date: 2019-02-28
host: x86_64-apple-darwin
release: 1.33.0
LLVM version: 8.0

Backtrace:

error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:744: cannot convert `ReScope(Node(238))` to a region vid

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:588:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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_mir::borrow_check::nll::universal_regions::UniversalRegionIndices::to_region_vid::{{closure}}
  15: rustc_mir::borrow_check::nll::universal_regions::UniversalRegionIndices::to_region_vid
  16: rustc_mir::borrow_check::nll::type_check::constraint_conversion::ConstraintConversion::convert_all
  17: rustc_mir::borrow_check::nll::type_check::TypeChecker::prove_predicate
  18: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_stmt
  19: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  20: rustc_mir::borrow_check::nll::type_check::type_check
  21: rustc_mir::borrow_check::nll::compute_regions
  22: rustc_mir::borrow_check::do_mir_borrowck
  23: rustc::ty::context::GlobalCtxt::enter_local
  24: rustc_mir::borrow_check::mir_borrowck
  25: rustc::ty::query::__query_compute::mir_borrowck
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_borrowck<'tcx>>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  29: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_stmt
  30: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  31: rustc_mir::borrow_check::nll::type_check::type_check
  32: rustc_mir::borrow_check::nll::compute_regions
  33: rustc_mir::borrow_check::do_mir_borrowck
  34: rustc::ty::context::GlobalCtxt::enter_local
  35: rustc_mir::borrow_check::mir_borrowck
  36: rustc::ty::query::__query_compute::mir_borrowck
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_borrowck<'tcx>>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  40: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_stmt
  41: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  42: rustc_mir::borrow_check::nll::type_check::type_check
  43: rustc_mir::borrow_check::nll::compute_regions
  44: rustc_mir::borrow_check::do_mir_borrowck
  45: rustc::ty::context::GlobalCtxt::enter_local
  46: rustc_mir::borrow_check::mir_borrowck
  47: rustc::ty::query::__query_compute::mir_borrowck
  48: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_borrowck<'tcx>>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  51: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
  52: rustc::util::common::time
  53: <std::thread::local::LocalKey<T>>::with
  54: rustc::ty::context::TyCtxt::create_and_enter
  55: rustc_driver::driver::compile_input
  56: rustc_driver::run_compiler_with_pool
  57: <scoped_tls::ScopedKey<T>>::set
  58: rustc_driver::run_compiler
  59: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [mir_borrowck] processing `main::{{closure}}::{{closure}}`
#1 [mir_borrowck] processing `main::{{closure}}`
#2 [mir_borrowck] processing `main`
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 (2aa4c46cf 2019-02-28) running on x86_64-apple-darwin

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 `api`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions