Skip to content

ICE, &mut nickel::Request was subtype but now is not #36701

Closed
@snargleplax

Description

@snargleplax

I'm getting an internal compiler error with this code.

My repro involves a couple of other packages; here's the Cargo.toml:

[package]
name = "compiler-bug-repro"
version = "0.0.1"
authors = [ "Luke Meyers <[email protected]>" ]

[dependencies]
nickel = "*"
plugin="*"
typemap = "*"

And here's main.rs:

extern crate nickel;
extern crate plugin;
extern crate typemap;

use nickel::Request;
use plugin::{Plugin, Pluggable};

struct FooPlugin;

impl typemap::Key for FooPlugin {
    type Value = u32;
}

impl<'a, 'b> Plugin<Request<'a, 'b>> for FooPlugin {
    type Error = ();
    fn eval(request: &mut Request) -> Result<u32, ()> { Result::Err(()) }
}

fn foo<'a, 'b, D>(bar: &Request<'a, 'b, D>) {
    bar.get::<FooPlugin>()
}

fn main() {}

I don't claim the code should compile cleanly (I encountered the bug originally when fiddling around with generic params I didn't fully understand), but I get a compiler panic. Here's the output from cargo run --verbose:

cargo run --verbose
       Fresh rustc-serialize v0.3.19
       Fresh language-tags v0.2.2
       Fresh libc v0.2.16
       Fresh matches v0.1.2
       Fresh winapi-build v0.1.1
       Fresh unicode-normalization v0.1.2
       Fresh groupable v0.2.0
       Fresh log v0.3.6
       Fresh traitobject v0.0.3
       Fresh winapi v0.2.8
       Fresh unicode-bidi v0.2.3
       Fresh num_cpus v0.2.13
       Fresh memchr v0.1.11
       Fresh semver v0.1.20
       Fresh mime v0.2.2
       Fresh unsafe-any v0.4.1
       Fresh utf8-ranges v0.1.3
       Fresh idna v0.1.0
       Fresh lazy_static v0.1.16
       Fresh aho-corasick v0.5.3
       Fresh regex-syntax v0.3.5
       Fresh typeable v0.1.2
       Fresh mustache v0.6.3
       Fresh typemap v0.3.3
       Fresh modifier v0.1.0
       Fresh url v1.2.0
       Fresh traitobject v0.0.1
       Fresh hpack v0.2.0
       Fresh httparse v1.1.2
       Fresh rustc_version v0.1.7
       Fresh plugin v0.2.6
       Fresh solicit v0.4.4
       Fresh kernel32-sys v0.2.2
       Fresh thread-id v2.0.0
       Fresh time v0.1.35
       Fresh unicase v1.4.0
       Fresh thread_local v0.2.6
       Fresh cookie v0.2.5
       Fresh regex v0.1.77
       Fresh hyper v0.9.10
       Fresh nickel v0.9.0
   Compiling compiler-bug-repro v0.0.1 (file:///Users/luke/rust/workshop)
     Running `rustc src/main.rs --crate-name compiler_bug_repro --crate-type bin -g -C metadata=041422aad2109b65 --out-dir /Users/luke/rust/workshop/target/debug --emit=dep-info,link -L dependency=/Users/luke/rust/workshop/target/debug/deps --extern nickel=/Users/luke/rust/workshop/target/debug/deps/libnickel-c8a48e533ebfcad5.rlib --extern plugin=/Users/luke/rust/workshop/target/debug/deps/libplugin-a6cf157fb041a4c2.rlib --extern typemap=/Users/luke/rust/workshop/target/debug/deps/libtypemap-deddc09802823f24.rlib`
error: internal compiler error: ../src/librustc_typeck/check/method/confirm.rs:361: &mut nickel::Request<'a, 'b, D> was a subtype of &mut nickel::Request<'_, '_, _> but now is not?
  --> src/main.rs:20:9
   |
20 |     bar.get::<FooPlugin>()
   |         ^^^

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

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

error: Could not compile `compiler-bug-repro`.

Caused by:
  Process didn't exit successfully: `rustc src/main.rs --crate-name compiler_bug_repro --crate-type bin -g -C metadata=041422aad2109b65 --out-dir /Users/luke/rust/workshop/target/debug --emit=dep-info,link -L dependency=/Users/luke/rust/workshop/target/debug/deps --extern nickel=/Users/luke/rust/workshop/target/debug/deps/libnickel-c8a48e533ebfcad5.rlib --extern plugin=/Users/luke/rust/workshop/target/debug/deps/libplugin-a6cf157fb041a4c2.rlib --extern typemap=/Users/luke/rust/workshop/target/debug/deps/libtypemap-deddc09802823f24.rlib` (exit code: 101)

Meta

rustc version --verbose:

rustc 1.13.0-nightly (6ffdda1ba 2016-09-14)
binary: rustc
commit-hash: 6ffdda1ba183c981d57e63b59c88184be449eee4
commit-date: 2016-09-14
host: x86_64-apple-darwin
release: 1.13.0-nightly

Backtrace:

   1:        0x11231723a - std::sys::backtrace::tracing::imp::write::h4b09e6e8c01db097
   2:        0x11232594f - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
   3:        0x112323fed - std::panicking::default_hook::h96c288d728df3ebf
   4:        0x112324686 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   5:        0x10e91fffb - std::panicking::begin_panic::hb7c71bbc491f561c
   6:        0x10ea515d3 - rustc::session::opt_span_bug_fmt::{{closure}}::h6ad7caa20ac20c4b
   7:        0x10e966279 - rustc::session::span_bug_fmt::heb3fdb6acac8d0c7
   8:        0x10e9a9e6c - rustc_typeck::check::method::confirm::ConfirmContext::confirm::h6184703963035442
   9:        0x10e9b7b03 - rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::lookup_method::hf46acac3437c7790
  10:        0x10ea0951c - rustc_typeck::check::FnCtxt::check_expr_kind::h3deead7da823b578
  11:        0x10ea06588 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::he143ecfe673f135a
  12:        0x10ea15416 - rustc_typeck::check::FnCtxt::check_block_with_expected::h3cbcd7af6c6dd8d8
  13:        0x10e9e5a9b - rustc_typeck::check::check_fn::h248c6bcb73d27057
  14:        0x10e9e4304 - rustc_typeck::check::check_bare_fn::haa7199476c92e826
  15:        0x10e9e75f5 - rustc_typeck::check::check_item_body::h4df24fa6569eb6cd
  16:        0x10e9e1d17 - rustc_typeck::check::check_item_bodies::h575d7e72333c5821
  17:        0x10ea4e117 - rustc_typeck::check_crate::h56444fcd0efce52e
  18:        0x10dec0d44 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::hcac3a2328cd9259a
  19:        0x10de92257 - rustc_driver::driver::phase_3_run_analysis_passes::h9865057b323cad0e
  20:        0x10de849df - rustc_driver::driver::compile_input::hc0edbed7edb3eb18
  21:        0x10deae0c8 - rustc_driver::run_compiler::h22d678d32fb7c300
  22:        0x10ddf1dd0 - std::panicking::try::do_call::h4d040997e2efdaf3
  23:        0x112325f4a - __rust_maybe_catch_panic
  24:        0x10de0fff4 - <F as alloc::boxed::FnBox<A>>::call_box::hba0b436c79e56b23
  25:        0x112322e64 - std::sys::thread::Thread::new::thread_start::h022e3887023c6290
  26:     0x7fff9ab9299c - _pthread_body
  27:     0x7fff9ab92919 - _pthread_start

Possibly-related closed issues: #17033, #13847, #13202, #20791

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions