Skip to content

Commit 85080fa

Browse files
author
Oliver Schneider
committed
fix tests
1 parent 6584ae5 commit 85080fa

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl<'a> MyWriter for &'a mut [u8] {
2626

2727
let write_len = buf.len();
2828
unsafe {
29-
*self = slice::from_raw_parts(
30-
self.as_ptr().offset(write_len as int),
29+
*self = slice::from_raw_parts_mut(
30+
self.as_mut_ptr().offset(write_len as isize),
3131
self.len() - write_len
3232
);
3333
}

src/test/run-pass/unsized3.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,32 @@
1515

1616
use std::mem;
1717
use std::raw;
18+
use std::slice;
1819

1920
struct Foo<T> {
2021
f: [T],
2122
}
2223

2324
struct Bar {
24-
f1: uint,
25-
f2: [uint],
25+
f1: usize,
26+
f2: [usize],
2627
}
2728

2829
struct Baz {
29-
f1: uint,
30+
f1: usize,
3031
f2: str,
3132
}
3233

3334
trait Tr {
34-
fn foo(&self) -> uint;
35+
fn foo(&self) -> usize;
3536
}
3637

3738
struct St {
38-
f: uint
39+
f: usize
3940
}
4041

4142
impl Tr for St {
42-
fn foo(&self) -> uint {
43+
fn foo(&self) -> usize {
4344
self.f
4445
}
4546
}
@@ -67,18 +68,18 @@ pub fn main() {
6768
}
6869

6970
let data: Box<Foo_<i32>> = box Foo_{f: [1, 2, 3] };
70-
let x: &Foo<i32> = slice::from_raw_parts(&*data, 3);
71+
let x: &Foo<i32> = mem::transmute(slice::from_raw_parts(&*data, 3));
7172
assert!(x.f.len() == 3);
7273
assert!(x.f[0] == 1);
7374

7475
struct Baz_ {
75-
f1: uint,
76+
f1: usize,
7677
f2: [u8; 5],
7778
}
7879

7980
let data: Box<_> = box Baz_ {
8081
f1: 42, f2: ['a' as u8, 'b' as u8, 'c' as u8, 'd' as u8, 'e' as u8] };
81-
let x: &Baz = slice::from_raw_parts(&*data, 5);
82+
let x: &Baz = mem::transmute(slice::from_raw_parts(&*data, 5));
8283
assert!(x.f1 == 42);
8384
let chs: Vec<char> = x.f2.chars().collect();
8485
assert!(chs.len() == 5);

0 commit comments

Comments
 (0)