Skip to content

Commit bc9de77

Browse files
author
Subhash Bhushan
committed
Rename remaining Failures to Panic
1 parent 394269d commit bc9de77

File tree

20 files changed

+57
-41
lines changed

20 files changed

+57
-41
lines changed

src/libcollections/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
424424
// allocate some memory to use as scratch memory, we keep the
425425
// length 0 so we can keep shallow copies of the contents of `v`
426426
// without risking the dtors running on an object twice if
427-
// `compare` fails.
427+
// `compare` panics.
428428
let mut working_space = Vec::with_capacity(2 * len);
429429
// these both are buffers of length `len`.
430430
let mut buf_dat = working_space.as_mut_ptr();

src/libcore/option.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<T> Option<T> {
303303
///
304304
/// # Panics
305305
///
306-
/// Fails if the value is a `None` with a custom panic message provided by
306+
/// Panics if the value is a `None` with a custom panic message provided by
307307
/// `msg`.
308308
///
309309
/// # Example
@@ -315,7 +315,7 @@ impl<T> Option<T> {
315315
///
316316
/// ```{.should_fail}
317317
/// let x: Option<&str> = None;
318-
/// x.expect("the world is ending"); // fails with `world is ending`
318+
/// x.expect("the world is ending"); // panics with `world is ending`
319319
/// ```
320320
#[inline]
321321
#[unstable = "waiting for conventions"]

src/libgetopts/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl fmt::Show for Fail_ {
569569
///
570570
/// On success returns `Ok(Matches)`. Use methods such as `opt_present`
571571
/// `opt_str`, etc. to interrogate results.
572-
/// # Errors
572+
/// # Panics
573573
///
574574
/// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display
575575
/// information about it.
@@ -860,9 +860,9 @@ enum LengthLimit {
860860
/// Note: Function was moved here from `std::str` because this module is the only place that
861861
/// uses it, and because it was too specific for a general string function.
862862
///
863-
/// #Failure:
863+
/// # Panics
864864
///
865-
/// Fails during iteration if the string contains a non-whitespace
865+
/// Panics during iteration if the string contains a non-whitespace
866866
/// sequence longer than the limit.
867867
fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
868868
-> bool {

src/libgreen/stack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Stack {
4242
pub fn new(size: uint) -> Stack {
4343
// Map in a stack. Eventually we might be able to handle stack
4444
// allocation failure, which would fail to spawn the task. But there's
45-
// not many sensible things to do on OOM. Failure seems fine (and is
45+
// not many sensible things to do on OOM. Panic seems fine (and is
4646
// what the old stack allocation did).
4747
let stack = match MemoryMap::new(size, &[MapReadable, MapWritable,
4848
MapNonStandardFlags(STACK_FLAGS)]) {

src/librand/distributions/exponential.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct Exp {
7373

7474
impl Exp {
7575
/// Construct a new `Exp` with the given shape parameter
76-
/// `lambda`. Fails if `lambda <= 0`.
76+
/// `lambda`. Panics if `lambda <= 0`.
7777
pub fn new(lambda: f64) -> Exp {
7878
assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0");
7979
Exp { lambda_inverse: 1.0 / lambda }

src/librand/distributions/gamma.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Gamma {
9595
/// Construct an object representing the `Gamma(shape, scale)`
9696
/// distribution.
9797
///
98-
/// Fails if `shape <= 0` or `scale <= 0`.
98+
/// Panics if `shape <= 0` or `scale <= 0`.
9999
pub fn new(shape: f64, scale: f64) -> Gamma {
100100
assert!(shape > 0.0, "Gamma::new called with shape <= 0");
101101
assert!(scale > 0.0, "Gamma::new called with scale <= 0");
@@ -208,7 +208,7 @@ enum ChiSquaredRepr {
208208

209209
impl ChiSquared {
210210
/// Create a new chi-squared distribution with degrees-of-freedom
211-
/// `k`. Fails if `k < 0`.
211+
/// `k`. Panics if `k < 0`.
212212
pub fn new(k: f64) -> ChiSquared {
213213
let repr = if k == 1.0 {
214214
DoFExactlyOne
@@ -261,7 +261,7 @@ pub struct FisherF {
261261

262262
impl FisherF {
263263
/// Create a new `FisherF` distribution, with the given
264-
/// parameter. Fails if either `m` or `n` are not positive.
264+
/// parameter. Panics if either `m` or `n` are not positive.
265265
pub fn new(m: f64, n: f64) -> FisherF {
266266
assert!(m > 0.0, "FisherF::new called with `m < 0`");
267267
assert!(n > 0.0, "FisherF::new called with `n < 0`");
@@ -302,7 +302,7 @@ pub struct StudentT {
302302

303303
impl StudentT {
304304
/// Create a new Student t distribution with `n` degrees of
305-
/// freedom. Fails if `n <= 0`.
305+
/// freedom. Panics if `n <= 0`.
306306
pub fn new(n: f64) -> StudentT {
307307
assert!(n > 0.0, "StudentT::new called with `n <= 0`");
308308
StudentT {

src/librand/distributions/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub struct WeightedChoice<'a, T:'a> {
113113
impl<'a, T: Clone> WeightedChoice<'a, T> {
114114
/// Create a new `WeightedChoice`.
115115
///
116-
/// Fails if:
116+
/// Panics if:
117117
/// - `v` is empty
118118
/// - the total weight is 0
119119
/// - the total weight is larger than a `uint` can contain.

src/librand/distributions/normal.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ pub struct Normal {
9090

9191
impl Normal {
9292
/// Construct a new `Normal` distribution with the given mean and
93-
/// standard deviation. Fails if `std_dev < 0`.
93+
/// standard deviation.
94+
///
95+
/// # Panics
96+
///
97+
/// Panics if `std_dev < 0`.
9498
pub fn new(mean: f64, std_dev: f64) -> Normal {
9599
assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0");
96100
Normal {
@@ -132,7 +136,11 @@ pub struct LogNormal {
132136

133137
impl LogNormal {
134138
/// Construct a new `LogNormal` distribution with the given mean
135-
/// and standard deviation. Fails if `std_dev < 0`.
139+
/// and standard deviation.
140+
///
141+
/// # Panics
142+
///
143+
/// Panics if `std_dev < 0`.
136144
pub fn new(mean: f64, std_dev: f64) -> LogNormal {
137145
assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0");
138146
LogNormal { norm: Normal::new(mean, std_dev) }

src/librand/distributions/range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub struct Range<X> {
5555

5656
impl<X: SampleRange + PartialOrd> Range<X> {
5757
/// Create a new `Range` instance that samples uniformly from
58-
/// `[low, high)`. Fails if `low >= high`.
58+
/// `[low, high)`. Panics if `low >= high`.
5959
pub fn new(low: X, high: X) -> Range<X> {
6060
assert!(low < high, "Range::new called with `low >= high`");
6161
SampleRange::construct_range(low, high)

src/librand/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,18 @@ pub trait Rng {
204204
Generator { rng: self }
205205
}
206206

207-
/// Generate a random value in the range [`low`, `high`). Fails if
208-
/// `low >= high`.
207+
/// Generate a random value in the range [`low`, `high`).
209208
///
210209
/// This is a convenience wrapper around
211210
/// `distributions::Range`. If this function will be called
212211
/// repeatedly with the same arguments, one should use `Range`, as
213212
/// that will amortize the computations that allow for perfect
214213
/// uniformity, as they only happen on initialization.
215214
///
215+
/// # Panics
216+
///
217+
/// Panics if `low >= high`.
218+
///
216219
/// # Example
217220
///
218221
/// ```rust

src/librbml/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ pub mod writer {
841841
// the encoded EBML (normally). This is just for
842842
// efficiency. When debugging, though, we can emit such
843843
// labels and then they will be checked by decoder to
844-
// try and check failures more quickly.
844+
// try and check panics more quickly.
845845
if DEBUG { self.wr_tagged_str(EsLabel as uint, label) }
846846
else { Ok(()) }
847847
}

src/libregex/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub enum Inst {
6666
Jump(InstIdx),
6767

6868
// Jumps to the instruction at the first index given. If that leads to
69-
// a failing state, then the instruction at the second index given is
69+
// a panic state, then the instruction at the second index given is
7070
// tried.
7171
Split(InstIdx, InstIdx),
7272
}

src/librustc/middle/resolve.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl NameBindings {
766766
}
767767

768768
/**
769-
* Returns the module node. Fails if this node does not have a module
769+
* Returns the module node. Panics if this node does not have a module
770770
* definition.
771771
*/
772772
fn get_module(&self) -> Rc<Module> {
@@ -1109,8 +1109,10 @@ impl<'a> Resolver<'a> {
11091109
* corresponding to the innermost block ID and returns the name bindings
11101110
* as well as the newly-created parent.
11111111
*
1112-
* If this node does not have a module definition and we are not inside
1113-
* a block, fails.
1112+
* # Panics
1113+
*
1114+
* Panics if this node does not have a module definition and we are not inside
1115+
* a block.
11141116
*/
11151117
fn add_child(&self,
11161118
name: Name,
@@ -2795,7 +2797,7 @@ impl<'a> Resolver<'a> {
27952797
return Success(());
27962798
}
27972799

2798-
// Resolves a glob import. Note that this function cannot fail; it either
2800+
// Resolves a glob import. Note that this function cannot panic; it either
27992801
// succeeds or bails out (as importing * from an empty module or a module
28002802
// that exports nothing is valid).
28012803
fn resolve_glob_import(&mut self,

src/librustc/middle/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3348,7 +3348,7 @@ pub fn lltype_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
33483348
}
33493349
}
33503350

3351-
// Return the smallest part of ty which is unsized. Fails if ty is sized.
3351+
// Return the smallest part of `ty` which is unsized. Fails if `ty` is sized.
33523352
// 'Smallest' here means component of the static representation of the type; not
33533353
// the size of an object at runtime.
33543354
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>,
49164916
}
49174917

49184918
// Look up the list of field names and IDs for a given struct.
4919-
// Fails if the id is not bound to a struct.
4919+
// Panics if the id is not bound to a struct.
49204920
pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
49214921
if did.krate == ast::LOCAL_CRATE {
49224922
let struct_fields = cx.struct_fields.borrow();

src/librustc/middle/typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2605,7 +2605,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
26052605
}
26062606

26072607
/// Given the head of a `for` expression, looks up the `next` method in the
2608-
/// `Iterator` trait. Fails if the expression does not implement `next`.
2608+
/// `Iterator` trait. Panics if the expression does not implement `next`.
26092609
///
26102610
/// The return type of this function represents the concrete element type
26112611
/// `A` in the type `Iterator<A>` that the method returns.

src/librustc_trans/driver/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub fn commit_date_str() -> Option<&'static str> {
143143
}
144144

145145
/// Prints version information and returns None on success or an error
146-
/// message on failure.
146+
/// message on panic.
147147
pub fn version(binary: &str, matches: &getopts::Matches) -> Option<String> {
148148
let verbose = match matches.opt_str("version").as_ref().map(|s| s.as_slice()) {
149149
None => false,
@@ -425,7 +425,7 @@ pub fn list_metadata(sess: &Session, path: &Path,
425425
metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx, path, out)
426426
}
427427

428-
/// Run a procedure which will detect failures in the compiler and print nicer
428+
/// Run a procedure which will detect panics in the compiler and print nicer
429429
/// error messages rather than just failing the test.
430430
///
431431
/// The diagnostic emitter yielded to the procedure should be used for reporting
@@ -492,7 +492,7 @@ pub fn monitor(f: proc():Send) {
492492
}
493493

494494
// Panic so the process returns a failure code, but don't pollute the
495-
// output with some unnecessary failure messages, we've already
495+
// output with some unnecessary panic messages, we've already
496496
// printed everything that we needed to.
497497
io::stdio::set_stderr(box io::util::NullWriter);
498498
panic!();

src/libstd/ascii.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ pub trait OwnedAsciiCast {
216216
/// Check if convertible to ascii
217217
fn is_ascii(&self) -> bool;
218218

219-
/// Take ownership and cast to an ascii vector. Fail on non-ASCII input.
219+
/// Take ownership and cast to an ascii vector.
220+
/// # Panics
221+
///
222+
/// Panic on non-ASCII input.
220223
#[inline]
221224
fn into_ascii(self) -> Vec<Ascii> {
222225
assert!(self.is_ascii());

src/libstd/c_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<T> Drop for CVec<T> {
6464
impl<T> CVec<T> {
6565
/// Create a `CVec` from a raw pointer to a buffer with a given length.
6666
///
67-
/// Fails if the given pointer is null. The returned vector will not attempt
67+
/// Panics if the given pointer is null. The returned vector will not attempt
6868
/// to deallocate the vector when dropped.
6969
///
7070
/// # Arguments
@@ -83,7 +83,7 @@ impl<T> CVec<T> {
8383
/// Create a `CVec` from a foreign buffer, with a given length,
8484
/// and a function to run upon destruction.
8585
///
86-
/// Fails if the given pointer is null.
86+
/// Panics if the given pointer is null.
8787
///
8888
/// # Arguments
8989
///

src/libstd/sys/windows/tty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//!
1515
//! This module contains the implementation of a Windows specific console TTY.
1616
//! Also converts between UTF-16 and UTF-8. Windows has very poor support for
17-
//! UTF-8 and some functions will fail. In particular ReadFile and ReadConsole
18-
//! will fail when the codepage is set to UTF-8 and a Unicode character is
17+
//! UTF-8 and some functions will panic. In particular ReadFile and ReadConsole
18+
//! will panic when the codepage is set to UTF-8 and a Unicode character is
1919
//! entered.
2020
//!
2121
//! FIXME
@@ -48,7 +48,7 @@ fn invalid_encoding() -> IoError {
4848

4949
pub fn is_tty(fd: c_int) -> bool {
5050
let mut out: DWORD = 0;
51-
// If this function doesn't fail then fd is a TTY
51+
// If this function doesn't panic then fd is a TTY
5252
match unsafe { GetConsoleMode(get_osfhandle(fd) as HANDLE,
5353
&mut out as LPDWORD) } {
5454
0 => false,

src/libstd/time/duration.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub const MAX: Duration = Duration {
6565
impl Duration {
6666
/// Makes a new `Duration` with given number of weeks.
6767
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
68-
/// Fails when the duration is out of bounds.
68+
/// Panics when the duration is out of bounds.
6969
#[inline]
7070
pub fn weeks(weeks: i64) -> Duration {
7171
let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds");
@@ -74,7 +74,7 @@ impl Duration {
7474

7575
/// Makes a new `Duration` with given number of days.
7676
/// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks.
77-
/// Fails when the duration is out of bounds.
77+
/// Panics when the duration is out of bounds.
7878
#[inline]
7979
pub fn days(days: i64) -> Duration {
8080
let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds");
@@ -83,7 +83,7 @@ impl Duration {
8383

8484
/// Makes a new `Duration` with given number of hours.
8585
/// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks.
86-
/// Fails when the duration is out of bounds.
86+
/// Panics when the duration is out of bounds.
8787
#[inline]
8888
pub fn hours(hours: i64) -> Duration {
8989
let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds");
@@ -92,15 +92,15 @@ impl Duration {
9292

9393
/// Makes a new `Duration` with given number of minutes.
9494
/// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks.
95-
/// Fails when the duration is out of bounds.
95+
/// Panics when the duration is out of bounds.
9696
#[inline]
9797
pub fn minutes(minutes: i64) -> Duration {
9898
let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds");
9999
Duration::seconds(secs)
100100
}
101101

102102
/// Makes a new `Duration` with given number of seconds.
103-
/// Fails when the duration is more than `i64::MAX` milliseconds
103+
/// Panics when the duration is more than `i64::MAX` milliseconds
104104
/// or less than `i64::MIN` milliseconds.
105105
#[inline]
106106
pub fn seconds(seconds: i64) -> Duration {

0 commit comments

Comments
 (0)