Skip to content

Commit 198e8d3

Browse files
committed
---
yaml --- r: 162422 b: refs/heads/try c: 9830051 h: refs/heads/master v: v3
1 parent f6edb1a commit 198e8d3

File tree

30 files changed

+127
-57
lines changed

30 files changed

+127
-57
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cafe2966770ff377aad6dd9fd808e68055587c58
5-
refs/heads/try: 16bb4e6400607ae51a929fe1c034fe709a57bb92
5+
refs/heads/try: 98300516072c6afd0e93654b325f5924b60dea53
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
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();

branches/try/src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
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"]

branches/try/src/libgetopts/lib.rs

Lines changed: 3 additions & 3 deletions
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 {

branches/try/src/libgreen/stack.rs

Lines changed: 1 addition & 1 deletion
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)]) {

branches/try/src/librand/distributions/exponential.rs

Lines changed: 1 addition & 1 deletion
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 }

branches/try/src/librand/distributions/gamma.rs

Lines changed: 4 additions & 4 deletions
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 {

branches/try/src/librand/distributions/mod.rs

Lines changed: 1 addition & 1 deletion
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.

branches/try/src/librand/distributions/normal.rs

Lines changed: 10 additions & 2 deletions
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) }

branches/try/src/librand/distributions/range.rs

Lines changed: 1 addition & 1 deletion
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)

branches/try/src/librand/lib.rs

Lines changed: 5 additions & 2 deletions
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

branches/try/src/librbml/lib.rs

Lines changed: 1 addition & 1 deletion
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
}

branches/try/src/libregex/compile.rs

Lines changed: 1 addition & 1 deletion
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
}

branches/try/src/librustc/middle/resolve.rs

Lines changed: 6 additions & 4 deletions
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,

branches/try/src/librustc/middle/traits/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ pub enum ObligationCauseCode<'tcx> {
9494

9595
// Types of fields (other than the last) in a struct must be sized.
9696
FieldSized,
97+
98+
// Only Sized types can be made into objects
99+
ObjectSized,
97100
}
98101

99102
pub type Obligations<'tcx> = subst::VecPerParamSpace<Obligation<'tcx>>;

branches/try/src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
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();

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,12 +1775,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17751775
}
17761776
ty::UnsizeVtable(ref ty_trait, self_ty) => {
17771777
vtable::check_object_safety(self.tcx(), ty_trait, span);
1778+
17781779
// If the type is `Foo+'a`, ensures that the type
17791780
// being cast to `Foo+'a` implements `Foo`:
17801781
vtable::register_object_cast_obligations(self,
1781-
span,
1782-
ty_trait,
1783-
self_ty);
1782+
span,
1783+
ty_trait,
1784+
self_ty);
17841785

17851786
// If the type is `Foo+'a`, ensures that the type
17861787
// being cast to `Foo+'a` outlives `'a`:
@@ -2605,7 +2606,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
26052606
}
26062607

26072608
/// 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`.
2609+
/// `Iterator` trait. Panics if the expression does not implement `next`.
26092610
///
26102611
/// The return type of this function represents the concrete element type
26112612
/// `A` in the type `Iterator<A>` that the method returns.

branches/try/src/librustc/middle/typeck/check/vtable.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use middle::typeck::infer;
2121
use std::rc::Rc;
2222
use syntax::ast;
2323
use syntax::codemap::Span;
24+
use util::common::ErrorReported;
2425
use util::ppaux::{UserString, Repr, ty_to_string};
2526

2627
pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
@@ -238,6 +239,20 @@ pub fn register_object_cast_obligations<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
238239
referent_ty: Ty<'tcx>)
239240
-> Rc<ty::TraitRef<'tcx>>
240241
{
242+
// We can only make objects from sized types.
243+
let sized_obligation =
244+
traits::obligation_for_builtin_bound(
245+
fcx.tcx(),
246+
traits::ObligationCause::new(span, traits::ObjectSized),
247+
referent_ty,
248+
ty::BoundSized);
249+
match sized_obligation {
250+
Ok(sized_obligation) => {
251+
fcx.register_obligation(sized_obligation);
252+
}
253+
Err(ErrorReported) => { }
254+
}
255+
241256
// This is just for better error reporting. Kinda goofy. The object type stuff
242257
// needs some refactoring so there is a more convenient type to pass around.
243258
let object_trait_ty =
@@ -543,5 +558,9 @@ fn note_obligation_cause<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
543558
"only the last field of a struct or enum variant \
544559
may have a dynamically sized type")
545560
}
561+
traits::ObjectSized => {
562+
span_note!(tcx.sess, obligation.cause.span,
563+
"only sized types can be made into objects");
564+
}
546565
}
547566
}

branches/try/src/librustc/util/common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use syntax::ast;
2020
use syntax::visit;
2121
use syntax::visit::Visitor;
2222

23-
// An error has already been reported to the user, so no need to continue checking.
23+
// Useful type to use with `Result<>` indicate that an error has already
24+
// been reported to the user, so no need to continue checking.
2425
#[deriving(Clone,Show)]
2526
pub struct ErrorReported;
2627

branches/try/src/librustc_trans/driver/mod.rs

Lines changed: 3 additions & 3 deletions
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!();

branches/try/src/libstd/ascii.rs

Lines changed: 4 additions & 1 deletion
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());

branches/try/src/libstd/c_vec.rs

Lines changed: 2 additions & 2 deletions
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
///

0 commit comments

Comments
 (0)