mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 05:57:03 +03:00
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:
+1
-1
@@ -885,7 +885,7 @@ pub unsafe fn c_str_to_static_slice(s: *libc::c_char) -> &'static str {
|
||||
/// 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));
|
||||
|
||||
Reference in New Issue
Block a user