diff options
| -rw-r--r-- | src/libcore/result.rs | 3 | ||||
| -rw-r--r-- | src/libstd/old_path/mod.rs | 6 | ||||
| -rw-r--r-- | src/test/run-pass/issue-17233.rs | 25 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs index fee8caa04c4..7732ff5f9b9 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -448,7 +448,8 @@ impl<T, E> Result<T, E> { /// ``` /// use std::old_io::IoResult; /// - /// let mut buffer = &mut b"1\n2\n3\n4\n"; + /// let mut buffer: &[u8] = b"1\n2\n3\n4\n"; + /// let mut buffer = &mut buffer; /// /// let mut sum = 0; /// diff --git a/src/libstd/old_path/mod.rs b/src/libstd/old_path/mod.rs index cb7ee36183d..83d17e4fc47 100644 --- a/src/libstd/old_path/mod.rs +++ b/src/libstd/old_path/mod.rs @@ -311,7 +311,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// # #[cfg(windows)] fn foo() {} /// # #[cfg(unix)] fn foo() { /// let p = Path::new("abc/def/ghi"); - /// assert_eq!(p.filename(), Some(b"ghi")); + /// assert_eq!(p.filename(), Some(&b"ghi"[..])); /// # } /// ``` fn filename<'a>(&'a self) -> Option<&'a [u8]>; @@ -345,7 +345,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// # #[cfg(windows)] fn foo() {} /// # #[cfg(unix)] fn foo() { /// let p = Path::new("/abc/def.txt"); - /// assert_eq!(p.filestem(), Some(b"def")); + /// assert_eq!(p.filestem(), Some(&b"def"[..])); /// # } /// ``` fn filestem<'a>(&'a self) -> Option<&'a [u8]> { @@ -392,7 +392,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe { /// # #[cfg(windows)] fn foo() {} /// # #[cfg(unix)] fn foo() { /// let p = Path::new("abc/def.txt"); - /// assert_eq!(p.extension(), Some(b"txt")); + /// assert_eq!(p.extension(), Some(&b"txt"[..])); /// # } /// ``` fn extension<'a>(&'a self) -> Option<&'a [u8]> { diff --git a/src/test/run-pass/issue-17233.rs b/src/test/run-pass/issue-17233.rs new file mode 100644 index 00000000000..9623613b555 --- /dev/null +++ b/src/test/run-pass/issue-17233.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const X1: &'static [u8] = &[b'1']; +const X2: &'static [u8] = b"1"; +const X3: &'static [u8; 1] = &[b'1']; +const X4: &'static [u8; 1] = b"1"; + +static Y1: u8 = X1[0]; +static Y2: u8 = X2[0]; +static Y3: u8 = X3[0]; +static Y4: u8 = X4[0]; + +fn main() { + assert_eq!(Y1, Y2); + assert_eq!(Y1, Y3); + assert_eq!(Y1, Y4); +} |
