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: Region parameter out of range when substituting in region... #49362

Closed
cynecx opened this issue Mar 25, 2018 · 6 comments · Fixed by #67160
Closed

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

cynecx opened this issue Mar 25, 2018 · 6 comments · Fixed by #67160
Labels
A-associated-items Area: Associated items such as associated types and consts. A-traits Area: Trait system A-typesystem Area: The type system C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Comments

@cynecx
Copy link
Contributor

cynecx commented Mar 25, 2018

#![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).

@matthewjasper matthewjasper added A-typesystem Area: The type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-traits Area: Trait system A-associated-items Area: Associated items such as associated types and consts. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 labels Mar 25, 2018
@matthewjasper
Copy link
Contributor

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

@jkordish jkordish added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels May 6, 2018
@0ndorio
Copy link

0ndorio commented May 8, 2018

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.

@estebank
Copy link
Contributor

estebank commented May 8, 2019

Triage: still happens.

@Centril Centril added F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way. labels Aug 5, 2019
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Aug 6, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@hellow554
Copy link
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() {}

@estebank
Copy link
Contributor

Closing in favor of #62521.

@hellow554
Copy link
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

Centril added a commit to Centril/rust that referenced this issue Dec 21, 2019
…atsakis

Make GATs less ICE-prone.

After this PR simple lifetime-generic associated types can now be used in a compiling program. There are two big limitations:

* rust-lang#30472 has not been addressed in any way (see src/test/ui/generic-associated-types/iterable.rs)
* Using type- and const-generic associated types errors because bound types and constants aren't handled by trait solving.
    * The errors are technically non-fatal, but they happen in a [part of the compiler](https://github.com/rust-lang/rust/blob/4abb0ad2731e9ac6fd5d64d4cf15b7c82e4b5a81/src/librustc_typeck/lib.rs#L298) that fairly aggressively stops compiling on errors.

closes rust-lang#47206
closes rust-lang#49362
closes rust-lang#62521
closes rust-lang#63300
closes rust-lang#64755
closes rust-lang#67089
@bors bors closed this as completed in b50c3b7 Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. A-traits Area: Trait system A-typesystem Area: The type system C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants