about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-20 00:36:11 -0700
committerbors <bors@rust-lang.org>2013-09-20 00:36:11 -0700
commite5fdc7dee52033f1097019d3aafe838db9ab5e3e (patch)
treee3965282a18b6ed03a811f118bc6be4262082fef /src/libstd
parentc7c769d8c2efb05dfa5850ae4aec0d6509d713dc (diff)
parente2807a4565575c6a08a2a65c76ee37bf3f48c841 (diff)
downloadrust-e5fdc7dee52033f1097019d3aafe838db9ab5e3e.tar.gz
rust-e5fdc7dee52033f1097019d3aafe838db9ab5e3e.zip
auto merge of #9320 : chris-morgan/rust/unreachable-macro-part-two-of-two-containing-the-destruction-of-the-unreachable-function, r=alexcrichton
This is the second of two parts of #8991, now possible as a new snapshot
has been made. (The first part implemented the unreachable!() macro; it
was #8992, 6b7b8f2682.)

``std::util::unreachable()`` is removed summarily; any code which used
it should now use the ``unreachable!()`` macro.

Closes #9312.

Closes #8991.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/hashmap.rs4
-rw-r--r--src/libstd/rand.rs3
-rw-r--r--src/libstd/rt/io/extensions.rs3
-rw-r--r--src/libstd/util.rs28
4 files changed, 4 insertions, 34 deletions
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index 6c0a6a4ea0a..800eca4291f 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -27,7 +27,7 @@ use option::{None, Option, Some};
 use rand::RngUtil;
 use rand;
 use uint;
-use util::{replace, unreachable};
+use util::replace;
 use vec::{ImmutableVector, MutableVector, OwnedVector};
 use vec;
 
@@ -187,7 +187,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
     fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V {
         match self.buckets[idx] {
             Some(ref mut bkt) => &mut bkt.value,
-            None => unreachable()
+            None => unreachable!()
         }
     }
 
diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs
index 8ca247edb59..71664569c87 100644
--- a/src/libstd/rand.rs
+++ b/src/libstd/rand.rs
@@ -56,7 +56,6 @@ use str;
 use sys;
 use u32;
 use uint;
-use util;
 use vec;
 use libc::size_t;
 
@@ -586,7 +585,7 @@ impl<R: Rng> RngUtil for R {
                 return Some(item.item.clone());
             }
         }
-        util::unreachable();
+        unreachable!();
     }
 
     /**
diff --git a/src/libstd/rt/io/extensions.rs b/src/libstd/rt/io/extensions.rs
index 1c48d6e7f1e..99634b532b0 100644
--- a/src/libstd/rt/io/extensions.rs
+++ b/src/libstd/rt/io/extensions.rs
@@ -21,7 +21,6 @@ use rt::io::{Reader, Writer, Decorator};
 use rt::io::{read_error, standard_error, EndOfFile, DEFAULT_BUF_SIZE};
 use option::{Option, Some, None};
 use unstable::finally::Finally;
-use util;
 use cast;
 use io::{u64_to_le_bytes, u64_to_be_bytes};
 
@@ -293,7 +292,7 @@ impl<T: Reader> ReaderUtil for T {
                 self.read_byte()
             }
             Some(1) => Some(buf[0]),
-            Some(_) => util::unreachable(),
+            Some(_) => unreachable!(),
             None => None
         }
     }
diff --git a/src/libstd/util.rs b/src/libstd/util.rs
index e8bcceb85fa..4acc1f3abff 100644
--- a/src/libstd/util.rs
+++ b/src/libstd/util.rs
@@ -104,34 +104,6 @@ impl Void {
 }
 
 
-/**
-A utility function for indicating unreachable code. It will fail if
-executed. This is occasionally useful to put after loops that never
-terminate normally, but instead directly return from a function.
-
-# Example
-
-~~~ {.rust}
-fn choose_weighted_item(v: &[Item]) -> Item {
-    assert!(!v.is_empty());
-    let mut so_far = 0u;
-    for v.each |item| {
-        so_far += item.weight;
-        if so_far > 100 {
-            return item;
-        }
-    }
-    // The above loop always returns, so we must hint to the
-    // type checker that it isn't possible to get down here
-    util::unreachable();
-}
-~~~
-
-*/
-pub fn unreachable() -> ! {
-    fail!("internal error: entered unreachable code");
-}
-
 #[cfg(test)]
 mod tests {
     use super::*;