Closed
Description
Internal compiler error when compiling the code below. When I change &str to String
and "shane" to "shane".to_string() it compiles.
#[deriving(Show)]
struct Pair<T,V>(T,V);
impl Pair<&str, int> {
fn say(self: &Pair<&str, int>) {
println!("{}", self);
}
}
fn main() {
let result = &Pair("shane", 1i);
result.say();
}
Error message:
shane@tuva ~/hello_world $ RUST_BACKTRACE=1 rustc ./src/main.rs
src/main.rs:3:11: 3:15 error: missing lifetime specifier [E0106]
src/main.rs:3 impl Pair<&str, int> {
^~~~
src/main.rs:4:12: 4:37 error: internal compiler error: cannot relate bound region: ReLateBound(103, BrAnon(1)) <= ReStatic
src/main.rs:4 fn say(self: &Pair<&str, int>) {
^~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:113
stack backtrace:
1: 0x7f958b037f50 - rt::backtrace::imp::write::hb1f1803d8941cd7dEAq
2: 0x7f958b03b0e0 - failure::on_fail::h9fbd63160481d8b76Vq
3: 0x7f958f76a8c0 - unwind::begin_unwind_inner::h7014ce12ee89c8aeIxd
4: 0x7f958e0e3d40 - unwind::begin_unwind::h3159935999110321135
5: 0x7f958e0e3cc0 - diagnostic::SpanHandler::span_bug::ha33c2c4484455dbeGMF
6: 0x7f958ff7be70 - driver::session::Session::span_bug::h3cd2ce290cf89fe6wtx
7: 0x7f95903fa0b0 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_subregion::h51eb89a0d2c3a361s47
8: 0x7f95903b7e20 - middle::typeck::infer::region_inference::RegionVarBindings<'a, 'tcx>::make_eqregion::hf308420b28e474f1R37
9: 0x7f95903b7aa0 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::regions::hf373312c5711a8earX3
10: 0x7f95903b1a00 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::ha8209bdf143531b5E43
11: 0x7f95903bb350 - middle::typeck::infer::combine::Combine::substs::h2013094428453956443
12: 0x7f95903b1a00 - middle::typeck::infer::equate::Equate<'f, 'tcx>.Combine<'tcx>::tys::ha8209bdf143531b5E43
13: 0x7f959013b300 - middle::typeck::infer::InferCtxt<'a, 'tcx>::eq_types::hf8e3ea7365746f51Bqd
14: 0x7f95904156b0 - middle::typeck::infer::mk_eqty::closure.136122
15: 0x7f9590414e40 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::closure.136065
16: 0x7f959072f0c0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::closure.136086
17: 0x7f95903acad0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::try::h56945167629248360
18: 0x7f95904150f0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h14894066604232688873
19: 0x7f95902fa800 - middle::typeck::infer::mk_eqty::hfb5b58a0e241c71aFVc
20: 0x7f95902c13c0 - middle::typeck::require_same_types::h3a3aae4338560a2eT1j
21: 0x7f95904bf760 - middle::typeck::collect::check_method_self_type::h17716824198498991828
22: 0x7f959041f820 - middle::typeck::collect::convert::h19400805faaf8aa3zwf
23: 0x7f95904193d0 - middle::typeck::collect::collect_item_types::hb509bd5bd824bdd1qxe
24: 0x7f958fdc7fc0 - util::common::time::h4598558106411716556
25: 0x7f95905dcad0 - middle::typeck::check_crate::h6a2949805af7a059Edk
26: 0x7f95906470d0 - driver::driver::phase_3_run_analysis_passes::h9e1666443d557039EKw
27: 0x7f95906428e0 - driver::driver::compile_input::h27eaa5feb1d31b23qrw
28: 0x7f95906c4ca0 - driver::run_compiler::hc7f0df9c8d364f42HhA
29: 0x7f95906c4b80 - driver::run::closure.146507
30: 0x7f958fde0f10 - task::TaskBuilder<S>::try_future::closure.101318
31: 0x7f958fde0d00 - task::TaskBuilder<S>::spawn_internal::closure.101289
32: 0x7f958fab0e10 - task::spawn_opts::closure.8455
33: 0x7f958f7bf980 - rust_try_inner
34: 0x7f958f7bf970 - rust_try
35: 0x7f958f768380 - unwind::try::h562b1387da651c61qmd
36: 0x7f958f768210 - task::Task::run::h50cf282b32182c7f4Bc
37: 0x7f958fab0b80 - task::spawn_opts::closure.8395
38: 0x7f958f769960 - thread::thread_start::hbc67389ff8ce258afWc
39: 0x7f958a3e50c0 - start_thread
40: 0x7f958f431f89 - __clone
41: 0x0 - <unknown>