Skip to content

ICE: Region parameter out of range when substituting in region... #49362

Closed

Description

@cynecx
#![feature(generic_associated_types)]

struct S;

trait Trait {
    type Associated<'a>;
}

impl Trait for S {
    type Associated<'a> = &'a ();
}

fn main() {}
error: internal compiler error: librustc/ty/subst.rs:439: Region parameter out of range when substituting in region 'a (root type=Some(TestIterItem<'a>)) (index=0)

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:488:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors

Rust playground

Probably related: #47309

I can reproduce this with rustc 1.26.0-nightly (f5631d9ac 2018-03-24).

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    A-associated-itemsArea: Associated items (types, constants & functions)
    on Mar 25, 2018
  2. matthewjasper commented on Mar 25, 2018

    @matthewjasper
    Contributor

    Generic associated types aren't implemented past syntax yet, so this is probably expected. cc #44265

  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on May 6, 2018
  4. 0ndorio commented on May 8, 2018

    @0ndorio
    Contributor

    This does not only happen with generic associated lifetimes but with any generic associated type:

    #![feature(generic_associated_types)]
    
    pub trait MyTrait {
        type InternalType<TypeA>;
    }
    
    pub struct GenericType<TypeA> {
        _dummy: TypeA,
    }
    
    pub struct MyStruct {}
    
    impl MyTrait for MyStruct {
        type InternalType<TypeA> = GenericType<TypeA>;
    }
    
    // -----------------------------------------------------------------------------
    fn main() {}
    Compiling playground v0.0.1 (file:///playground)
    error: internal compiler error: librustc/ty/subst.rs:493: Type parameter `TypeA/#0` (TypeA/0) out of range when substituting (root type=Some(GenericType<TypeA>)) substs=[]
    
    thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    error: aborting due to previous error
    
    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.27.0-nightly (565235ee7 2018-05-07) running on x86_64-unknown-linux-gnu
    note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
    note: some of the compiler flags provided by cargo are hidden
    

    Rust playground: https://play.rust-lang.org/?gist=c36f51038511f3e6568b1b2c866f2ca3&version=nightly&mode=debug

    Maybe its worth to disable the feature flag or add a compiler error warning if the flag is used, until the feature implementation progressed further.

  5. estebank commented on May 8, 2019

    @estebank
    Contributor

    Triage: still happens.

  6. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Aug 5, 2019
  7. added
    C-bugCategory: This is a bug.
    and removed
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Aug 6, 2019
  8. hellow554 commented on Nov 25, 2019

    @hellow554
    Contributor

    Slightly reduced, no need for a new struct S, just use the unit type

    #![feature(generic_associated_types)]
    
    trait Trait {
        type Associated<'a>;
    }
    
    impl Trait for () {
        type Associated<'a> = &'a ();
    }
    
    fn main() {}
    
  9. estebank commented on Nov 25, 2019

    @estebank
    Contributor

    Closing in favor of #62521.

  10. hellow554 commented on Nov 26, 2019

    @hellow554
    Contributor

    @estebank although they are two different ICE messages?

    error: internal compiler error: Region parameter out of range when substituting in region 'a (root type=Some(&'a ())) (index=0)

    vs

    error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:764: cannot convert ReEarlyBound(0, 'a) to a region vid

  11. added 2 commits that reference this issue on Dec 21, 2019
    61881b7
    b50c3b7
  12. added
    A-GATsArea: Generic associated types (GATs)
    on Nov 2, 2024
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-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)A-trait-systemArea: Trait systemA-type-systemArea: Type systemC-bugCategory: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions