about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-06 05:26:01 -0700
committerbors <bors@rust-lang.org>2013-08-06 05:26:01 -0700
commitca6385034c1ca269b0b797fa039d485f7f413959 (patch)
treea4786719151b51b31ffb9505acbbc8aec4de7b6e
parent8adcba4300e75388b0e9e3b21c10a23b2d9d9bd0 (diff)
parent476dfc24b311a837f931e678c4bdfbb99d29f4e4 (diff)
downloadrust-ca6385034c1ca269b0b797fa039d485f7f413959.tar.gz
rust-ca6385034c1ca269b0b797fa039d485f7f413959.zip
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.
-rw-r--r--src/libstd/str.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index 95a411a3f96..b4057b85cbf 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -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));