Skip to content

Commit f66b72c

Browse files
committed
---
yaml --- r: 114346 b: refs/heads/master c: a239663 h: refs/heads/master v: v3
1 parent 6383fca commit f66b72c

File tree

9 files changed

+98
-92
lines changed

9 files changed

+98
-92
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1edb0e536433056738b7f715dd02ff1de582f2ba
2+
refs/heads/master: a239663413f62f9ff2ced554f35576557ff32a5c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ struct Foo { x: int, y: Box<int> }
944944
// `a` is the owner of the struct, and thus the owner of the struct's fields
945945
let a = Foo { x: 5, y: box 10 };
946946
}
947-
// when `a` goes out of scope, the destructor for the `Box<int>` in the struct's
947+
// when `a` goes out of scope, the destructor for the `~int` in the struct's
948948
// field is called
949949
950950
// `b` is mutable, and the mutability is inherited by the objects it owns

trunk/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ pub struct RangeInclusive<A> {
20162016

20172017
/// Return an iterator over the range [start, stop]
20182018
#[inline]
2019-
pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A)
2019+
pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One + ToPrimitive>(start: A, stop: A)
20202020
-> RangeInclusive<A> {
20212021
RangeInclusive{range: range(start, stop), done: false}
20222022
}

trunk/src/libflate/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ mod tests {
125125
for _ in range(0, 20) {
126126
let mut input = vec![];
127127
for _ in range(0, 2000) {
128-
input.push_all(r.choose(words.as_slice()).unwrap().as_slice());
128+
input.push_all(r.choose(words.as_slice()).as_slice());
129129
}
130130
debug!("de/inflate of {} bytes of random word-sequences",
131131
input.len());

trunk/src/librand/lib.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,39 +266,37 @@ pub trait Rng {
266266
0123456789");
267267
let mut s = StrBuf::with_capacity(len);
268268
for _ in range(0, len) {
269-
s.push_char(*self.choose(GEN_ASCII_STR_CHARSET).unwrap() as char)
269+
s.push_char(self.choose(GEN_ASCII_STR_CHARSET) as char)
270270
}
271271
s
272272
}
273273

274-
/// Return a random element from `values`.
275-
///
276-
/// Return `None` if `values` is empty.
274+
/// Choose an item randomly, failing if `values` is empty.
275+
fn choose<T: Clone>(&mut self, values: &[T]) -> T {
276+
self.choose_option(values).expect("Rng.choose: `values` is empty").clone()
277+
}
278+
279+
/// Choose `Some(&item)` randomly, returning `None` if values is
280+
/// empty.
277281
///
278282
/// # Example
279283
///
280-
/// ```
284+
/// ```rust
281285
/// use rand::{task_rng, Rng};
282286
///
283287
/// let choices = [1, 2, 4, 8, 16, 32];
284288
/// let mut rng = task_rng();
285-
/// println!("{}", rng.choose(choices));
286-
/// assert_eq!(rng.choose(choices.slice_to(0)), None);
289+
/// println!("{:?}", rng.choose_option(choices));
290+
/// println!("{:?}", rng.choose_option(choices.slice_to(0)));
287291
/// ```
288-
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
292+
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
289293
if values.is_empty() {
290294
None
291295
} else {
292296
Some(&values[self.gen_range(0u, values.len())])
293297
}
294298
}
295299

296-
/// Deprecated name for `choose()`.
297-
#[deprecated = "replaced by .choose()"]
298-
fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
299-
self.choose(values)
300-
}
301-
302300
/// Shuffle a mutable slice in place.
303301
///
304302
/// # Example
@@ -795,10 +793,18 @@ mod test {
795793
#[test]
796794
fn test_choose() {
797795
let mut r = task_rng();
798-
assert_eq!(r.choose([1, 1, 1]).map(|&x|x), Some(1));
796+
assert_eq!(r.choose([1, 1, 1]), 1);
797+
}
799798

799+
#[test]
800+
fn test_choose_option() {
801+
let mut r = task_rng();
800802
let v: &[int] = &[];
801-
assert_eq!(r.choose(v), None);
803+
assert!(r.choose_option(v).is_none());
804+
805+
let i = 1;
806+
let v = [1,1,1];
807+
assert_eq!(r.choose_option(v), Some(&i));
802808
}
803809

804810
#[test]

trunk/src/librustc/driver/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct Options {
7070
pub gc: bool,
7171
pub optimize: OptLevel,
7272
pub debuginfo: DebugInfoLevel,
73-
pub lint_opts: Vec<(lint::Lint, lint::level)> ,
73+
pub lint_opts: Vec<(lint::Lint, lint::Level)> ,
7474
pub output_types: Vec<back::link::OutputType> ,
7575
// This was mutable for rustpkg, which updates search paths based on the
7676
// parsed code. It remains mutable in case its replacements wants to use
@@ -580,8 +580,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
580580
let no_trans = matches.opt_present("no-trans");
581581
let no_analysis = matches.opt_present("no-analysis");
582582

583-
let lint_levels = [lint::allow, lint::warn,
584-
lint::deny, lint::forbid];
583+
let lint_levels = [lint::Allow, lint::Warn,
584+
lint::Deny, lint::Forbid];
585585
let mut lint_opts = Vec::new();
586586
let lint_dict = lint::get_lint_dict();
587587
for level in lint_levels.iter() {

trunk/src/librustc/middle/dead.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// closely. The idea is that all reachable symbols are live, codes called
1313
// from live codes are live, and everything else is dead.
1414

15-
use middle::lint::{allow, contains_lint, DeadCode};
15+
use middle::lint::{Allow, contains_lint, DeadCode};
1616
use middle::privacy;
1717
use middle::ty;
1818
use middle::typeck;
@@ -195,7 +195,7 @@ impl<'a> Visitor<()> for MarkSymbolVisitor<'a> {
195195
}
196196

197197
fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
198-
contains_lint(attrs, allow, DEAD_CODE_LINT_STR)
198+
contains_lint(attrs, Allow, DEAD_CODE_LINT_STR)
199199
|| attr::contains_name(attrs.as_slice(), "lang")
200200
}
201201

0 commit comments

Comments
 (0)