about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorChris Morgan <me@chrismorgan.info>2013-09-19 15:04:03 +1000
committerChris Morgan <me@chrismorgan.info>2013-09-19 15:04:03 +1000
commite2807a4565575c6a08a2a65c76ee37bf3f48c841 (patch)
treea3902c5db8e070e6e91a1f5b253c45b0ea2c801a /src/libstd
parent4dacd736510b2ae28a54489fe88571f1a6de019f (diff)
downloadrust-e2807a4565575c6a08a2a65c76ee37bf3f48c841.tar.gz
rust-e2807a4565575c6a08a2a65c76ee37bf3f48c841.zip
Replace unreachable() calls with unreachable!().
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::*;