Skip to content

Commit 38eab25

Browse files
committed
---
yaml --- r: 71991 b: refs/heads/dist-snap c: 79d4f14 h: refs/heads/master i: 71989: 41a017a 71987: 6db50b0 71983: 344f68f v: v3
1 parent 8d6e575 commit 38eab25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1019
-1048
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 59e69aa0e79302887abcb4b6bf3613c84b48e5d7
10+
refs/heads/dist-snap: 79d4f1402e9abc7a8910a5d81dbb4d19c8c1b2b6
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/compiletest/errors.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,36 @@ pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
3030
}
3131

3232
fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
33-
let error_tag = ~"//~";
34-
let mut idx;
35-
match str::find_str(line, error_tag) {
36-
None => return ~[],
37-
Some(nn) => { idx = (nn as uint) + str::len(error_tag); }
38-
}
33+
unsafe {
34+
let error_tag = ~"//~";
35+
let mut idx;
36+
match str::find_str(line, error_tag) {
37+
None => return ~[],
38+
Some(nn) => { idx = (nn as uint) + str::len(error_tag); }
39+
}
3940

40-
// "//~^^^ kind msg" denotes a message expected
41-
// three lines above current line:
42-
let mut adjust_line = 0u;
43-
let len = str::len(line);
44-
while idx < len && line[idx] == ('^' as u8) {
45-
adjust_line += 1u;
46-
idx += 1u;
47-
}
41+
// "//~^^^ kind msg" denotes a message expected
42+
// three lines above current line:
43+
let mut adjust_line = 0u;
44+
let len = str::len(line);
45+
while idx < len && line[idx] == ('^' as u8) {
46+
adjust_line += 1u;
47+
idx += 1u;
48+
}
4849

49-
// Extract kind:
50-
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
51-
let start_kind = idx;
52-
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
53-
let kind = str::to_lower(str::slice(line, start_kind, idx).to_owned());
50+
// Extract kind:
51+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
52+
let start_kind = idx;
53+
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
54+
let kind = str::to_lower(str::slice(line, start_kind, idx).to_owned());
5455

55-
// Extract msg:
56-
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
57-
let msg = str::slice(line, idx, len).to_owned();
56+
// Extract msg:
57+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
58+
let msg = str::slice(line, idx, len).to_owned();
5859

59-
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
60+
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
6061

61-
return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
62-
msg: msg}];
62+
return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
63+
msg: msg}];
64+
}
6365
}

branches/dist-snap/src/compiletest/header.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,16 @@ fn parse_name_directive(line: ~str, directive: ~str) -> bool {
171171

172172
fn parse_name_value_directive(line: ~str,
173173
directive: ~str) -> Option<~str> {
174-
let keycolon = directive + ~":";
175-
match str::find_str(line, keycolon) {
176-
Some(colon) => {
177-
let value = str::slice(line, colon + str::len(keycolon),
178-
str::len(line)).to_owned();
179-
debug!("%s: %s", directive, value);
180-
Some(value)
174+
unsafe {
175+
let keycolon = directive + ~":";
176+
match str::find_str(line, keycolon) {
177+
Some(colon) => {
178+
let value = str::slice(line, colon + str::len(keycolon),
179+
str::len(line)).to_owned();
180+
debug!("%s: %s", directive, value);
181+
Some(value)
182+
}
183+
None => None
181184
}
182-
None => None
183185
}
184186
}

branches/dist-snap/src/libcore/comm.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,16 @@ impl<T: Owned> Peekable<T> for Port<T> {
188188
189189
#[inline(always)]
190190
fn port_peek<T:Owned>(self: &Port<T>) -> bool {
191-
let mut endp = None;
192-
endp <-> self.endp;
193-
let peek = match &endp {
194-
&Some(ref endp) => peek(endp),
195-
&None => fail!(~"peeking empty stream")
196-
};
197-
self.endp <-> endp;
198-
peek
191+
unsafe {
192+
let mut endp = None;
193+
endp <-> self.endp;
194+
let peek = match &endp {
195+
&Some(ref endp) => peek(endp),
196+
&None => fail!(~"peeking empty stream")
197+
};
198+
self.endp <-> endp;
199+
peek
200+
}
199201
}
200202
201203
impl<T: Owned> Selectable for Port<T> {

branches/dist-snap/src/libcore/io.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,11 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
15361536
pub fn with_str_writer(f: &fn(@Writer)) -> ~str {
15371537
let mut v = with_bytes_writer(f);
15381538
1539-
// Make sure the vector has a trailing null and is proper utf8.
1540-
v.push(0);
1539+
// FIXME (#3758): This should not be needed.
1540+
unsafe {
1541+
// Make sure the vector has a trailing null and is proper utf8.
1542+
v.push(0);
1543+
}
15411544
assert!(str::is_utf8(v));
15421545
15431546
unsafe { ::cast::transmute(v) }
@@ -1637,14 +1640,16 @@ pub mod fsync {
16371640
// outer res
16381641
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
16391642
blk: &fn(v: Res<*libc::FILE>)) {
1640-
blk(Res(Arg {
1641-
val: file.f, opt_level: opt_level,
1642-
fsync_fn: |file, l| {
1643-
unsafe {
1644-
os::fsync_fd(libc::fileno(file), l) as int
1643+
unsafe {
1644+
blk(Res(Arg {
1645+
val: file.f, opt_level: opt_level,
1646+
fsync_fn: |file, l| {
1647+
unsafe {
1648+
os::fsync_fd(libc::fileno(file), l) as int
1649+
}
16451650
}
1646-
}
1647-
}));
1651+
}));
1652+
}
16481653
}
16491654

16501655
// fsync fd after executing blk

branches/dist-snap/src/libcore/managed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pub mod raw {
3838
#[inline(always)]
3939
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
4040
//! Determine if two shared boxes point to the same object
41-
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
41+
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
4242
}
4343

4444
#[inline(always)]
4545
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
4646
//! Determine if two mutable shared boxes point to the same object
47-
ptr::addr_of(&(*a)) == ptr::addr_of(&(*b))
47+
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
4848
}
4949

5050
#[cfg(notest)]

branches/dist-snap/src/libcore/num/float.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,27 +369,27 @@ pub fn is_NaN(x: float) -> bool { f64::is_NaN(x as f64) }
369369
370370
#[inline(always)]
371371
pub fn abs(x: float) -> float {
372-
f64::abs(x as f64) as float
372+
unsafe { f64::abs(x as f64) as float }
373373
}
374374
#[inline(always)]
375375
pub fn sqrt(x: float) -> float {
376-
f64::sqrt(x as f64) as float
376+
unsafe { f64::sqrt(x as f64) as float }
377377
}
378378
#[inline(always)]
379379
pub fn atan(x: float) -> float {
380-
f64::atan(x as f64) as float
380+
unsafe { f64::atan(x as f64) as float }
381381
}
382382
#[inline(always)]
383383
pub fn sin(x: float) -> float {
384-
f64::sin(x as f64) as float
384+
unsafe { f64::sin(x as f64) as float }
385385
}
386386
#[inline(always)]
387387
pub fn cos(x: float) -> float {
388-
f64::cos(x as f64) as float
388+
unsafe { f64::cos(x as f64) as float }
389389
}
390390
#[inline(always)]
391391
pub fn tan(x: float) -> float {
392-
f64::tan(x as f64) as float
392+
unsafe { f64::tan(x as f64) as float }
393393
}
394394
395395
#[cfg(notest)]

branches/dist-snap/src/libcore/path.rs

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,13 @@ impl GenericPath for PosixPath {
389389
}
390390

391391
fn dirname(&self) -> ~str {
392-
let s = self.dir_path().to_str();
393-
if s.len() == 0 {
394-
~"."
395-
} else {
396-
s
392+
unsafe {
393+
let s = self.dir_path().to_str();
394+
if s.len() == 0 {
395+
~"."
396+
} else {
397+
s
398+
}
397399
}
398400
}
399401

@@ -437,8 +439,10 @@ impl GenericPath for PosixPath {
437439
}
438440

439441
fn with_filename(&self, f: &str) -> PosixPath {
440-
assert!(! str::any(f, |c| windows::is_sep(c as u8)));
441-
self.dir_path().push(f)
442+
unsafe {
443+
assert!(! str::any(f, |c| windows::is_sep(c as u8)));
444+
self.dir_path().push(f)
445+
}
442446
}
443447

444448
fn with_filestem(&self, s: &str) -> PosixPath {
@@ -505,7 +509,7 @@ impl GenericPath for PosixPath {
505509
for str::each_split_nonempty(*e, |c| windows::is_sep(c as u8)) |s| {
506510
ss.push(s.to_owned())
507511
}
508-
v.push_all_move(ss);
512+
unsafe { v.push_all_move(ss); }
509513
}
510514
PosixPath { is_absolute: self.is_absolute,
511515
components: v }
@@ -517,14 +521,14 @@ impl GenericPath for PosixPath {
517521
for str::each_split_nonempty(s, |c| windows::is_sep(c as u8)) |s| {
518522
ss.push(s.to_owned())
519523
}
520-
v.push_all_move(ss);
524+
unsafe { v.push_all_move(ss); }
521525
PosixPath { components: v, ..copy *self }
522526
}
523527

524528
fn pop(&self) -> PosixPath {
525529
let mut cs = copy self.components;
526530
if cs.len() != 0 {
527-
cs.pop();
531+
unsafe { cs.pop(); }
528532
}
529533
return PosixPath {
530534
is_absolute: self.is_absolute,
@@ -603,11 +607,13 @@ impl GenericPath for WindowsPath {
603607
}
604608

605609
fn dirname(&self) -> ~str {
606-
let s = self.dir_path().to_str();
607-
if s.len() == 0 {
608-
~"."
609-
} else {
610-
s
610+
unsafe {
611+
let s = self.dir_path().to_str();
612+
if s.len() == 0 {
613+
~"."
614+
} else {
615+
s
616+
}
611617
}
612618
}
613619

@@ -764,7 +770,7 @@ impl GenericPath for WindowsPath {
764770
for str::each_split_nonempty(*e, |c| windows::is_sep(c as u8)) |s| {
765771
ss.push(s.to_owned())
766772
}
767-
v.push_all_move(ss);
773+
unsafe { v.push_all_move(ss); }
768774
}
769775
// tedious, but as-is, we can't use ..self
770776
return WindowsPath {
@@ -781,14 +787,14 @@ impl GenericPath for WindowsPath {
781787
for str::each_split_nonempty(s, |c| windows::is_sep(c as u8)) |s| {
782788
ss.push(s.to_owned())
783789
}
784-
v.push_all_move(ss);
790+
unsafe { v.push_all_move(ss); }
785791
return WindowsPath { components: v, ..copy *self }
786792
}
787793

788794
fn pop(&self) -> WindowsPath {
789795
let mut cs = copy self.components;
790796
if cs.len() != 0 {
791-
cs.pop();
797+
unsafe { cs.pop(); }
792798
}
793799
return WindowsPath {
794800
host: copy self.host,
@@ -814,14 +820,18 @@ impl GenericPath for WindowsPath {
814820

815821
pub fn normalize(components: &[~str]) -> ~[~str] {
816822
let mut cs = ~[];
817-
for components.each |c| {
818-
if *c == ~"." && components.len() > 1 { loop; }
819-
if *c == ~"" { loop; }
820-
if *c == ~".." && cs.len() != 0 {
821-
cs.pop();
822-
loop;
823+
unsafe {
824+
for components.each |c| {
825+
unsafe {
826+
if *c == ~"." && components.len() > 1 { loop; }
827+
if *c == ~"" { loop; }
828+
if *c == ~".." && cs.len() != 0 {
829+
cs.pop();
830+
loop;
831+
}
832+
cs.push(copy *c);
833+
}
823834
}
824-
cs.push(copy *c);
825835
}
826836
cs
827837
}

branches/dist-snap/src/libcore/ptr.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ pub fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
5555
/// Calculate the offset from a pointer
5656
#[inline(always)]
5757
pub fn offset<T>(ptr: *T, count: uint) -> *T {
58-
(ptr as uint + count * sys::size_of::<T>()) as *T
58+
unsafe {
59+
(ptr as uint + count * sys::size_of::<T>()) as *T
60+
}
5961
}
6062

6163
/// Calculate the offset from a const pointer
6264
#[inline(always)]
6365
pub fn const_offset<T>(ptr: *const T, count: uint) -> *const T {
64-
(ptr as uint + count * sys::size_of::<T>()) as *T
66+
unsafe {
67+
(ptr as uint + count * sys::size_of::<T>()) as *T
68+
}
6569
}
6670

6771
/// Calculate the offset from a mut pointer

branches/dist-snap/src/libcore/rt/context.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ fn align_down(sp: *mut uint) -> *mut uint {
205205
#[inline(always)]
206206
pub fn mut_offset<T>(ptr: *mut T, count: int) -> *mut T {
207207
use core::sys::size_of;
208-
(ptr as int + count * (size_of::<T>() as int)) as *mut T
208+
unsafe {
209+
(ptr as int + count * (size_of::<T>() as int)) as *mut T
210+
}
209211
}
210212

branches/dist-snap/src/libcore/rt/thread_local_storage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ pub type Key = pthread_key_t;
2121

2222
#[cfg(unix)]
2323
pub unsafe fn create(key: &mut Key) {
24-
assert!(0 == pthread_key_create(key, null()));
24+
unsafe { assert!(0 == pthread_key_create(key, null())); }
2525
}
2626

2727
#[cfg(unix)]
2828
pub unsafe fn set(key: Key, value: *mut c_void) {
29-
assert!(0 == pthread_setspecific(key, value));
29+
unsafe { assert!(0 == pthread_setspecific(key, value)); }
3030
}
3131

3232
#[cfg(unix)]
3333
pub unsafe fn get(key: Key) -> *mut c_void {
34-
pthread_getspecific(key)
34+
unsafe { pthread_getspecific(key) }
3535
}
3636

3737
#[cfg(target_os="macos")]

0 commit comments

Comments
 (0)