]> git.lizzy.rs Git - rust.git/commitdiff
Rename remaining Failures to Panic
authorSubhash Bhushan <subhash.bhushan@kaybus.com>
Sat, 8 Nov 2014 15:47:51 +0000 (21:17 +0530)
committerSubhash Bhushan <subhash.bhushan@kaybus.com>
Thu, 20 Nov 2014 18:15:42 +0000 (23:45 +0530)
20 files changed:
src/libcollections/slice.rs
src/libcore/option.rs
src/libgetopts/lib.rs
src/libgreen/stack.rs
src/librand/distributions/exponential.rs
src/librand/distributions/gamma.rs
src/librand/distributions/mod.rs
src/librand/distributions/normal.rs
src/librand/distributions/range.rs
src/librand/lib.rs
src/librbml/lib.rs
src/libregex/compile.rs
src/librustc/middle/resolve.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc_trans/driver/mod.rs
src/libstd/ascii.rs
src/libstd/c_vec.rs
src/libstd/sys/windows/tty.rs
src/libstd/time/duration.rs

index e077f7f6021bde6f0a2aef46c8b339f62198265e..4a54b361001ceba9a07914676bdccf0b2cce7a61 100644 (file)
@@ -424,7 +424,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
     // allocate some memory to use as scratch memory, we keep the
     // length 0 so we can keep shallow copies of the contents of `v`
     // without risking the dtors running on an object twice if
-    // `compare` fails.
+    // `compare` panics.
     let mut working_space = Vec::with_capacity(2 * len);
     // these both are buffers of length `len`.
     let mut buf_dat = working_space.as_mut_ptr();
index 199389730373a541b2402c88cd86e76645b2d898..fcf2dab6908900b0f426ce74c0fa87052e2d1d8d 100644 (file)
@@ -303,7 +303,7 @@ pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
     ///
     /// # Panics
     ///
-    /// Fails if the value is a `None` with a custom panic message provided by
+    /// Panics if the value is a `None` with a custom panic message provided by
     /// `msg`.
     ///
     /// # Example
@@ -315,7 +315,7 @@ pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
     ///
     /// ```{.should_fail}
     /// let x: Option<&str> = None;
-    /// x.expect("the world is ending"); // fails with `world is ending`
+    /// x.expect("the world is ending"); // panics with `world is ending`
     /// ```
     #[inline]
     #[unstable = "waiting for conventions"]
index ad30bf304fc02e3547238fe0cee39c852648b116..c4d712cb673620f24a64eeecbf6e41a1db9b3801 100644 (file)
@@ -569,7 +569,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 ///
 /// On success returns `Ok(Matches)`. Use methods such as `opt_present`
 /// `opt_str`, etc. to interrogate results.
-/// # Errors
+/// # Panics
 ///
 /// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display
 /// information about it.
@@ -860,9 +860,9 @@ enum LengthLimit {
 /// Note: Function was moved here from `std::str` because this module is the only place that
 /// uses it, and because it was too specific for a general string function.
 ///
-/// #Failure:
+/// # Panics
 ///
-/// Fails during iteration if the string contains a non-whitespace
+/// Panics during iteration if the string contains a non-whitespace
 /// sequence longer than the limit.
 fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
                      -> bool {
index 5d8c1745723463d6f47f8e8d0b48d475ce7cf351..81e6152b3d7c3802499a7f9c11e8e8849b0af6f7 100644 (file)
@@ -42,7 +42,7 @@ impl Stack {
     pub fn new(size: uint) -> Stack {
         // Map in a stack. Eventually we might be able to handle stack
         // allocation failure, which would fail to spawn the task. But there's
-        // not many sensible things to do on OOM.  Failure seems fine (and is
+        // not many sensible things to do on OOM. Panic seems fine (and is
         // what the old stack allocation did).
         let stack = match MemoryMap::new(size, &[MapReadable, MapWritable,
                                                  MapNonStandardFlags(STACK_FLAGS)]) {
index 7d1a4409718faf42860114fffcdc3653967c2d68..d874f1deed3c2194917becf96f942162121f6e16 100644 (file)
@@ -73,7 +73,7 @@ pub struct Exp {
 
 impl Exp {
     /// Construct a new `Exp` with the given shape parameter
-    /// `lambda`. Fails if `lambda <= 0`.
+    /// `lambda`. Panics if `lambda <= 0`.
     pub fn new(lambda: f64) -> Exp {
         assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0");
         Exp { lambda_inverse: 1.0 / lambda }
index a8ce2efd5392f41ed3d41fc299fbc899bd4b3c5a..d33d838766f220da9cda5952f77e8fd7308b1c60 100644 (file)
@@ -95,7 +95,7 @@ impl Gamma {
     /// Construct an object representing the `Gamma(shape, scale)`
     /// distribution.
     ///
-    /// Fails if `shape <= 0` or `scale <= 0`.
+    /// Panics if `shape <= 0` or `scale <= 0`.
     pub fn new(shape: f64, scale: f64) -> Gamma {
         assert!(shape > 0.0, "Gamma::new called with shape <= 0");
         assert!(scale > 0.0, "Gamma::new called with scale <= 0");
@@ -208,7 +208,7 @@ enum ChiSquaredRepr {
 
 impl ChiSquared {
     /// Create a new chi-squared distribution with degrees-of-freedom
-    /// `k`. Fails if `k < 0`.
+    /// `k`. Panics if `k < 0`.
     pub fn new(k: f64) -> ChiSquared {
         let repr = if k == 1.0 {
             DoFExactlyOne
@@ -261,7 +261,7 @@ pub struct FisherF {
 
 impl FisherF {
     /// Create a new `FisherF` distribution, with the given
-    /// parameter. Fails if either `m` or `n` are not positive.
+    /// parameter. Panics if either `m` or `n` are not positive.
     pub fn new(m: f64, n: f64) -> FisherF {
         assert!(m > 0.0, "FisherF::new called with `m < 0`");
         assert!(n > 0.0, "FisherF::new called with `n < 0`");
@@ -302,7 +302,7 @@ pub struct StudentT {
 
 impl StudentT {
     /// Create a new Student t distribution with `n` degrees of
-    /// freedom. Fails if `n <= 0`.
+    /// freedom. Panics if `n <= 0`.
     pub fn new(n: f64) -> StudentT {
         assert!(n > 0.0, "StudentT::new called with `n <= 0`");
         StudentT {
index c777b8db31369291cb41e90ea9b2a529d6ce4ff7..5bbddcb7c1652892d1594d3d59df2f652f18cb65 100644 (file)
@@ -113,7 +113,7 @@ pub struct WeightedChoice<'a, T:'a> {
 impl<'a, T: Clone> WeightedChoice<'a, T> {
     /// Create a new `WeightedChoice`.
     ///
-    /// Fails if:
+    /// Panics if:
     /// - `v` is empty
     /// - the total weight is 0
     /// - the total weight is larger than a `uint` can contain.
index 507cafd28359042ba2e25f2cf6612448efb9a745..b3dc20819bc85a56463688579fdbb331c985086c 100644 (file)
@@ -90,7 +90,11 @@ pub struct Normal {
 
 impl Normal {
     /// Construct a new `Normal` distribution with the given mean and
-    /// standard deviation. Fails if `std_dev < 0`.
+    /// standard deviation.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `std_dev < 0`.
     pub fn new(mean: f64, std_dev: f64) -> Normal {
         assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
         Normal {
@@ -132,7 +136,11 @@ pub struct LogNormal {
 
 impl LogNormal {
     /// Construct a new `LogNormal` distribution with the given mean
-    /// and standard deviation. Fails if `std_dev < 0`.
+    /// and standard deviation.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `std_dev < 0`.
     pub fn new(mean: f64, std_dev: f64) -> LogNormal {
         assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0");
         LogNormal { norm: Normal::new(mean, std_dev) }
index 24ad917c250cd4943b9f0c46d95c35fe85b47ea4..6301623bbdc184ba429a2296a30432a62c32adac 100644 (file)
@@ -55,7 +55,7 @@ pub struct Range<X> {
 
 impl<X: SampleRange + PartialOrd> Range<X> {
     /// Create a new `Range` instance that samples uniformly from
-    /// `[low, high)`. Fails if `low >= high`.
+    /// `[low, high)`. Panics if `low >= high`.
     pub fn new(low: X, high: X) -> Range<X> {
         assert!(low < high, "Range::new called with `low >= high`");
         SampleRange::construct_range(low, high)
index d6a68dd07d76cfa08a90120bf925f8e8170d0267..b7b5b09cfe4a00df82a07118abfc0aa438ca8320 100644 (file)
@@ -204,8 +204,7 @@ fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
         Generator { rng: self }
     }
 
-    /// Generate a random value in the range [`low`, `high`). Fails if
-    /// `low >= high`.
+    /// Generate a random value in the range [`low`, `high`).
     ///
     /// This is a convenience wrapper around
     /// `distributions::Range`. If this function will be called
@@ -213,6 +212,10 @@ fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
     /// that will amortize the computations that allow for perfect
     /// uniformity, as they only happen on initialization.
     ///
+    /// # Panics
+    ///
+    /// Panics if `low >= high`.
+    ///
     /// # Example
     ///
     /// ```rust
index ccc7b96b26b82d8bf244dfdf12c1cc579069bce6..3f3f3179d27b8c4177c14675b826e90104ea9906 100644 (file)
@@ -841,7 +841,7 @@ fn _emit_label(&mut self, label: &str) -> EncodeResult {
             // the encoded EBML (normally).  This is just for
             // efficiency.  When debugging, though, we can emit such
             // labels and then they will be checked by decoder to
-            // try and check failures more quickly.
+            // try and check panics more quickly.
             if DEBUG { self.wr_tagged_str(EsLabel as uint, label) }
             else { Ok(()) }
         }
index 52167ead18ad47073b70da64cae1d605b3da27b4..c361a25bf52eb6c9af82b72e8fa013b0662d6421 100644 (file)
@@ -66,7 +66,7 @@ pub enum Inst {
     Jump(InstIdx),
 
     // Jumps to the instruction at the first index given. If that leads to
-    // a failing state, then the instruction at the second index given is
+    // a panic state, then the instruction at the second index given is
     // tried.
     Split(InstIdx, InstIdx),
 }
index 901f602ff30a84d55136a7782deeced2f6fe0c97..6ad3d67af0acd2cf79547ff035d28cf5f19cc66c 100644 (file)
@@ -766,7 +766,7 @@ fn get_module_if_available(&self) -> Option<Rc<Module>> {
     }
 
     /**
-     * Returns the module node. Fails if this node does not have a module
+     * Returns the module node. Panics if this node does not have a module
      * definition.
      */
     fn get_module(&self) -> Rc<Module> {
@@ -1109,8 +1109,10 @@ fn build_reduced_graph(&mut self, krate: &ast::Crate) {
      * corresponding to the innermost block ID and returns the name bindings
      * as well as the newly-created parent.
      *
-     * If this node does not have a module definition and we are not inside
-     * a block, fails.
+     * # Panics
+     *
+     * Panics if this node does not have a module definition and we are not inside
+     * a block.
      */
     fn add_child(&self,
                  name: Name,
@@ -2795,7 +2797,7 @@ fn get_binding(this: &mut Resolver,
         return Success(());
     }
 
-    // Resolves a glob import. Note that this function cannot fail; it either
+    // Resolves a glob import. Note that this function cannot panic; it either
     // succeeds or bails out (as importing * from an empty module or a module
     // that exports nothing is valid).
     fn resolve_glob_import(&mut self,
index 70b6bb9eed2f09ead3a4edc0b2d3351d7341a94f..e9319e29555d5fce48ba87446abe7ae7f1e2a66e 100644 (file)
@@ -3348,7 +3348,7 @@ pub fn lltype_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
     }
 }
 
-// Return the smallest part of ty which is unsized. Fails if ty is sized.
+// Return the smallest part of `ty` which is unsized. Fails if `ty` is sized.
 // 'Smallest' here means component of the static representation of the type; not
 // the size of an object at runtime.
 pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
@@ -4916,7 +4916,7 @@ pub fn lookup_field_type<'tcx>(tcx: &ctxt<'tcx>,
 }
 
 // Look up the list of field names and IDs for a given struct.
-// Fails if the id is not bound to a struct.
+// Panics if the id is not bound to a struct.
 pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
     if did.krate == ast::LOCAL_CRATE {
         let struct_fields = cx.struct_fields.borrow();
index fec1e06157b82722feeb7d8b84b266f0b47061b0..22483ce697835fa9eada9013f12922144c2a301c 100644 (file)
@@ -2605,7 +2605,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 }
 
 /// Given the head of a `for` expression, looks up the `next` method in the
-/// `Iterator` trait. Fails if the expression does not implement `next`.
+/// `Iterator` trait. Panics if the expression does not implement `next`.
 ///
 /// The return type of this function represents the concrete element type
 /// `A` in the type `Iterator<A>` that the method returns.
index a73afdf68e33c5958092271b45832e1215c8bd19..af5983244dfdd55b7539195539983a3b0f071b73 100644 (file)
@@ -143,7 +143,7 @@ pub fn commit_date_str() -> Option<&'static str> {
 }
 
 /// Prints version information and returns None on success or an error
-/// message on failure.
+/// message on panic.
 pub fn version(binary: &str, matches: &getopts::Matches) -> Option<String> {
     let verbose = match matches.opt_str("version").as_ref().map(|s| s.as_slice()) {
         None => false,
@@ -425,7 +425,7 @@ pub fn list_metadata(sess: &Session, path: &Path,
     metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx, path, out)
 }
 
-/// Run a procedure which will detect failures in the compiler and print nicer
+/// Run a procedure which will detect panics in the compiler and print nicer
 /// error messages rather than just failing the test.
 ///
 /// The diagnostic emitter yielded to the procedure should be used for reporting
@@ -492,7 +492,7 @@ pub fn monitor(f: proc():Send) {
             }
 
             // Panic so the process returns a failure code, but don't pollute the
-            // output with some unnecessary failure messages, we've already
+            // output with some unnecessary panic messages, we've already
             // printed everything that we needed to.
             io::stdio::set_stderr(box io::util::NullWriter);
             panic!();
index 923349b1bf74089ba378064d222e9e8e56cf0b02..933794cb5a4861129334b0a225f2ee22b831f88f 100644 (file)
@@ -216,7 +216,10 @@ pub trait OwnedAsciiCast {
     /// Check if convertible to ascii
     fn is_ascii(&self) -> bool;
 
-    /// Take ownership and cast to an ascii vector. Fail on non-ASCII input.
+    /// Take ownership and cast to an ascii vector.
+    /// # Panics
+    ///
+    /// Panic on non-ASCII input.
     #[inline]
     fn into_ascii(self) -> Vec<Ascii> {
         assert!(self.is_ascii());
index 771184df53dd4d8d87d07d26be715e399a15fafe..1267d7411cc2e986566a9adf90c04f8c2758404f 100644 (file)
@@ -64,7 +64,7 @@ fn drop(&mut self) {
 impl<T> CVec<T> {
     /// Create a `CVec` from a raw pointer to a buffer with a given length.
     ///
-    /// Fails if the given pointer is null. The returned vector will not attempt
+    /// Panics if the given pointer is null. The returned vector will not attempt
     /// to deallocate the vector when dropped.
     ///
     /// # Arguments
@@ -83,7 +83,7 @@ pub unsafe fn new(base: *mut T, len: uint) -> CVec<T> {
     /// Create a `CVec` from a foreign buffer, with a given length,
     /// and a function to run upon destruction.
     ///
-    /// Fails if the given pointer is null.
+    /// Panics if the given pointer is null.
     ///
     /// # Arguments
     ///
index 7d001e6394c30ff9752b64574ccb8d25a0f8e003..0e7b06cbb94785822c7d652038e880930f22174c 100644 (file)
@@ -14,8 +14,8 @@
 //!
 //! This module contains the implementation of a Windows specific console TTY.
 //! Also converts between UTF-16 and UTF-8. Windows has very poor support for
-//! UTF-8 and some functions will fail. In particular ReadFile and ReadConsole
-//! will fail when the codepage is set to UTF-8 and a Unicode character is
+//! UTF-8 and some functions will panic. In particular ReadFile and ReadConsole
+//! will panic when the codepage is set to UTF-8 and a Unicode character is
 //! entered.
 //!
 //! FIXME
@@ -48,7 +48,7 @@ fn invalid_encoding() -> IoError {
 
 pub fn is_tty(fd: c_int) -> bool {
     let mut out: DWORD = 0;
-    // If this function doesn't fail then fd is a TTY
+    // If this function doesn't panic then fd is a TTY
     match unsafe { GetConsoleMode(get_osfhandle(fd) as HANDLE,
                                   &mut out as LPDWORD) } {
         0 => false,
index 39ca3128ccb2babc7d94eafd1b2b55749cacd9b7..ec2d62ff85cb183df7c1c6173646e6e2f71df698 100644 (file)
@@ -65,7 +65,7 @@ pub struct Duration {
 impl Duration {
     /// Makes a new `Duration` with given number of weeks.
     /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
-    /// Fails when the duration is out of bounds.
+    /// Panics when the duration is out of bounds.
     #[inline]
     pub fn weeks(weeks: i64) -> Duration {
         let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds");
@@ -74,7 +74,7 @@ pub fn weeks(weeks: i64) -> Duration {
 
     /// Makes a new `Duration` with given number of days.
     /// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks.
-    /// Fails when the duration is out of bounds.
+    /// Panics when the duration is out of bounds.
     #[inline]
     pub fn days(days: i64) -> Duration {
         let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds");
@@ -83,7 +83,7 @@ pub fn days(days: i64) -> Duration {
 
     /// Makes a new `Duration` with given number of hours.
     /// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks.
-    /// Fails when the duration is out of bounds.
+    /// Panics when the duration is out of bounds.
     #[inline]
     pub fn hours(hours: i64) -> Duration {
         let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds");
@@ -92,7 +92,7 @@ pub fn hours(hours: i64) -> Duration {
 
     /// Makes a new `Duration` with given number of minutes.
     /// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks.
-    /// Fails when the duration is out of bounds.
+    /// Panics when the duration is out of bounds.
     #[inline]
     pub fn minutes(minutes: i64) -> Duration {
         let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds");
@@ -100,7 +100,7 @@ pub fn minutes(minutes: i64) -> Duration {
     }
 
     /// Makes a new `Duration` with given number of seconds.
-    /// Fails when the duration is more than `i64::MAX` milliseconds
+    /// Panics when the duration is more than `i64::MAX` milliseconds
     /// or less than `i64::MIN` milliseconds.
     #[inline]
     pub fn seconds(seconds: i64) -> Duration {