Skip to content

Commit e233987

Browse files
committed
Auto merge of rust-lang#22860 - Manishearth:rollup, r=alexcrichton
Passes check-stage1, check-stage2
2 parents bd0d8e4 + bde4c1d commit e233987

Some content is hidden

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

57 files changed

+952
-131
lines changed

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

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.

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
}

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;

src/libcollections/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,15 +2093,15 @@ mod tests {
20932093
let (left, right) = values.split_at_mut(2);
20942094
{
20952095
let left: &[_] = left;
2096-
assert!(&left[..left.len()] == &[1, 2][]);
2096+
assert!(&left[..left.len()] == &[1, 2]);
20972097
}
20982098
for p in left {
20992099
*p += 1;
21002100
}
21012101

21022102
{
21032103
let right: &[_] = right;
2104-
assert!(&right[..right.len()] == &[3, 4, 5][]);
2104+
assert!(&right[..right.len()] == &[3, 4, 5]);
21052105
}
21062106
for p in right {
21072107
*p += 2;

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)

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

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

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
}

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
}

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

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]);

src/librand/reseeding.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ pub trait Reseeder<R> {
134134
/// Reseed an RNG using a `Default` instance. This reseeds by
135135
/// replacing the RNG with the result of a `Default::default` call.
136136
#[derive(Copy)]
137-
pub struct ReseedWithDefault { __hack: [u8; 0] }
138-
// FIXME(#21721) used to be an unit struct but that can cause
139-
// certain LLVM versions to abort during optimizations.
140-
#[allow(non_upper_case_globals)]
141-
pub const ReseedWithDefault: ReseedWithDefault = ReseedWithDefault { __hack: [] };
137+
pub struct ReseedWithDefault;
142138

143139
impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
144140
fn reseed(&mut self, rng: &mut R) {

src/librustc/lint/builtin.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,11 @@ impl LintPass for Stability {
17711771
stability::check_path(cx.tcx, path, id,
17721772
&mut |id, sp, stab| self.lint(cx, id, sp, stab));
17731773
}
1774+
1775+
fn check_pat(&mut self, cx: &Context, pat: &ast::Pat) {
1776+
stability::check_pat(cx.tcx, pat,
1777+
&mut |id, sp, stab| self.lint(cx, id, sp, stab))
1778+
}
17741779
}
17751780

17761781
declare_lint! {

src/librustc/middle/astconv_util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
6868
Some(d) => d.full_def()
6969
};
7070
if let def::DefPrimTy(nty) = def {
71-
Some(prim_ty_to_ty(tcx, &path.segments[], nty))
71+
Some(prim_ty_to_ty(tcx, &path.segments, nty))
7272
} else {
7373
None
7474
}
7575
} else {
7676
None
7777
}
7878
}
79-

0 commit comments

Comments
 (0)