Skip to content

Commit 2c6df97

Browse files
committed
Add and fix more tests
1 parent 70949ca commit 2c6df97

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/libcore/result.rs

+2-1
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
309309
/// # #[cfg(windows)] fn foo() {}
310310
/// # #[cfg(unix)] fn foo() {
311311
/// let p = Path::new("abc/def/ghi");
312-
/// assert_eq!(p.filename(), Some(b"ghi"));
312+
/// assert_eq!(p.filename(), Some(&b"ghi"[..]));
313313
/// # }
314314
/// ```
315315
fn filename<'a>(&'a self) -> Option<&'a [u8]>;
@@ -343,7 +343,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
343343
/// # #[cfg(windows)] fn foo() {}
344344
/// # #[cfg(unix)] fn foo() {
345345
/// let p = Path::new("/abc/def.txt");
346-
/// assert_eq!(p.filestem(), Some(b"def"));
346+
/// assert_eq!(p.filestem(), Some(&b"def"[..]));
347347
/// # }
348348
/// ```
349349
fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
@@ -390,7 +390,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
390390
/// # #[cfg(windows)] fn foo() {}
391391
/// # #[cfg(unix)] fn foo() {
392392
/// let p = Path::new("abc/def.txt");
393-
/// assert_eq!(p.extension(), Some(b"txt"));
393+
/// assert_eq!(p.extension(), Some(&b"txt"[..]));
394394
/// # }
395395
/// ```
396396
fn extension<'a>(&'a self) -> Option<&'a [u8]> {

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

+25
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)