Skip to content

Commit b98255c

Browse files
committed
Add and fix more tests
1 parent 1e9bef9 commit b98255c

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/libcore/result.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ impl<T, E> Result<T, E> {
448448
/// ```
449449
/// use std::old_io::IoResult;
450450
///
451-
/// let mut buffer = &mut b"1\n2\n3\n4\n";
451+
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
452+
/// let mut buffer = &mut buffer;
452453
///
453454
/// let mut sum = 0;
454455
///

src/libstd/old_path/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
311311
/// # #[cfg(windows)] fn foo() {}
312312
/// # #[cfg(unix)] fn foo() {
313313
/// let p = Path::new("abc/def/ghi");
314-
/// assert_eq!(p.filename(), Some(b"ghi"));
314+
/// assert_eq!(p.filename(), Some(&b"ghi"[..]));
315315
/// # }
316316
/// ```
317317
fn filename<'a>(&'a self) -> Option<&'a [u8]>;
@@ -345,7 +345,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
345345
/// # #[cfg(windows)] fn foo() {}
346346
/// # #[cfg(unix)] fn foo() {
347347
/// let p = Path::new("/abc/def.txt");
348-
/// assert_eq!(p.filestem(), Some(b"def"));
348+
/// assert_eq!(p.filestem(), Some(&b"def"[..]));
349349
/// # }
350350
/// ```
351351
fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
@@ -392,7 +392,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
392392
/// # #[cfg(windows)] fn foo() {}
393393
/// # #[cfg(unix)] fn foo() {
394394
/// let p = Path::new("abc/def.txt");
395-
/// assert_eq!(p.extension(), Some(b"txt"));
395+
/// assert_eq!(p.extension(), Some(&b"txt"[..]));
396396
/// # }
397397
/// ```
398398
fn extension<'a>(&'a self) -> Option<&'a [u8]> {

src/test/run-pass/issue-17233.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
const X1: &'static [u8] = &[b'1'];
12+
const X2: &'static [u8] = b"1";
13+
const X3: &'static [u8; 1] = &[b'1'];
14+
const X4: &'static [u8; 1] = b"1";
15+
16+
static Y1: u8 = X1[0];
17+
static Y2: u8 = X2[0];
18+
static Y3: u8 = X3[0];
19+
static Y4: u8 = X4[0];
20+
21+
fn main() {
22+
assert_eq!(Y1, Y2);
23+
assert_eq!(Y1, Y3);
24+
assert_eq!(Y1, Y4);
25+
}

0 commit comments

Comments
 (0)