Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels