std: Use correct lifetime parameter on str::raw::slice_bytes

fn slice_bytes is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of slice_bytes are region checked correctly.
This commit is contained in:
blake2-ppc
2013-08-05 17:52:03 +02:00
parent dbaca98d78
commit 476dfc24b3

View File

@@ -885,7 +885,7 @@ pub mod raw {
/// If begin is greater than end.
/// If end is greater than the length of the string.
#[inline]
pub unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> &str {
pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str {
do s.as_imm_buf |sbuf, n| {
assert!((begin <= end));
assert!((end <= n));