mozilla/rust — pull request #9557 by blake2-ppc (2013-09-27 03:54:51+00:00)
Title: std::vec: Use a valid pointer as lifetime dummy in iterator

Use a valid pointer for the dummy `lifetime` field in VecIterator and
VecMutIterator.

The current implementation uses &v[0], which is a dangling pointer for
iterators derived from zero-length slices.

Example:

let v: [int, ..0] = []; println!("{:?}", v.iter())

std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128}

To replace this parameter, use the field:

lifetime: &'self ()

Which is initialized as a pointer to a () held in a static variable.
From the static variable we can derive a &'a () of the correct lifetime
automatically.