Skip to content

Rolling up PRs in the queue #17127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Sep 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5eea93a
Fixes type range issue during linting (#16684)
Aug 26, 2014
d80729a
Add ICE regression test for issue #16218.
nathantypanski Sep 7, 2014
fda2319
Add regression test for issue #10766
nathantypanski Sep 7, 2014
0b2e6f8
Relicense shootout-reverse-complement.rs to the shootout license.
TeXitoi Sep 7, 2014
4894c21
Relicense shootout-nbody.rs to the shootout license
TeXitoi Sep 7, 2014
248319a
Flip arguments to `std::iter::iterate`.
treeman Sep 7, 2014
c98a80e
Fix casts in constant expressions
Sep 7, 2014
8c3db5b
Allow Rust to be built with LLVM trunk (3.6).
DanAlbert Sep 7, 2014
6c5c1ee
rustdoc: Don't strip #-lines if notrust
alexcrichton Sep 7, 2014
52e99cb
libnative/io: generic retry() for Unix 64 bit read/write().
nodakai Sep 5, 2014
a1d9010
Add ICE regression test with unboxed closures
nathantypanski Sep 8, 2014
13013d8
Relicense shootout-chameneos-redux.rs to the shootout license.
TeXitoi Sep 8, 2014
3ca53d3
librustc: Make sure lifetimes in `for` loop heads outlive the `for` loop
pcwalton Sep 8, 2014
22179f4
librustc: Feature gate subslice matching in non-tail positions.
pcwalton Sep 6, 2014
2b36194
quote: Explicitly borrow the ExtCtxt
kmcallister Sep 6, 2014
c2fcd4c
Check traits for built-in bounds in impls
nrc Sep 5, 2014
18f1f5a
guide: Remove reference to uninitialized bindings
steveklabnik Sep 8, 2014
eb678ff
librustc: Change the syntax of subslice matching to use postfix `..`
pcwalton Sep 6, 2014
4f4a3df
Decoding json now defaults Option<_> to None.
treeman Sep 9, 2014
b191628
Handle `Sized?` in `type` items.
nrc Sep 9, 2014
947a1b9
Remove some test warnings.
treeman Sep 9, 2014
679b4e1
rollup merge of #16971 : treeman/json-decode
alexcrichton Sep 9, 2014
f48b701
rollup merge of #17008 : nick29581/impl2
alexcrichton Sep 9, 2014
a0b3701
rollup merge of #17013 : rgawdzik/literal_int
alexcrichton Sep 9, 2014
d1d9d19
rollup merge of #17020 : nodakai/libnative-c_int
alexcrichton Sep 9, 2014
fb3c67a
rollup merge of #17040 : kmcallister/borrow-extctxt
alexcrichton Sep 9, 2014
2c66c29
rollup merge of #17052 : pcwalton/feature-gate-subslices
alexcrichton Sep 9, 2014
8158463
rollup merge of #17054 : pcwalton/subslice-syntax
alexcrichton Sep 9, 2014
e8e6239
rollup merge of #17061 : nathantypanski/test-borrowck-trait
alexcrichton Sep 9, 2014
2703fcf
rollup merge of #17062 : nathantypanski/generic-lifetime-trait-impl
alexcrichton Sep 9, 2014
d0cd011
rollup merge of #17070 : TeXitoi/relicense-shootout-reverse-complemen…
alexcrichton Sep 9, 2014
83e4653
rollup merge of #17077 : TeXitoi/relicense-shootout-nbody
alexcrichton Sep 9, 2014
b8dd7d5
rollup merge of #17080 : treeman/issue-17066
alexcrichton Sep 9, 2014
e6b0784
rollup merge of #17085 : jakub-/issue-17074
alexcrichton Sep 9, 2014
c9b1e83
rollup merge of #17087 : DanAlbert/llvm-3.6
alexcrichton Sep 9, 2014
b00db68
rollup merge of #17090 : alexcrichton/rustdoc-no-strip
alexcrichton Sep 9, 2014
e561a28
rollup merge of #17093 : nathantypanski/17021
alexcrichton Sep 9, 2014
6b487eb
rollup merge of #17096 : TeXitoi/relicense-shootout-chameneos-redux
alexcrichton Sep 9, 2014
a9d8f29
rollup merge of #17101 : pcwalton/for-loop-borrowck
alexcrichton Sep 9, 2014
613ae0b
rollup merge of #17106 : treeman/test-warnings
alexcrichton Sep 9, 2014
456f00e
rollup merge of #17107 : steveklabnik/uninitialized_bindings
alexcrichton Sep 9, 2014
25e08fb
rollup merge of #17114 : nick29581/dst-type
alexcrichton Sep 9, 2014
e5abe15
Test fixes from the rollup
alexcrichton Sep 9, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ then
| cut -d ' ' -f 2)

case $CFG_CLANG_VERSION in
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* )
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
if [ -z "$CC" ]
then
Expand Down
13 changes: 2 additions & 11 deletions src/doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,8 @@ error: aborting due to previous error
Could not compile `hello_world`.
```

Rust will not let us use a value that has not been initialized. So why let us
declare a binding without initializing it? You'd think our first example would
have errored. Well, Rust is smarter than that. Before we get to that, let's talk
about this stuff we've added to `println!`.
Rust will not let us use a value that has not been initialized. Next, let's
talk about this stuff we've added to `println!`.

If you include two curly braces (`{}`, some call them moustaches...) in your
string to print, Rust will interpret this as a request to interpolate some sort
Expand All @@ -538,12 +536,6 @@ format in a more detailed manner, there are a [wide number of options
available](std/fmt/index.html). For now, we'll just stick to the default:
integers aren't very complicated to print.

So, we've cleared up all of the confusion around bindings, with one exception:
why does Rust let us declare a variable binding without an initial value if we
must initialize the binding before we use it? And how does it know that we have
or have not initialized the binding? For that, we need to learn our next
concept: `if`.

# If

Rust's take on `if` is not particularly complex, but it's much more like the
Expand Down Expand Up @@ -582,7 +574,6 @@ if x == 5i {

This is all pretty standard. However, you can also do this:


```
let x = 5i;

Expand Down
14 changes: 8 additions & 6 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -3290,17 +3290,19 @@ between `_` and `..` is that the pattern `C(_)` is only type-correct if `C` has
exactly one argument, while the pattern `C(..)` is type-correct for any enum
variant `C`, regardless of how many arguments `C` has.

Used inside a vector pattern, `..` stands for any number of elements. This
wildcard can be used at most once for a given vector, which implies that it
cannot be used to specifically match elements that are at an unknown distance
from both ends of a vector, like `[.., 42, ..]`. If followed by a variable name,
it will bind the corresponding slice to the variable. Example:
Used inside a vector pattern, `..` stands for any number of elements, when the
`advanced_slice_patterns` feature gate is turned on. This wildcard can be used
at most once for a given vector, which implies that it cannot be used to
specifically match elements that are at an unknown distance from both ends of a
vector, like `[.., 42, ..]`. If followed by a variable name, it will bind the
corresponding slice to the variable. Example:

~~~~
# #![feature(advanced_slice_patterns)]
fn is_symmetric(list: &[uint]) -> bool {
match list {
[] | [_] => true,
[x, ..inside, y] if x == y => is_symmetric(inside),
[x, inside.., y] if x == y => is_symmetric(inside),
_ => false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ let score = match numbers {
[] => 0,
[a] => a * 10,
[a, b] => a * 6 + b * 4,
[a, b, c, ..rest] => a * 5 + b * 3 + c * 2 + rest.len() as int
[a, b, c, rest..] => a * 5 + b * 3 + c * 2 + rest.len() as int
};
~~~~

Expand Down
3 changes: 3 additions & 0 deletions src/etc/licenseck.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@
"libsync/mpmc_bounded_queue.rs", # BSD
"libsync/mpsc_intrusive.rs", # BSD
"test/bench/shootout-binarytrees.rs", # BSD
"test/bench/shootout-chameneos-redux.rs", # BSD
"test/bench/shootout-fannkuch-redux.rs", # BSD
"test/bench/shootout-k-nucleotide.rs", # BSD
"test/bench/shootout-mandelbrot.rs", # BSD
"test/bench/shootout-meteor.rs", # BSD
"test/bench/shootout-nbody.rs", # BSD
"test/bench/shootout-pidigits.rs", # BSD
"test/bench/shootout-regex-dna.rs", # BSD
"test/bench/shootout-reverse-complement.rs", # BSD
"test/bench/shootout-threadring.rs", # BSD
]

Expand Down
2 changes: 2 additions & 0 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ mod tests {
use self::test::Bencher;
use super::{Arena, TypedArena};

#[allow(dead_code)]
struct Point {
x: int,
y: int,
Expand Down Expand Up @@ -564,6 +565,7 @@ mod tests {
})
}

#[allow(dead_code)]
struct Noncopy {
string: String,
array: Vec<int>,
Expand Down
12 changes: 10 additions & 2 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_tailn() {
let mut a = vec![11i, 12, 13];
let b: &[int] = &[11, 12, 13];
Expand All @@ -875,6 +876,7 @@ mod tests {

#[test]
#[should_fail]
#[allow(deprecated)]
fn test_tailn_empty() {
let a: Vec<int> = vec![];
a.tailn(2);
Expand Down Expand Up @@ -909,6 +911,7 @@ mod tests {

#[test]
#[should_fail]
#[allow(deprecated)]
fn test_initn_empty() {
let a: Vec<int> = vec![];
a.as_slice().initn(2);
Expand Down Expand Up @@ -1466,6 +1469,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_unshift() {
let mut x = vec![1i, 2, 3];
x.unshift(0);
Expand Down Expand Up @@ -2079,6 +2083,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_shift_ref() {
let mut x: &[int] = [1, 2, 3, 4, 5];
let h = x.shift_ref();
Expand All @@ -2092,6 +2097,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_pop_ref() {
let mut x: &[int] = [1, 2, 3, 4, 5];
let h = x.pop_ref();
Expand Down Expand Up @@ -2171,6 +2177,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_mut_shift_ref() {
let mut x: &mut [int] = [1, 2, 3, 4, 5];
let h = x.mut_shift_ref();
Expand All @@ -2184,6 +2191,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_mut_pop_ref() {
let mut x: &mut [int] = [1, 2, 3, 4, 5];
let h = x.mut_pop_ref();
Expand Down Expand Up @@ -2441,7 +2449,7 @@ mod bench {
b.iter(|| {
v.sort();
});
b.bytes = (v.len() * mem::size_of_val(v.get(0))) as u64;
b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
}

type BigSortable = (u64,u64,u64,u64);
Expand Down Expand Up @@ -2485,6 +2493,6 @@ mod bench {
b.iter(|| {
v.sort();
});
b.bytes = (v.len() * mem::size_of_val(v.get(0))) as u64;
b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
}
}
2 changes: 1 addition & 1 deletion src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,7 @@ pub type Iterate<'a, T> = Unfold<'a, T, IterateState<'a, T>>;
/// Creates a new iterator that produces an infinite sequence of
/// repeated applications of the given function `f`.
#[allow(visible_private_types)]
pub fn iterate<'a, T: Clone>(f: |T|: 'a -> T, seed: T) -> Iterate<'a, T> {
pub fn iterate<'a, T: Clone>(seed: T, f: |T|: 'a -> T) -> Iterate<'a, T> {
Unfold::new((f, Some(seed), true), |st| {
let &(ref mut f, ref mut val, ref mut first) = st;
if *first {
Expand Down
6 changes: 4 additions & 2 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
*
*/

use kinds::Sized;

/**
*
* The `Drop` trait is used to run some code when a value goes out of scope. This
Expand Down Expand Up @@ -700,7 +702,7 @@ pub trait IndexMut<Index,Result> {
* ```
*/
#[lang="deref"]
pub trait Deref<Result> {
pub trait Deref<Sized? Result> {
/// The method called to dereference a value
fn deref<'a>(&'a self) -> &'a Result;
}
Expand Down Expand Up @@ -740,7 +742,7 @@ pub trait Deref<Result> {
* ```
*/
#[lang="deref_mut"]
pub trait DerefMut<Result>: Deref<Result> {
pub trait DerefMut<Sized? Result>: Deref<Result> {
/// The method called to mutably dereference a value
fn deref_mut<'a>(&'a mut self) -> &'a mut Result;
}
Expand Down
24 changes: 12 additions & 12 deletions src/libcoretest/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,61 +51,61 @@ fn any_owning() {
}

#[test]
fn any_as_ref() {
fn any_downcast_ref() {
let a = &5u as &Any;

match a.as_ref::<uint>() {
match a.downcast_ref::<uint>() {
Some(&5) => {}
x => fail!("Unexpected value {}", x)
}

match a.as_ref::<Test>() {
match a.downcast_ref::<Test>() {
None => {}
x => fail!("Unexpected value {}", x)
}
}

#[test]
fn any_as_mut() {
fn any_downcast_mut() {
let mut a = 5u;
let mut b = box 7u;

let a_r = &mut a as &mut Any;
let tmp: &mut uint = &mut *b;
let b_r = tmp as &mut Any;

match a_r.as_mut::<uint>() {
match a_r.downcast_mut::<uint>() {
Some(x) => {
assert_eq!(*x, 5u);
*x = 612;
}
x => fail!("Unexpected value {}", x)
}

match b_r.as_mut::<uint>() {
match b_r.downcast_mut::<uint>() {
Some(x) => {
assert_eq!(*x, 7u);
*x = 413;
}
x => fail!("Unexpected value {}", x)
}

match a_r.as_mut::<Test>() {
match a_r.downcast_mut::<Test>() {
None => (),
x => fail!("Unexpected value {}", x)
}

match b_r.as_mut::<Test>() {
match b_r.downcast_mut::<Test>() {
None => (),
x => fail!("Unexpected value {}", x)
}

match a_r.as_mut::<uint>() {
match a_r.downcast_mut::<uint>() {
Some(&612) => {}
x => fail!("Unexpected value {}", x)
}

match b_r.as_mut::<uint>() {
match b_r.downcast_mut::<uint>() {
Some(&413) => {}
x => fail!("Unexpected value {}", x)
}
Expand All @@ -121,11 +121,11 @@ fn any_fixed_vec() {


#[bench]
fn bench_as_ref(b: &mut Bencher) {
fn bench_downcast_ref(b: &mut Bencher) {
b.iter(|| {
let mut x = 0i;
let mut y = &mut x as &mut Any;
test::black_box(&mut y);
test::black_box(y.as_ref::<int>() == Some(&0));
test::black_box(y.downcast_ref::<int>() == Some(&0));
});
}
2 changes: 1 addition & 1 deletion src/libcoretest/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ fn test_min_max_result() {

#[test]
fn test_iterate() {
let mut it = iterate(|x| x * 2, 1u);
let mut it = iterate(1u, |x| x * 2);
assert_eq!(it.next(), Some(1u));
assert_eq!(it.next(), Some(2u));
assert_eq!(it.next(), Some(4u));
Expand Down
3 changes: 3 additions & 0 deletions src/libcoretest/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ fn test_or_else() {
}

#[test]
#[allow(deprecated)]
fn test_option_while_some() {
let mut i = 0i;
Some(10i).while_some(|j| {
Expand Down Expand Up @@ -184,6 +185,7 @@ fn test_unwrap_or_else() {
}

#[test]
#[allow(deprecated)]
fn test_filtered() {
let some_stuff = Some(42i);
let modified_stuff = some_stuff.filtered(|&x| {x < 10});
Expand Down Expand Up @@ -256,6 +258,7 @@ fn test_mutate() {
}

#[test]
#[allow(deprecated)]
fn test_collect() {
let v: Option<Vec<int>> = collect(range(0i, 0)
.map(|_| Some(0i)));
Expand Down
1 change: 1 addition & 0 deletions src/libcoretest/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub fn test_impl_map_err() {
}

#[test]
#[allow(deprecated)]
fn test_collect() {
let v: Result<Vec<int>, ()> = collect(range(0i, 0).map(|_| Ok::<int, ()>(0)));
assert!(v == Ok(vec![]));
Expand Down
1 change: 1 addition & 0 deletions src/libdebug/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ pub fn repr_to_string<T>(t: &T) -> String {
}

#[cfg(test)]
#[allow(dead_code)]
struct P {a: int, b: f64}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,9 @@ mod tests {
id_name(n)
}
fn node_label(&'a self, n: &Node) -> LabelText<'a> {
match self.node_labels.get(*n) {
&Some(ref l) => LabelStr(str::Slice(l.as_slice())),
&None => LabelStr(id_name(n).name()),
match self.node_labels[*n] {
Some(ref l) => LabelStr(str::Slice(l.as_slice())),
None => LabelStr(id_name(n).name()),
}
}
fn edge_label(&'a self, e: & &'a Edge) -> LabelText<'a> {
Expand Down
1 change: 1 addition & 0 deletions src/libgreen/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,7 @@ mod test {
// Regression test that the `start` task entrypoint can
// contain dtors that use task resources
run(proc() {
#[allow(dead_code)]
struct S { field: () }

impl Drop for S {
Expand Down
Loading