This code from the io library is definitely wrong as the lifetime of the parameter s is lost:
pub fn with_str_reader<T>(s: &str, f: &fn(@Reader) -> T) -> T {
str::byte_slice(s, |bytes| with_bytes_reader(bytes, f))
}
The lifetime of the s is lost. I have a fix for this in a branch I want to land (currently commented out with a FIXME) but I don't want to turn on the check because to do this right we need & objects working. I'm not even sure where to insert strategic transmutes to get with_str_reader working.
This signature for example should really be:
pub fn with_str_reader<T>(s: &str, f: &fn(&Reader) -> T) -> T {...}
or even
pub fn str_reader<'a, T>(s: &'a str) -> &'a Reader {...}
There is a test that was supposed to be defending against this case, but it was basically accidentally reporting an error.
This code from the
iolibrary is definitely wrong as the lifetime of the parametersis lost:The lifetime of the
sis lost. I have a fix for this in a branch I want to land (currently commented out with a FIXME) but I don't want to turn on the check because to do this right we need&objects working. I'm not even sure where to insert strategic transmutes to getwith_str_readerworking.This signature for example should really be:
or even
There is a test that was supposed to be defending against this case, but it was basically accidentally reporting an error.