Skip to content

Commit 71d09c8

Browse files
committed
---
yaml --- r: 80926 b: refs/heads/snap-stage3 c: 3c00131 h: refs/heads/master v: v3
1 parent 9d9f85d commit 71d09c8

22 files changed

+104
-106
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e2807a4565575c6a08a2a65c76ee37bf3f48c841
4+
refs/heads/snap-stage3: 3c0013134cecbe9592f02ed5c6a94c06effb19d4
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7171
rt/sync/lock_and_signal.cpp \
7272
rt/sync/rust_thread.cpp \
7373
rt/rust_builtin.cpp \
74-
rt/rust_run_program.cpp \
7574
rt/rust_rng.cpp \
7675
rt/rust_upcall.cpp \
7776
rt/rust_uv.cpp \

branches/snap-stage3/src/libextra/glob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* `glob`/`fnmatch` functions.
2424
*/
2525

26-
use std::{os, path};
26+
use std::{os, path, util};
2727

2828
use sort;
2929

@@ -356,7 +356,7 @@ impl Pattern {
356356
chars_eq(c, c2, options.case_sensitive)
357357
}
358358
AnySequence => {
359-
unreachable!()
359+
util::unreachable()
360360
}
361361
};
362362
if !matches {

branches/snap-stage3/src/libextra/terminfo/parm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
261261
flags.width = (cur as uint - '0' as uint);
262262
fstate = FormatStateWidth;
263263
}
264-
_ => unreachable!()
264+
_ => util::unreachable()
265265
}
266266
state = FormatPattern(flags, fstate);
267267
}
@@ -487,7 +487,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
487487
FormatDigit => 10,
488488
FormatOctal => 8,
489489
FormatHex|FormatHEX => 16,
490-
FormatString => unreachable!()
490+
FormatString => util::unreachable()
491491
};
492492
let mut s = ~[];
493493
match op {
@@ -535,7 +535,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
535535
s.push_all_move(s_);
536536
}
537537
}
538-
FormatString => unreachable!()
538+
FormatString => util::unreachable()
539539
}
540540
s
541541
}

branches/snap-stage3/src/librustc/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use metadata::cstore;
1414
use metadata::filesearch;
1515

1616
use std::hashmap::HashSet;
17-
use std::{os, vec};
17+
use std::{os, util, vec};
1818

1919
fn not_win32(os: session::Os) -> bool {
2020
os != session::OsWin32
@@ -116,7 +116,7 @@ pub fn get_rpath_relative_to_output(os: session::Os,
116116
session::OsAndroid | session::OsLinux | session::OsFreebsd
117117
=> "$ORIGIN",
118118
session::OsMacos => "@executable_path",
119-
session::OsWin32 => unreachable!()
119+
session::OsWin32 => util::unreachable()
120120
};
121121

122122
Path(prefix).push_rel(&os::make_absolute(output).get_relative_to(&os::make_absolute(lib)))

branches/snap-stage3/src/librustc/middle/entry.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use syntax::codemap::Span;
1818
use syntax::parse::token::special_idents;
1919
use syntax::visit;
2020
use syntax::visit::Visitor;
21+
use std::util;
2122

2223
struct EntryContext {
2324
session: Session,
@@ -93,7 +94,7 @@ fn find_item(item: @item, ctxt: &mut EntryContext) {
9394
ctxt.non_main_fns.push((item.id, item.span));
9495
}
9596
}
96-
_ => unreachable!()
97+
_ => util::unreachable()
9798
}
9899
}
99100

branches/snap-stage3/src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ fn variant_opt(bcx: @mut Block, pat_id: ast::NodeId)
356356
adt::represent_node(bcx, pat_id))
357357
}
358358
}
359-
unreachable!();
359+
::std::util::unreachable();
360360
}
361361
ast::DefFn(*) |
362362
ast::DefStruct(_) => {

branches/snap-stage3/src/librustdoc/prune_private_pass.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use fold::Fold;
2020
use fold;
2121
use pass::Pass;
2222

23+
use std::util;
24+
2325
pub fn mk_pass() -> Pass {
2426
Pass {
2527
name: ~"prune_private",
@@ -146,7 +148,7 @@ fn is_visible(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool {
146148
}
147149
}
148150
}
149-
_ => unreachable!()
151+
_ => util::unreachable()
150152
}
151153
}
152154
}

branches/snap-stage3/src/libstd/hashmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use option::{None, Option, Some};
2727
use rand::RngUtil;
2828
use rand;
2929
use uint;
30-
use util::replace;
30+
use util::{replace, unreachable};
3131
use vec::{ImmutableVector, MutableVector, OwnedVector};
3232
use vec;
3333

@@ -187,7 +187,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
187187
fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V {
188188
match self.buckets[idx] {
189189
Some(ref mut bkt) => &mut bkt.value,
190-
None => unreachable!()
190+
None => unreachable()
191191
}
192192
}
193193

branches/snap-stage3/src/libstd/rand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use str;
5656
use sys;
5757
use u32;
5858
use uint;
59+
use util;
5960
use vec;
6061
use libc::size_t;
6162

@@ -585,7 +586,7 @@ impl<R: Rng> RngUtil for R {
585586
return Some(item.item.clone());
586587
}
587588
}
588-
unreachable!();
589+
util::unreachable();
589590
}
590591

591592
/**

branches/snap-stage3/src/libstd/rt/io/extensions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rt::io::{Reader, Writer, Decorator};
2121
use rt::io::{read_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
2222
use option::{Option, Some, None};
2323
use unstable::finally::Finally;
24+
use util;
2425
use cast;
2526
use io::{u64_to_le_bytes, u64_to_be_bytes};
2627

@@ -292,7 +293,7 @@ impl<T: Reader> ReaderUtil for T {
292293
self.read_byte()
293294
}
294295
Some(1) => Some(buf[0]),
295-
Some(_) => unreachable!(),
296+
Some(_) => util::unreachable(),
296297
None => None
297298
}
298299
}

branches/snap-stage3/src/libstd/run.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,28 @@ fn spawn_process_os(prog: &str, args: &[~str],
643643
use libc::funcs::bsd44::getdtablesize;
644644

645645
mod rustrt {
646-
use libc::c_void;
647-
648646
#[abi = "cdecl"]
649647
extern {
650648
pub fn rust_unset_sigprocmask();
651-
pub fn rust_set_environ(envp: *c_void);
652649
}
653650
}
654651

652+
#[cfg(windows)]
653+
unsafe fn set_environ(_envp: *c_void) {}
654+
#[cfg(target_os = "macos")]
655+
unsafe fn set_environ(envp: *c_void) {
656+
externfn!(fn _NSGetEnviron() -> *mut *c_void);
657+
658+
*_NSGetEnviron() = envp;
659+
}
660+
#[cfg(not(target_os = "macos"), not(windows))]
661+
unsafe fn set_environ(envp: *c_void) {
662+
extern {
663+
static mut environ: *c_void;
664+
}
665+
environ = envp;
666+
}
667+
655668
unsafe {
656669

657670
let pid = fork();
@@ -685,7 +698,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
685698

686699
do with_envp(env) |envp| {
687700
if !envp.is_null() {
688-
rustrt::rust_set_environ(envp);
701+
set_environ(envp);
689702
}
690703
do with_argv(prog, args) |argv| {
691704
execvp(*argv, argv);

branches/snap-stage3/src/libstd/util.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,34 @@ impl Void {
104104
}
105105

106106

107+
/**
108+
A utility function for indicating unreachable code. It will fail if
109+
executed. This is occasionally useful to put after loops that never
110+
terminate normally, but instead directly return from a function.
111+
112+
# Example
113+
114+
~~~ {.rust}
115+
fn choose_weighted_item(v: &[Item]) -> Item {
116+
assert!(!v.is_empty());
117+
let mut so_far = 0u;
118+
for v.each |item| {
119+
so_far += item.weight;
120+
if so_far > 100 {
121+
return item;
122+
}
123+
}
124+
// The above loop always returns, so we must hint to the
125+
// type checker that it isn't possible to get down here
126+
util::unreachable();
127+
}
128+
~~~
129+
130+
*/
131+
pub fn unreachable() -> ! {
132+
fail!("internal error: entered unreachable code");
133+
}
134+
107135
#[cfg(test)]
108136
mod tests {
109137
use super::*;

branches/snap-stage3/src/rt/rust_builtin.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,29 @@ rust_valgrind_stack_deregister(unsigned int id) {
643643
VALGRIND_STACK_DEREGISTER(id);
644644
}
645645

646+
#if defined(__WIN32__)
647+
648+
extern "C" CDECL void
649+
rust_unset_sigprocmask() {
650+
// empty stub for windows to keep linker happy
651+
}
652+
653+
#else
654+
655+
#include <signal.h>
656+
#include <unistd.h>
657+
658+
extern "C" CDECL void
659+
rust_unset_sigprocmask() {
660+
// this can't be safely converted to rust code because the
661+
// representation of sigset_t is platform-dependent
662+
sigset_t sset;
663+
sigemptyset(&sset);
664+
sigprocmask(SIG_SETMASK, &sset, NULL);
665+
}
666+
667+
#endif
668+
646669
//
647670
// Local Variables:
648671
// mode: C++

branches/snap-stage3/src/rt/rust_run_program.cpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

branches/snap-stage3/src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ rust_list_dir_wfd_fp_buf
2525
rust_log_console_on
2626
rust_log_console_off
2727
rust_should_log_console
28-
rust_set_environ
2928
rust_unset_sigprocmask
3029
rust_env_pairs
3130
upcall_rust_personality

branches/snap-stage3/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ pub fn main() {
1919
//~^^ ERROR cannot move out of dereference of & pointer
2020
}
2121
_ => {
22-
unreachable!();
22+
::std::util::unreachable();
2323
}
2424
}
2525
let z = tail[0].clone();
2626
info!(fmt!("%?", z));
2727
}
2828
_ => {
29-
unreachable!();
29+
::std::util::unreachable();
3030
}
3131
}
3232
}

branches/snap-stage3/src/test/compile-fail/borrowck-vec-pattern-move-tail.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ fn main() {
22
let mut a = [1, 2, 3, 4];
33
let t = match a {
44
[1, 2, ..tail] => tail,
5-
_ => unreachable!()
5+
_ => std::util::unreachable()
66
};
77
a[0] = 0; //~ ERROR cannot assign to `a[]` because it is borrowed
88
t[0];

0 commit comments

Comments
 (0)