diff options
| author | bors <bors@rust-lang.org> | 2013-08-06 05:26:01 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-06 05:26:01 -0700 |
| commit | ca6385034c1ca269b0b797fa039d485f7f413959 (patch) | |
| tree | a4786719151b51b31ffb9505acbbc8aec4de7b6e | |
| parent | 8adcba4300e75388b0e9e3b21c10a23b2d9d9bd0 (diff) | |
| parent | 476dfc24b311a837f931e678c4bdfbb99d29f4e4 (diff) | |
| download | rust-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.rs | 2 |
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)); |
