Skip to content

Commit 9eecd32

Browse files
committed
---
yaml --- r: 187897 b: refs/heads/tmp c: a0f5ed9 h: refs/heads/master i: 187895: d75233c v: v3
1 parent 0ec012d commit 9eecd32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3625
-2368
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: ad1489195763b5f2603675dc75b0d86d903333db
37+
refs/heads/tmp: a0f5ed957accd7623efcbbfa351a8024c699ff76
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/mk/crates.mk

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TARGET_CRATES := libc std flate arena term \
5454
log graphviz core rbml alloc \
5555
unicode rustc_bitflags
5656
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
57-
rustc_trans rustc_back rustc_llvm rustc_privacy
57+
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint
5858
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
5959
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
6060
TOOLS := compiletest rustdoc rustc rustbook
@@ -70,20 +70,21 @@ DEPS_graphviz := std
7070
DEPS_syntax := std term serialize log fmt_macros arena libc
7171
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
7272
rustc_typeck rustc_resolve log syntax serialize rustc_llvm \
73-
rustc_trans rustc_privacy
73+
rustc_trans rustc_privacy rustc_lint
7474

7575
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
7676
log syntax serialize rustc_llvm
7777
DEPS_rustc_typeck := rustc syntax
7878
DEPS_rustc_borrowck := rustc log graphviz syntax
7979
DEPS_rustc_resolve := rustc log syntax
8080
DEPS_rustc_privacy := rustc log syntax
81+
DEPS_rustc_lint := rustc log syntax
8182
DEPS_rustc := syntax flate arena serialize getopts rbml \
8283
log graphviz rustc_llvm rustc_back
8384
DEPS_rustc_llvm := native:rustllvm libc std
8485
DEPS_rustc_back := std syntax rustc_llvm flate log libc
8586
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
86-
test
87+
test rustc_lint
8788
DEPS_rustc_bitflags := core
8889
DEPS_flate := std native:miniz
8990
DEPS_arena := std
@@ -128,11 +129,13 @@ DOC_CRATES := $(filter-out rustc, \
128129
$(filter-out rustc_resolve, \
129130
$(filter-out rustc_driver, \
130131
$(filter-out rustc_privacy, \
132+
$(filter-out rustc_lint, \
131133
$(filter-out log, \
132134
$(filter-out getopts, \
133-
$(filter-out syntax, $(CRATES)))))))))))
135+
$(filter-out syntax, $(CRATES))))))))))))
134136
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
135-
rustc_typeck rustc_driver syntax rustc_privacy
137+
rustc_typeck rustc_driver syntax rustc_privacy \
138+
rustc_lint
136139

137140
# This macro creates some simple definitions for each crate being built, just
138141
# some munging of all of the parameters above.

branches/tmp/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $(eval $(call RUST_CRATE,coretest))
2121

2222
TEST_TARGET_CRATES = $(filter-out core unicode,$(TARGET_CRATES)) coretest
2323
TEST_DOC_CRATES = $(DOC_CRATES)
24-
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans,\
24+
TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve rustc_trans rustc_lint,\
2525
$(HOST_CRATES))
2626
TEST_CRATES = $(TEST_TARGET_CRATES) $(TEST_HOST_CRATES)
2727

branches/tmp/src/doc/reference.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ nonzero_dec: '1' | '2' | '3' | '4'
302302

303303
A _character literal_ is a single Unicode character enclosed within two
304304
`U+0027` (single-quote) characters, with the exception of `U+0027` itself,
305-
which must be _escaped_ by a preceding U+005C character (`\`).
305+
which must be _escaped_ by a preceding `U+005C` character (`\`).
306306

307307
##### String literals
308308

@@ -311,6 +311,19 @@ A _string literal_ is a sequence of any Unicode characters enclosed within two
311311
which must be _escaped_ by a preceding `U+005C` character (`\`), or a _raw
312312
string literal_.
313313

314+
A multi-line string literal may be defined by terminating each line with a
315+
`U+005C` character (`\`) immediately before the newline. This causes the
316+
`U+005C` character, the newline, and all whitespace at the beginning of the
317+
next line to be ignored.
318+
319+
```rust
320+
let a = "foobar";
321+
let b = "foo\
322+
bar";
323+
324+
assert_eq!(a,b);
325+
```
326+
314327
##### Character escapes
315328

316329
Some additional _escapes_ are available in either character or non-raw string

branches/tmp/src/doc/trpl/hello-cargo.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ the Cargo
1818
README](https://github.com/rust-lang/cargo#installing-cargo-from-nightlies)
1919
for specific instructions about installing it.
2020

21+
## Converting to Cargo
22+
2123
Let's convert Hello World to Cargo.
2224

2325
To Cargo-ify our project, we need to do two things: Make a `Cargo.toml`
2426
configuration file, and put our source file in the right place. Let's
2527
do that part first:
2628

27-
```{bash}
29+
```bash
2830
$ mkdir src
2931
$ mv main.rs src/main.rs
3032
```
@@ -36,7 +38,7 @@ place for everything, and everything in its place.
3638

3739
Next, our configuration file:
3840

39-
```{bash}
41+
```bash
4042
$ editor Cargo.toml
4143
```
4244

@@ -73,7 +75,7 @@ well as what it is named.
7375

7476
Once you have this file in place, we should be ready to build! Try this:
7577

76-
```{bash}
78+
```bash
7779
$ cargo build
7880
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
7981
$ ./target/hello_world
@@ -103,6 +105,62 @@ That's it! We've successfully built `hello_world` with Cargo. Even though our
103105
program is simple, it's using much of the real tooling that you'll use for the
104106
rest of your Rust career.
105107

108+
## A New Project
109+
110+
You don't have to go through this whole process every time you want to start a new
111+
project! Cargo has the ability to make a bare-bones project directory in which you
112+
can start developing right away.
113+
114+
To start a new project with Cargo, use `cargo new`:
115+
116+
```bash
117+
$ cargo new hello_world --bin
118+
```
119+
120+
We're passing `--bin` because we're making a binary program: if we
121+
were making a library, we'd leave it off.
122+
123+
Let's check out what Cargo has generated for us:
124+
125+
```bash
126+
$ cd hello_world
127+
$ tree .
128+
.
129+
├── Cargo.toml
130+
└── src
131+
└── main.rs
132+
133+
1 directory, 2 files
134+
```
135+
136+
If you don't have the `tree` command, you can probably get it from your distro's package
137+
manager. It's not necessary, but it's certainly useful.
138+
139+
This is all we need to get started. First, let's check out `Cargo.toml`:
140+
141+
```toml
142+
[package]
143+
144+
name = "hello_world"
145+
version = "0.0.1"
146+
authors = ["Your Name <[email protected]>"]
147+
```
148+
149+
Cargo has populated this file with reasonable defaults based off the arguments you gave
150+
it and your `git` global configuration. You may notice that Cargo has also initialized
151+
the `hello_world` directory as a `git` repository.
152+
153+
Here's what's in `src/main.rs`:
154+
155+
```rust
156+
fn main() {
157+
println!("Hello, world!");
158+
}
159+
```
160+
161+
Cargo has generated a "Hello World!" for us, and you're ready to start coding! A
162+
much more in-depth guide to Cargo can be found [here](http://doc.crates.io/guide.html).
163+
106164
Now that you've got the tools down, let's actually learn more about the Rust
107165
language itself. These are the basics that will serve you well through the rest
108-
of your time with Rust.
166+
of your time with Rust.

branches/tmp/src/liballoc/heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ mod imp {
300300
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
301301
} else {
302302
let new_ptr = allocate(size, align);
303-
ptr::copy_memory(new_ptr, ptr, cmp::min(size, old_size));
303+
ptr::copy(new_ptr, ptr, cmp::min(size, old_size));
304304
deallocate(ptr, old_size, align);
305305
new_ptr
306306
}

branches/tmp/src/libcollections/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,15 +2663,15 @@ mod tests {
26632663
let (left, right) = values.split_at_mut(2);
26642664
{
26652665
let left: &[_] = left;
2666-
assert!(left[..left.len()] == [1, 2][]);
2666+
assert!(left[..left.len()] == [1, 2]);
26672667
}
26682668
for p in left {
26692669
*p += 1;
26702670
}
26712671

26722672
{
26732673
let right: &[_] = right;
2674-
assert!(right[..right.len()] == [3, 4, 5][]);
2674+
assert!(right[..right.len()] == [3, 4, 5]);
26752675
}
26762676
for p in right {
26772677
*p += 2;

branches/tmp/src/libcollections/vec.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,10 @@ impl<T> Vec<T> {
433433
#[stable(feature = "rust1", since = "1.0.0")]
434434
pub fn as_mut_slice(&mut self) -> &mut [T] {
435435
unsafe {
436+
let ptr = *self.ptr;
437+
assume(!ptr.is_null());
436438
mem::transmute(RawSlice {
437-
data: *self.ptr,
439+
data: ptr,
438440
len: self.len,
439441
})
440442
}
@@ -458,6 +460,7 @@ impl<T> Vec<T> {
458460
pub fn into_iter(self) -> IntoIter<T> {
459461
unsafe {
460462
let ptr = *self.ptr;
463+
assume(!ptr.is_null());
461464
let cap = self.cap;
462465
let begin = ptr as *const T;
463466
let end = if mem::size_of::<T>() == 0 {
@@ -2093,15 +2096,15 @@ mod tests {
20932096
let (left, right) = values.split_at_mut(2);
20942097
{
20952098
let left: &[_] = left;
2096-
assert!(&left[..left.len()] == &[1, 2][]);
2099+
assert!(&left[..left.len()] == &[1, 2]);
20972100
}
20982101
for p in left {
20992102
*p += 1;
21002103
}
21012104

21022105
{
21032106
let right: &[_] = right;
2104-
assert!(&right[..right.len()] == &[3, 4, 5][]);
2107+
assert!(&right[..right.len()] == &[3, 4, 5]);
21052108
}
21062109
for p in right {
21072110
*p += 2;

branches/tmp/src/libcore/intrinsics.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,12 @@ extern "rust-intrinsic" {
241241
/// will trigger a compiler error.
242242
pub fn return_address() -> *const u8;
243243

244-
/// Returns `true` if a type requires drop glue.
244+
/// Returns `true` if the actual type given as `T` requires drop
245+
/// glue; returns `false` if the actual type provided for `T`
246+
/// implements `Copy`.
247+
///
248+
/// If the actual type neither requires drop glue nor implements
249+
/// `Copy`, then may return `true` or `false`.
245250
pub fn needs_drop<T>() -> bool;
246251

247252
/// Returns `true` if a type is managed (will be allocated on the local heap)

branches/tmp/src/libcore/iter.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ pub trait IteratorExt: Iterator + Sized {
171171
self.fold(0, |cnt, _x| cnt + 1)
172172
}
173173

174-
/// Loops through the entire iterator, returning the last element of the
175-
/// iterator.
174+
/// Loops through the entire iterator, returning the last element.
176175
///
177176
/// # Examples
178177
///
@@ -637,8 +636,8 @@ pub trait IteratorExt: Iterator + Sized {
637636
/// ```
638637
#[inline]
639638
#[stable(feature = "rust1", since = "1.0.0")]
640-
fn all<F>(self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
641-
for x in self { if !f(x) { return false; } }
639+
fn all<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
640+
for x in self.by_ref() { if !f(x) { return false; } }
642641
true
643642
}
644643

@@ -1637,8 +1636,6 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool
16371636
for x in self.iter.by_ref() {
16381637
if (self.predicate)(&x) {
16391638
return Some(x);
1640-
} else {
1641-
continue
16421639
}
16431640
}
16441641
None

branches/tmp/src/libcore/marker.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ macro_rules! impls{
275275
/// any methods, but instead is used to gate access to data.
276276
///
277277
/// FIXME. Better documentation needed here!
278-
pub trait MarkerTrait : PhantomFn<Self> { }
278+
pub trait MarkerTrait : PhantomFn<Self,Self> { }
279+
// ~~~~~ <-- FIXME(#22806)?
280+
//
281+
// Marker trait has been made invariant so as to avoid inf recursion,
282+
// but we should ideally solve the underlying problem. That's a bit
283+
// complicated.
284+
279285
impl<T:?Sized> MarkerTrait for T { }
280286

281287
/// `PhantomFn` is a marker trait for use with traits that contain

branches/tmp/src/libcore/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ impl<T, E> Result<T, E> {
641641
/// ```
642642
#[inline]
643643
#[stable(feature = "rust1", since = "1.0.0")]
644-
pub fn or(self, res: Result<T, E>) -> Result<T, E> {
644+
pub fn or<F>(self, res: Result<T, F>) -> Result<T, F> {
645645
match self {
646-
Ok(_) => self,
646+
Ok(v) => Ok(v),
647647
Err(_) => res,
648648
}
649649
}

branches/tmp/src/libcore/slice.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use cmp::{Ordering, PartialEq, PartialOrd, Eq, Ord};
4040
use cmp::Ordering::{Less, Equal, Greater};
4141
use cmp;
4242
use default::Default;
43+
use intrinsics::assume;
4344
use iter::*;
4445
use ops::{FnMut, self, Index};
4546
use ops::RangeFull;
@@ -137,6 +138,7 @@ impl<T> SliceExt for [T] {
137138
fn iter<'a>(&'a self) -> Iter<'a, T> {
138139
unsafe {
139140
let p = self.as_ptr();
141+
assume(!p.is_null());
140142
if mem::size_of::<T>() == 0 {
141143
Iter {ptr: p,
142144
end: (p as usize + self.len()) as *const T,
@@ -276,6 +278,7 @@ impl<T> SliceExt for [T] {
276278
fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
277279
unsafe {
278280
let p = self.as_mut_ptr();
281+
assume(!p.is_null());
279282
if mem::size_of::<T>() == 0 {
280283
IterMut {ptr: p,
281284
end: (p as usize + self.len()) as *mut T,

branches/tmp/src/libcore/str/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> {
939939
type Item = &'a str;
940940

941941
#[inline]
942+
#[allow(deprecated)]
942943
fn next(&mut self) -> Option<&'a str> {
943944
Iterator::next(&mut self.0)
944945
}

branches/tmp/src/libcoretest/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ pub fn test_and_then() {
3636

3737
#[test]
3838
pub fn test_or() {
39-
assert_eq!(op1().or(Ok(667)).unwrap(), 666);
39+
assert_eq!(op1().or(Ok::<_, &'static str>(667)).unwrap(), 666);
4040
assert_eq!(op1().or(Err("bad")).unwrap(), 666);
4141

42-
assert_eq!(op2().or(Ok(667)).unwrap(), 667);
42+
assert_eq!(op2().or(Ok::<_, &'static str>(667)).unwrap(), 667);
4343
assert_eq!(op2().or(Err("bad")).unwrap_err(), "bad");
4444
}
4545

branches/tmp/src/libcoretest/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ fn iterator_to_slice() {
5959
let mut iter = data.iter_mut();
6060
assert_eq!(&iter[..], &other_data[..]);
6161
// mutability:
62-
assert!(&mut iter[] == other_data);
62+
assert!(&mut iter[..] == other_data);
6363

6464
iter.next();
6565
assert_eq!(&iter[..], &other_data[1..]);
66-
assert!(&mut iter[] == &mut other_data[1..]);
66+
assert!(&mut iter[..] == &mut other_data[1..]);
6767

6868
iter.next_back();
6969

7070
assert_eq!(&iter[..], &other_data[1..2]);
71-
assert!(&mut iter[] == &mut other_data[1..2]);
71+
assert!(&mut iter[..] == &mut other_data[1..2]);
7272

7373
let s = iter.into_slice();
7474
assert!(s == &mut other_data[1..2]);

0 commit comments

Comments
 (0)