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

Complier Crash: internal compiler error: cannot relate bound region #44718

Closed
sbwtw opened this issue Sep 20, 2017 · 4 comments
Closed

Complier Crash: internal compiler error: cannot relate bound region #44718

sbwtw opened this issue Sep 20, 2017 · 4 comments
Labels
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.

Comments

@sbwtw
Copy link
Contributor

sbwtw commented Sep 20, 2017

I'm using Rocket to build my website, and got a complier error, here is a minimum demo to reproduce:

Cargo.toml:

[package]
name = "demo"
version = "0.1.0"
authors = ["石博文 <sbw@sbw.so>"]

[dependencies]
rocket = "*"
rocket_codegen = "*"
mysql = "*"

[dependencies.rocket_contrib]
version = "*"
default-features = false

main.rs:


#![feature(conservative_impl_trait)]
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen)]

extern crate rocket;
extern crate rocket_contrib;

use rocket::response::*;
use rocket::http::*;

#[get("/<hash>")]
fn index_with_hash(hash: &RawStr) -> impl Responder {

    if hash.len() != 0 {
        let url = vec![];

        return Some(Redirect::to(std::str::from_utf8(&url).unwrap()));
    }

    return None;
}

fn main() {
    rocket::ignite()
        .mount("/", routes![index_with_hash])
        .launch();
}

here is output after execute cargo build --verbose

       Fresh yansi v0.3.4
       Fresh language-tags v0.2.2
       Fresh lazy_static v0.2.8
       Fresh ordermap v0.2.12
       Fresh dtoa v0.4.2
       Fresh version_check v0.1.3
       Fresh libc v0.2.31
       Fresh httparse v1.2.3
       Fresh cfg-if v0.1.2
       Fresh log v0.3.8
       Fresh scopeguard v0.3.2
       Fresh regex-syntax v0.4.1
       Fresh bufstream v0.1.3
       Fresh utf8-ranges v1.0.0
       Fresh bit-vec v0.4.4
       Fresh num-traits v0.1.40
       Fresh safemem v0.2.0
       Fresh void v1.0.2
       Fresh futures v0.1.16
       Fresh untrusted v0.5.1
       Fresh gcc v0.3.54
       Fresh traitobject v0.1.0
       Fresh fnv v1.0.5
       Fresh smallvec v0.4.3
       Fresh pear_codegen v0.0.10
       Fresh unicode-normalization v0.1.5
       Fresh pear v0.0.10
       Fresh byteorder v1.1.0
       Fresh matches v0.1.6
       Fresh state v0.3.2
       Fresh uuid v0.5.1
       Fresh serde v1.0.15
       Fresh bitflags v0.9.1
       Fresh percent-encoding v1.0.0
       Fresh typeable v0.1.2
       Fresh either v1.1.0
       Fresh itoa v0.3.4
       Fresh isatty v0.1.3
       Fresh time v0.1.38
       Fresh num_cpus v1.6.2
       Fresh memchr v1.0.1
       Fresh rand v0.3.16
       Fresh net2 v0.2.31
       Fresh mime v0.2.6
       Fresh atoi v0.2.2
       Fresh num-integer v0.1.35
       Fresh unreachable v1.0.0
       Fresh base64 v0.6.0
       Fresh unicode-bidi v0.3.4
       Fresh toml v0.4.5
       Fresh nix v0.9.0
       Fresh coco v0.1.1
       Fresh serde_json v1.0.3
       Fresh aho-corasick v0.6.3
       Fresh twox-hash v1.1.0
       Fresh num-iter v0.1.34
       Fresh thread_local v0.3.4
       Fresh idna v0.1.4
       Fresh rayon-core v1.2.1
       Fresh unicase v1.4.2
       Fresh num v0.1.40
       Fresh regex v0.2.2
       Fresh url v1.5.1
       Fresh rayon v0.7.1
       Fresh chrono v0.4.0
       Fresh hyper v0.10.13
       Fresh mysql_common v0.2.0
       Fresh mysql v12.0.3
       Fresh ring v0.11.0
       Fresh cookie v0.9.1
       Fresh rocket v0.3.2
       Fresh rocket_contrib v0.3.2
       Fresh rocket_codegen v0.3.2
   Compiling demo v0.1.0 (file:///home/Projects/demo)
     Running `rustc --crate-name demo src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=921caa19a954fe24 -C extra-filename=-921caa19a954fe24 --out-dir /home/.cache/rust-build/debug/deps -L dependency=/home/.cache/rust-build/debug/deps --extern rocket_contrib=/home/.cache/rust-build/debug/deps/librocket_contrib-deae706dc6aff940.rlib --extern mysql=/home/.cache/rust-build/debug/deps/libmysql-eb615418c3bc2492.rlib --extern rocket_codegen=/home/.cache/rust-build/debug/deps/librocket_codegen-d88168fd88807be8.so --extern rocket=/home/.cache/rust-build/debug/deps/librocket-09121367ccb45b19.rlib -L native=/home/.cache/rust-build/debug/build/ring-a774c3003c43ee5b/out`
error: internal compiler error: /checkout/src/librustc/infer/region_inference/mod.rs:706: cannot relate bound region: ReLateBound(DebruijnIndex { depth: 2 }, BrAnon(0)) <= '_#114r
  --> src/main.rs:12:1
   |
12 | #[get("/<hash>")]
   | ^^^^^^^^^^^^^^^^^

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.22.0-nightly (325ba23d5 2017-09-19) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:439:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `demo`.

Caused by:
  process didn't exit successfully: `rustc --crate-name demo src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=921caa19a954fe24 -C extra-filename=-921caa19a954fe24 --out-dir /home/.cache/rust-build/debug/deps -L dependency=/home/.cache/rust-build/debug/deps --extern rocket_contrib=/home/.cache/rust-build/debug/deps/librocket_contrib-deae706dc6aff940.rlib --extern mysql=/home/.cache/rust-build/debug/deps/libmysql-eb615418c3bc2492.rlib --extern rocket_codegen=/home/.cache/rust-build/debug/deps/librocket_codegen-d88168fd88807be8.so --extern rocket=/home/.cache/rust-build/debug/deps/librocket-09121367ccb45b19.rlib -L native=/home/.cache/rust-build/debug/build/ring-a774c3003c43ee5b/out` (exit code: 101)

cc @SergioBenitez

@Mark-Simulacrum Mark-Simulacrum 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 Sep 20, 2017
@hashedone
Copy link

hashedone commented Sep 21, 2017

Exactly same error here. My code can be found here: hashedone/rpgtool@022e181. I found, that the problem is with "impl Trait", everything compiles when I change main.rs:17:

fn index(ctx: State<ViewContext>) -> impl Responder {

to:

fn index(ctx: State<ViewContext>) -> maud::Markup {

rustc version:

➜  rpgtool git:(master) ✗ rustc --version --verbose
rustc 1.22.0-nightly (5dfc84cfa 2017-09-14)
binary: rustc
commit-hash: 5dfc84cfa72b405c194228b53c4de3f6474204ec
commit-date: 2017-09-14
host: x86_64-unknown-linux-gnu
release: 1.22.0-nightly
LLVM version: 4.0

Full backtrace:

   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::span_bug
   7: rustc::session::opt_span_bug_fmt::{{closure}}
   8: rustc::session::opt_span_bug_fmt
   9: rustc::session::span_bug_fmt
  10: rustc::infer::region_inference::RegionVarBindings::make_subregion
  11: rustc::infer::region_inference::RegionVarBindings::make_eqregion
  12: rustc::ty::relate::relate_substs::{{closure}}
  13: <core::result::Result<T, E> as rustc::ty::context::InternIteratorElement<T, R>>::intern_with
  14: rustc::infer::at::At::sub_exp
  15: rustc::traits::select::SelectionContext::match_projection
  16: rustc::traits::select::SelectionContext::match_projection_obligation_against_definition_bounds
  17: rustc::traits::select::SelectionContext::assemble_candidates
  18: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  19: rustc::dep_graph::graph::DepGraph::with_anon_task
  20: rustc::traits::select::SelectionContext::candidate_from_obligation
  21: rustc::traits::select::SelectionContext::select
  22: <rustc::traits::fulfill::FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
  23: rustc::traits::fulfill::FulfillmentContext::select
  24: rustc::traits::fulfill::FulfillmentContext::select_where_possible
  25: rustc_typeck::check::FnCtxt::select_obligations_where_possible
  26: rustc_typeck::check::FnCtxt::check_argument_types
  27: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call
  28: rustc_typeck::check::FnCtxt::check_expr_kind
  29: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  30: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  31: rustc_typeck::check::FnCtxt::check_block_with_expected
  32: rustc_typeck::check::FnCtxt::check_expr_kind
  33: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  34: rustc_typeck::check::FnCtxt::check_return_expr
  35: rustc_typeck::check::check_fn
  36: rustc_typeck::check::typeck_tables_of::{{closure}}
  37: rustc_typeck::check::typeck_tables_of
  38: rustc::dep_graph::graph::DepGraph::with_task
  39: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  40: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  41: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  42: rustc_typeck::check::typeck_item_bodies
  43: rustc::dep_graph::graph::DepGraph::with_task
  44: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  45: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  46: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  47: rustc_typeck::check_crate
  48: rustc::ty::context::TyCtxt::create_and_enter
  49: rustc_driver::driver::compile_input
  50: rustc_driver::run_compiler

@SergioBenitez
Copy link
Contributor

This is almost certainly a dup of #43380, which itself is almost certainly a dup of #39872. The gist: Responder takes a lifetime parameter, but you're not supplying one. Supplying one should resolve the panic:

#[get("/")]
fn handler<'r>() -> impl Responder<'r> { ... }

@cramertj
Copy link
Member

cramertj commented Jan 5, 2018

@sbwtw I believe this should be fixed now. Can you try on the latest nightly and confirm?

@pietroalbini
Copy link
Member

Tested locally, this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

6 participants