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

ICE: Type parameter out of range when substituting in region 'a (space=FnSpace, index=0) #18232

Closed
vhbit opened this issue Oct 22, 2014 · 13 comments · Fixed by #19780
Closed
Labels
A-lifetimes Area: Lifetimes / regions E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@vhbit
Copy link
Contributor

vhbit commented Oct 22, 2014

Unfortunately I've failed to understand what exactly causes it as reported 'a core::NativeTransaction is used just in a couple of places and looks completely innocent.

I believe it started after #18121 landed.

Here is a backtrace:

/Users/vhbit/projects/lmdb-rs/src/lib.rs:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'a (root type='acore::NativeTransaction) (space=FnSpace, index=0)
/Users/vhbit/projects/lmdb-rs/src/lib.rs:1 #![crate_name = "lmdb"]
                                           ^
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>', /Users/vhbit/projects/auto-rust/src/libsyntax/diagnostic.rs:116

stack backtrace:
   1:        0x10f254299 - rt::backtrace::imp::write::h6f68f12355c8d0e2mlq
   2:        0x10f257577 - failure::on_fail::he53cd18c9c48fe7cVBq
   3:        0x10f4ba675 - unwind::begin_unwind_inner::h532adb3b47d70b2aDud
   4:        0x10e9ab687 - unwind::begin_unwind::h13945917757193214155
   5:        0x10e9ab620 - unwind::begin_unwind::h13945917757193214155
   6:        0x10c2d2c13 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_region::hf439d6ca506a1235J8V
   7:        0x10c20ab96 - middle::subst::SubstFolder<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h6b224cbf27a1f8b0PaW
   8:        0x10c4aab18 - middle::typeck::check::method::LookupContext<'a, 'tcx>::xform_self_ty::h8b8bf7076e90ad97bdU
   9:        0x10c4a96bd - middle::typeck::check::method::LookupContext<'a, 'tcx>::push_inherent_impl_candidates_for_type::h149b1a403c6e9c8d4US
  10:        0x10c4a9103 - middle::typeck::check::method::LookupContext<'a, 'tcx>::push_inherent_candidates::closure.130669
  11:        0x10c4a8af5 - middle::typeck::check::autoderef::h1138707213401754793
  12:        0x10c49f192 - middle::typeck::check::method::lookup::h656fa83e72c76904vGR
  13:        0x10c4fdebb - middle::typeck::check::check_expr_with_unifier::ha848438f23402a7dCsY
  14:        0x10c4c72e0 - middle::typeck::check::check_block_with_expected::hdc28d4c9d3fea42a0A0
  15:        0x10c4c2b44 - middle::typeck::check::check_fn::h84feddd5d2edf884LfV
  16:        0x10c4c200b - middle::typeck::check::check_bare_fn::he86fef689e6d9102T4U
  17:        0x10c4c9a10 - middle::typeck::check::check_method_body::ha706363df14218ddEzV
  18:        0x10c4bee98 - middle::typeck::check::check_item::hf51938155885a1b8UoV
  19:        0x10c4c02e3 - visit::walk_item::h11639469492027250940
  20:        0x10c4c1e6a - middle::typeck::check::check_item_types::hbb9da7acb2b363e033U
  21:        0x10bf87d56 - util::common::time::h17357078438074708411
  22:        0x10c79062e - middle::typeck::check_crate::h0ccf9d9f552899b3xLn
  23:        0x10c7fbcff - driver::driver::phase_3_run_analysis_passes::h5c7782ef6e7c62e6fpA
  24:        0x10c7f6cae - driver::driver::compile_input::h0f5f8287137a89d705z
  25:        0x10c87b23f - driver::run_compiler::hef0d18d631a92f7abTD
  26:        0x10c8793c6 - driver::run::closure.144873
  27:        0x10bfa141b - task::TaskBuilder<S>::try_future::closure.103271
  28:        0x10bfa1303 - task::TaskBuilder<S>::spawn_internal::closure.103242
  29:        0x10bf1e8fd - task::NativeSpawner.Spawner::spawn::closure.8527
  30:        0x10f524b3c - rust_try_inner
  31:        0x10f524b26 - rust_try
  32:        0x10f4b7ce7 - unwind::try::hf6abc66f61cc4b23ljd
  33:        0x10f4b7b6c - task::Task::run::h4e050f8fa3cba51ewzc
  34:        0x10bf1e722 - task::NativeSpawner.Spawner::spawn::closure.8466
  35:        0x10f4b952a - thread::thread_start::h8fed07902f91253fHTc
  36:     0x7fff9406b899 - _pthread_body
  37:     0x7fff9406b72a - _pthread_struct_init
@vhbit
Copy link
Contributor Author

vhbit commented Oct 22, 2014

cc @nikomatsakis

@vhbit
Copy link
Contributor Author

vhbit commented Oct 22, 2014

After commenting out everything what somehow uses NativeTransaction I've got Type parameter out of range when substituting in region 'a (root type='aSelf) (space=FnSpace, index=0) and stopped here as there is too much to comment out if trying to remove all traits.

@pythonesque
Copy link
Contributor

Having the same issue.

@vhbit
Copy link
Contributor Author

vhbit commented Oct 23, 2014

Here is so far smallest piece of code which causes it:

#![allow(dead_code)]

struct Cursor<'a>;

trait CursorNavigator {
    fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool;
}

struct SimpleNavigator;

impl CursorNavigator for SimpleNavigator {
    fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool {
        false
    }
}

fn main() {
    let mut c = Cursor;
    let n = SimpleNavigator;
    n.init_cursor(&mut c); // <-------------------- fails on resolving this method call
}

@vhbit
Copy link
Contributor Author

vhbit commented Oct 23, 2014

So it seems the only thing which crashes it is a notion that 'b outlives 'a, if 'b is declared to be independent it has a problem compiling it.

Unfortunately there is no workaround it my case as if I remove this obligation I get compile errors in other parts.

@vhbit
Copy link
Contributor Author

vhbit commented Oct 24, 2014

@nikomatsakis is there anything else I can provide to help fixing it?

@nikomatsakis
Copy link
Contributor

Sorry, catching up on github notifications and only just saw this.

@nikomatsakis
Copy link
Contributor

The reduced test case certainly helps a lot.

@huonw huonw added A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 2, 2014
@IvanUkhov
Copy link
Contributor

Hello,

I get a similar error

<anon>:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'a (root type='aBar) (space=FnSpace, index=0)
<anon>:1 extern crate test;
         ^
note: the compiler unexpectedly panicked. 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' panicked at 'Box<Any>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:116

with the following code:

extern crate test;

trait Foo<'a> {
    fn foo(bar: &'a Bar) -> Self;
}

struct Bar;

struct Baz<'a> {
    bar: &'a Bar,
}

impl <'a> Foo<'a> for Baz<'a> {
    fn foo(bar: &'a Bar) -> Baz<'a> { Baz { bar: bar } }
}

impl Bar {
    fn foo<'a, T: Foo<'a>>(&'a self) -> T { Foo::foo(self) }
}

fn main() {
    let bar = Bar;
    let baz: Baz = bar.foo();
    test::black_box(baz.bar);
}

I hope it helps.

Regards,
Ivan

@vhbit
Copy link
Contributor Author

vhbit commented Nov 6, 2014

@nikomatsakis any estimations on this issue? There is a tons of useful stuff in nightly and it is a bit pity to stay on 2 week old version just because one of deps produced ICE.

@nikomatsakis
Copy link
Contributor

On Thu, Nov 06, 2014 at 01:04:45AM -0800, Valerii Hiora wrote:

@nikomatsakis any estimations on this issue? There is a tons of useful stuff in nightly and it is a bit pity to stay on 2 week old version just because one of deps produced ICE.

Hi, sorry, I've been busy pushing on new features, I plan to take some
time to investigate bugs (including this one).

@nikomatsakis
Copy link
Contributor

OK, so, I figured out the fix. I will attach a patch on this pending PR: #18694

@vhbit
Copy link
Contributor Author

vhbit commented Nov 7, 2014

ohh, it finally works! 👍

@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 12, 2014
bors added a commit that referenced this issue Dec 18, 2014
Closes #5988.
Closes #10176.
Closes #10456.
Closes #12744.
Closes #13264.
Closes #13324.
Closes #14182.
Closes #15381.
Closes #15444.
Closes #15480.
Closes #15756.
Closes #16822.
Closes #16966.
Closes #17351.
Closes #17503.
Closes #17545.
Closes #17771.
Closes #17816.
Closes #17897.
Closes #17905.
Closes #18188.
Closes #18232.
Closes #18345.
Closes #18389.
Closes #18400.
Closes #18502.
Closes #18611.
Closes #18783.
Closes #19009.
Closes #19081.
Closes #19098.
Closes #19127.
Closes #19135.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants