Skip to content

ICE on Hyper/Juniper Example #59344

Closed
Closed
@andreytkachenko

Description

@andreytkachenko

I am trying to compile hyper/juniper example:

#[macro_use]
extern crate juniper;
extern crate futures;

use futures::future;
use std::sync::Arc;
use hyper::rt::{self, Future};
use hyper::service::service_fn;
use hyper::Method;
use hyper::{Body, Response, Server, StatusCode};
use juniper::{FieldResult, RootNode};

struct Context;
impl juniper::Context for Context {}

#[derive(GraphQLObject)]
struct Human {
    id: String,
    home_planet: String,
}

#[derive(GraphQLInputObject)]
#[graphql(description = "A humanoid creature in the Star Wars universe")]
struct NewHuman {
    home_planet: String,
}

pub struct QueryRoot;

graphql_object!(QueryRoot: Context |&self| {
    field human(&executor, id: String) -> FieldResult<Human> {
        Ok(Human{
            id: "1234".to_owned(),
            home_planet: "Mars".to_owned(),
        })
    }
});

pub struct MutationRoot;

graphql_object!(MutationRoot: Context |&self| {
    field createHuman(&executor, new_human: NewHuman) -> FieldResult<Human> {
        Ok(Human {
            id: "1234".to_owned(),
            home_planet: new_human.home_planet,
        })
    }
});

pub type Schema = RootNode<'static, QueryRoot, MutationRoot>;

fn main() {
    let addr = ([127, 0, 0, 1], 3000).into();
    let ctx = Arc::new(Context);
    let root_node = Arc::new(Schema::new(QueryRoot {}, MutationRoot {}));

    let new_service = move || {
        let root_node = root_node.clone();
        let ctx = ctx.clone();

        service_fn(move |req| -> Box<dyn Future<Item = _, Error = _> + Send> {
            let root_node = root_node.clone();
            let ctx = ctx.clone();

            match (req.method(), req.uri().path()) {
                (&Method::GET, "/") => Box::new(juniper_hyper::graphiql("/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)),
                _ => {
                    let mut response = Response::new(Body::empty());
                    *response.status_mut() = StatusCode::NOT_FOUND;

                    Box::new(future::ok(response))
                }
            }
        })
    };
    let server = Server::bind(&addr)
        .serve(new_service)
        .map_err(|e| eprintln!("server error: {}", e));

    rt::run(server);
}

and got next ICE:

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

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:634: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
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   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_rvalue
  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 for rustc::ty::query::queries::mir_borrowck>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  29: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_rvalue
  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 for rustc::ty::query::queries::mir_borrowck>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_rvalue
  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 for rustc::ty::query::queries::mir_borrowck>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  51: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  52: rustc::util::common::time
  53: rustc_interface::passes::analysis
  54: rustc::ty::query::__query_compute::analysis
  55: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  56: rustc::dep_graph::graph::DepGraph::with_task_impl
  57: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  58: rustc::ty::context::tls::enter_global
  59: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  60: rustc_interface::passes::create_global_ctxt::{{closure}}
  61: rustc_interface::passes::BoxedGlobalCtxt::enter
  62: rustc_interface::interface::run_compiler_in_existing_thread_pool
  63: std::thread::local::LocalKey<T>::with
  64: scoped_tls::ScopedKey<T>::set
  65: syntax::with_globals
query stack during panic:
#0 [mir_borrowck] processing `main::{{closure}}#0::{{closure}}#0`
#1 [mir_borrowck] processing `main::{{closure}}#0`
#2 [mir_borrowck] processing `main`
#3 [analysis] running analysis passes on this crate
end of query stack

Cargo.toml

# ...
[dependencies]
futures = "0.1"
hyper = "0.12"
juniper = "0.11.1"
juniper_hyper = "0.2.0"

Metadata

Metadata

Assignees

No one assigned

    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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions