Skip to content

Commit ca63850

Browse files
committed
auto merge of #8308 : blake2-ppc/rust/str-slice-bytes, r=alexcrichton
`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.
2 parents 8adcba4 + 476dfc2 commit ca63850

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ pub mod raw {
885885
/// If begin is greater than end.
886886
/// If end is greater than the length of the string.
887887
#[inline]
888-
pub unsafe fn slice_bytes(s: &str, begin: uint, end: uint) -> &str {
888+
pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str {
889889
do s.as_imm_buf |sbuf, n| {
890890
assert!((begin <= end));
891891
assert!((end <= n));

0 commit comments

Comments
 (0)