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 #18660

Closed
thehydroimpulse opened this issue Nov 5, 2014 · 1 comment
Closed

Comments

@thehydroimpulse
Copy link
Contributor

ICE:

Users/daniel/Projects/rust/nanomsg.rs/src/lib.rs:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'a (root type='amut Socket<'a>) (space=FnSpace, index=1)
/Users/daniel/Projects/rust/nanomsg.rs/src/lib.rs:1 #![crate_type = "lib"]
                                                    ^
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>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:116

I have a struct S that takes lifetime 'a. Because the lifetime is associated with an unsafe pointer (technically, the implementation hides this). I added a ContravariantLifetime<'a> marker type.

pub struct Socket<'a> {
    value: c_int,
   marker: ContravariantLifetime<'a>
}

Now, Socket has a method called bind that creates a new Endpoint

pub struct Endpoint<'a> {
    socket: c_int,
    val: c_int,
    marker: ContravariantLifetime<'a>
}

impl<'a> Socket<'a> {
    pub fn bind<'b, 'a: 'b>(&'a mut self, addr: &str) -> Endpoint<'b> {
        // ...
    }
}

That is, I want a new lifetime 'b that is shorter than the lifetime of 'a.

Having the lifetime of 'a of &mut self results in the ICE, without it works fine.

/cc @aturon @nikomatsakis

@nikomatsakis
Copy link
Contributor

Dup of #18232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants