Skip to content

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

Closed

Description

@vhbit

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

Activity

  1. vhbit commented on Oct 22, 2014

    @vhbit
    ContributorAuthor
  2. vhbit commented on Oct 22, 2014

    @vhbit
    ContributorAuthor

    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.

  3. pythonesque commented on Oct 23, 2014

    @pythonesque
    Contributor

    Having the same issue.

  4. vhbit commented on Oct 23, 2014

    @vhbit
    ContributorAuthor

    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
    }
  5. vhbit commented on Oct 23, 2014

    @vhbit
    ContributorAuthor

    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.

  6. vhbit commented on Oct 24, 2014

    @vhbit
    ContributorAuthor

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

  7. nikomatsakis commented on Oct 30, 2014

    @nikomatsakis
    Contributor

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

  8. nikomatsakis commented on Oct 30, 2014

    @nikomatsakis
    Contributor

    The reduced test case certainly helps a lot.

  9. added
    A-lifetimesArea: Lifetimes / regions
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Nov 2, 2014
  10. IvanUkhov commented on Nov 2, 2014

    @IvanUkhov
    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

  11. vhbit commented on Nov 6, 2014

    @vhbit
    ContributorAuthor

    @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.

  12. nikomatsakis commented on Nov 6, 2014

    @nikomatsakis
    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).

  13. nikomatsakis commented on Nov 6, 2014

    @nikomatsakis
    Contributor

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

  14. vhbit commented on Nov 7, 2014

    @vhbit
    ContributorAuthor

    ohh, it finally works! 👍

  15. ghost added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Dec 12, 2014
  16. added 3 commits that reference this issue on Dec 12, 2014
    20cbbff
    c59b9b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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