Skip to content

Commit 5b3cd39

Browse files
committed
auto merge of #20733 : alexcrichton/rust/rollup, r=alexcrichton
2 parents 9f1ead8 + 0abf458 commit 5b3cd39

File tree

809 files changed

+6281
-4795
lines changed

Some content is hidden

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

809 files changed

+6281
-4795
lines changed

configure

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,18 @@ then
599599
fi
600600
putvar CFG_RELEASE_CHANNEL
601601

602+
# A magic value that allows the compiler to use unstable features
603+
# during the bootstrap even when doing so would normally be an error
604+
# because of feature staging or because the build turns on
605+
# warnings-as-errors and unstable features default to warnings. The
606+
# build has to match this key in an env var. Meant to be a mild
607+
# deterrent from users just turning on unstable features on the stable
608+
# channel.
609+
# Basing CFG_BOOTSTRAP_KEY on CFG_BOOTSTRAP_KEY lets it get picked up
610+
# during a Makefile reconfig.
611+
CFG_BOOTSTRAP_KEY="${CFG_BOOTSTRAP_KEY-`date +%N`}"
612+
putvar CFG_BOOTSTRAP_KEY
613+
602614
step_msg "looking for build programs"
603615

604616
probe_need CFG_PERL perl

mk/main.mk

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ ifeq ($(CFG_RELEASE_CHANNEL),stable)
2525
CFG_RELEASE=$(CFG_RELEASE_NUM)
2626
# This is the string used in dist artifact file names, e.g. "0.12.0", "nightly"
2727
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)
28+
CFG_DISABLE_UNSTABLE_FEATURES=1
2829
endif
2930
ifeq ($(CFG_RELEASE_CHANNEL),beta)
3031
# The beta channel is temporarily called 'alpha'
3132
CFG_RELEASE=$(CFG_RELEASE_NUM)-alpha$(CFG_BETA_CYCLE)
3233
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-alpha$(CFG_BETA_CYCLE)
34+
CFG_DISABLE_UNSTABLE_FEATURES=1
3335
endif
3436
ifeq ($(CFG_RELEASE_CHANNEL),nightly)
3537
CFG_RELEASE=$(CFG_RELEASE_NUM)-nightly
@@ -121,11 +123,9 @@ CFG_JEMALLOC_FLAGS += $(JEMALLOC_FLAGS)
121123

122124
ifdef CFG_DISABLE_DEBUG
123125
CFG_RUSTC_FLAGS += --cfg ndebug
124-
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
125126
else
126127
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
127128
CFG_RUSTC_FLAGS += --cfg debug
128-
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
129129
endif
130130

131131
ifdef SAVE_TEMPS
@@ -319,11 +319,20 @@ export CFG_VERSION_WIN
319319
export CFG_RELEASE
320320
export CFG_PACKAGE_NAME
321321
export CFG_BUILD
322+
export CFG_RELEASE_CHANNEL
322323
export CFG_LLVM_ROOT
323324
export CFG_PREFIX
324325
export CFG_LIBDIR
325326
export CFG_LIBDIR_RELATIVE
326327
export CFG_DISABLE_INJECT_STD_VERSION
328+
ifdef CFG_DISABLE_UNSTABLE_FEATURES
329+
CFG_INFO := $(info cfg: disabling unstable features (CFG_DISABLE_UNSTABLE_FEATURES))
330+
# Turn on feature-staging
331+
export CFG_DISABLE_UNSTABLE_FEATURES
332+
endif
333+
# Subvert unstable feature lints to do the self-build
334+
export CFG_BOOTSTRAP_KEY
335+
export RUSTC_BOOTSTRAP_KEY:=$(CFG_BOOTSTRAP_KEY)
327336

328337
######################################################################
329338
# Per-stage targets and runner

src/compiletest/compiletest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
// except according to those terms.
1010

1111
#![crate_type = "bin"]
12+
#![allow(unknown_features)]
1213
#![feature(slicing_syntax, unboxed_closures)]
14+
#![feature(box_syntax)]
1315

1416
#![deny(warnings)]
1517

src/compiletest/runtest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,7 @@ fn check_error_patterns(props: &TestProps,
908908
}
909909
if done { return; }
910910

911-
let missing_patterns =
912-
props.error_patterns.index(&(next_err_idx..));
911+
let missing_patterns = &props.error_patterns[next_err_idx..];
913912
if missing_patterns.len() == 1u {
914913
fatal_proc_rec(format!("error pattern '{}' not found!",
915914
missing_patterns[0]).as_slice(),

src/doc/footer.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<footer><p>
2-
Copyright &copy; 2011-2014 The Rust Project Developers. Licensed under the
2+
Copyright &copy; 2011-2015 The Rust Project Developers. Licensed under the
33
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
44
or the <a href="http://opensource.org/licenses/MIT">MIT license</a>, at your option.
55
</p><p>

src/doc/guide-error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ for all but the most trivial of situations.
147147
Here's an example of using `Result`:
148148

149149
```rust
150-
#[deriving(Show)]
150+
#[derive(Show)]
151151
enum Version { Version1, Version2 }
152152

153-
#[deriving(Show)]
153+
#[derive(Show)]
154154
enum ParseError { InvalidHeaderLength, InvalidVersion }
155155

156156
fn parse_version(header: &[u8]) -> Result<Version, ParseError> {

src/doc/guide-ffi.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ referenced Rust object.
262262
Rust code:
263263
264264
~~~~no_run
265+
# use std::boxed::Box;
265266
266267
#[repr(C)]
267268
struct RustObject {
@@ -286,7 +287,7 @@ extern {
286287
287288
fn main() {
288289
// Create the object that will be referenced in the callback
289-
let mut rust_object = box RustObject { a: 5 };
290+
let mut rust_object = Box::new(RustObject { a: 5 });
290291
291292
unsafe {
292293
register_callback(&mut *rust_object, callback);

src/doc/guide-ownership.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,29 @@ therefore deallocates the memory for you. Here's the equivalent example in
8181
Rust:
8282

8383
```rust
84+
# use std::boxed::Box;
8485
{
85-
let x = box 5i;
86+
let x = Box::new(5i);
8687
}
8788
```
8889

89-
The `box` keyword creates a `Box<T>` (specifically `Box<int>` in this case) by
90-
allocating a small segment of memory on the heap with enough space to fit an
91-
`int`. But where in the code is the box deallocated? We said before that we
92-
must have a deallocation for each allocation. Rust handles this for you. It
90+
The `Box::new` function creates a `Box<T>` (specifically `Box<int>` in this
91+
case) by allocating a small segment of memory on the heap with enough space to
92+
fit an `int`. But where in the code is the box deallocated? We said before that
93+
we must have a deallocation for each allocation. Rust handles this for you. It
9394
knows that our handle, `x`, is the owning reference to our box. Rust knows that
9495
`x` will go out of scope at the end of the block, and so it inserts a call to
9596
deallocate the memory at the end of the scope. Because the compiler does this
96-
for us, it's impossible to forget. We always have exactly one deallocation paired
97-
with each of our allocations.
97+
for us, it's impossible to forget. We always have exactly one deallocation
98+
paired with each of our allocations.
9899

99100
This is pretty straightforward, but what happens when we want to pass our box
100101
to a function? Let's look at some code:
101102

102103
```rust
104+
# use std::boxed::Box;
103105
fn main() {
104-
let x = box 5i;
106+
let x = Box::new(5i);
105107

106108
add_one(x);
107109
}
@@ -115,8 +117,9 @@ This code works, but it's not ideal. For example, let's add one more line of
115117
code, where we print out the value of `x`:
116118

117119
```{rust,ignore}
120+
# use std::boxed::Box;
118121
fn main() {
119-
let x = box 5i;
122+
let x = Box::new(5i);
120123
121124
add_one(x);
122125
@@ -148,8 +151,9 @@ To fix this, we can have `add_one` give ownership back when it's done with the
148151
box:
149152

150153
```rust
154+
# use std::boxed::Box;
151155
fn main() {
152-
let x = box 5i;
156+
let x = Box::new(5i);
153157

154158
let y = add_one(x);
155159

@@ -458,7 +462,7 @@ lifetime, and so if you elide a lifetime (like `&T` instead of `&'a T`), Rust
458462
will do three things to determine what those lifetimes should be.
459463

460464
When talking about lifetime elision, we use the term 'input lifetime' and
461-
'output lifetime'. An 'input liftime' is a lifetime associated with a parameter
465+
'output lifetime'. An 'input lifetime' is a lifetime associated with a parameter
462466
of a function, and an 'output lifetime' is a lifetime associated with the return
463467
value of a function. For example, this function has an input lifetime:
464468

src/doc/guide-pointers.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,13 @@ fn rc_succ(x: Rc<int>) -> int { *x + 1 }
455455
Note that the caller of your function will have to modify their calls slightly:
456456

457457
```{rust}
458+
# use std::boxed::Box;
458459
use std::rc::Rc;
459460
460461
fn succ(x: &int) -> int { *x + 1 }
461462
462463
let ref_x = &5i;
463-
let box_x = box 5i;
464+
let box_x = Box::new(5i);
464465
let rc_x = Rc::new(5i);
465466
466467
succ(ref_x);
@@ -477,24 +478,17 @@ those contents.
477478
heap allocation in Rust. Creating a box looks like this:
478479

479480
```{rust}
480-
let x = box(std::boxed::HEAP) 5i;
481+
# use std::boxed::Box;
482+
let x = Box::new(5i);
481483
```
482484

483-
`box` is a keyword that does 'placement new,' which we'll talk about in a bit.
484-
`box` will be useful for creating a number of heap-allocated types, but is not
485-
quite finished yet. In the meantime, `box`'s type defaults to
486-
`std::boxed::HEAP`, and so you can leave it off:
487-
488-
```{rust}
489-
let x = box 5i;
490-
```
491-
492-
As you might assume from the `HEAP`, boxes are heap allocated. They are
493-
deallocated automatically by Rust when they go out of scope:
485+
Boxes are heap allocated and they are deallocated automatically by Rust when
486+
they go out of scope:
494487

495488
```{rust}
489+
# use std::boxed::Box;
496490
{
497-
let x = box 5i;
491+
let x = Box::new(5i);
498492
499493
// stuff happens
500494
@@ -513,8 +507,9 @@ You don't need to fully grok the theory of affine types or regions to grok
513507
boxes, though. As a rough approximation, you can treat this Rust code:
514508

515509
```{rust}
510+
# use std::boxed::Box;
516511
{
517-
let x = box 5i;
512+
let x = Box::new(5i);
518513
519514
// stuff happens
520515
}
@@ -553,12 +548,13 @@ for more detail on how lifetimes work.
553548
Using boxes and references together is very common. For example:
554549

555550
```{rust}
551+
# use std::boxed::Box;
556552
fn add_one(x: &int) -> int {
557553
*x + 1
558554
}
559555
560556
fn main() {
561-
let x = box 5i;
557+
let x = Box::new(5i);
562558
563559
println!("{}", add_one(&*x));
564560
}
@@ -570,12 +566,13 @@ function, and since it's only reading the value, allows it.
570566
We can borrow `x` multiple times, as long as it's not simultaneous:
571567

572568
```{rust}
569+
# use std::boxed::Box;
573570
fn add_one(x: &int) -> int {
574571
*x + 1
575572
}
576573
577574
fn main() {
578-
let x = box 5i;
575+
let x = Box::new(5i);
579576
580577
println!("{}", add_one(&*x));
581578
println!("{}", add_one(&*x));
@@ -586,12 +583,13 @@ fn main() {
586583
Or as long as it's not a mutable borrow. This will error:
587584

588585
```{rust,ignore}
586+
# use std::boxed::Box;
589587
fn add_one(x: &mut int) -> int {
590588
*x + 1
591589
}
592590
593591
fn main() {
594-
let x = box 5i;
592+
let x = Box::new(5i);
595593
596594
println!("{}", add_one(&*x)); // error: cannot borrow immutable dereference
597595
// of `&`-pointer as mutable
@@ -612,22 +610,23 @@ Sometimes, you need a recursive data structure. The simplest is known as a
612610

613611

614612
```{rust}
615-
#[deriving(Show)]
613+
# use std::boxed::Box;
614+
#[derive(Show)]
616615
enum List<T> {
617616
Cons(T, Box<List<T>>),
618617
Nil,
619618
}
620619
621620
fn main() {
622-
let list: List<int> = List::Cons(1, box List::Cons(2, box List::Cons(3, box List::Nil)));
621+
let list: List<int> = List::Cons(1, Box::new(List::Cons(2, Box::new(List::Cons(3, Box::new(List::Nil))))));
623622
println!("{:?}", list);
624623
}
625624
```
626625

627626
This prints:
628627

629628
```text
630-
Cons(1, box Cons(2, box Cons(3, box Nil)))
629+
Cons(1, Box(Cons(2, Box(Cons(3, Box(Nil))))))
631630
```
632631

633632
The reference to another `List` inside of the `Cons` enum variant must be a box,
@@ -667,6 +666,7 @@ In many languages with pointers, you'd return a pointer from a function
667666
so as to avoid copying a large data structure. For example:
668667

669668
```{rust}
669+
# use std::boxed::Box;
670670
struct BigStruct {
671671
one: int,
672672
two: int,
@@ -675,15 +675,15 @@ struct BigStruct {
675675
}
676676
677677
fn foo(x: Box<BigStruct>) -> Box<BigStruct> {
678-
return box *x;
678+
return Box::new(*x);
679679
}
680680
681681
fn main() {
682-
let x = box BigStruct {
682+
let x = Box::new(BigStruct {
683683
one: 1,
684684
two: 2,
685685
one_hundred: 100,
686-
};
686+
});
687687
688688
let y = foo(x);
689689
}
@@ -695,6 +695,7 @@ than the hundred `int`s that make up the `BigStruct`.
695695
This is an antipattern in Rust. Instead, write this:
696696

697697
```{rust}
698+
# use std::boxed::Box;
698699
struct BigStruct {
699700
one: int,
700701
two: int,
@@ -707,13 +708,13 @@ fn foo(x: Box<BigStruct>) -> BigStruct {
707708
}
708709
709710
fn main() {
710-
let x = box BigStruct {
711+
let x = Box::new(BigStruct {
711712
one: 1,
712713
two: 2,
713714
one_hundred: 100,
714-
};
715+
});
715716
716-
let y = box foo(x);
717+
let y = Box::new(foo(x));
717718
}
718719
```
719720

src/doc/guide-unsafe.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ extern crate libc;
197197
use libc::{c_void, size_t, malloc, free};
198198
use std::mem;
199199
use std::ptr;
200+
# use std::boxed::Box;
200201
201202
// Define a wrapper around the handle returned by the foreign code.
202203
// Unique<T> has the same semantics as Box<T>
@@ -265,7 +266,7 @@ impl<T: Send> Drop for Unique<T> {
265266
// A comparison between the built-in `Box` and this reimplementation
266267
fn main() {
267268
{
268-
let mut x = box 5i;
269+
let mut x = Box::new(5i);
269270
*x = 10;
270271
} // `x` is freed here
271272
@@ -653,7 +654,7 @@ sugar for dynamic allocations via `malloc` and `free`:
653654

654655
```
655656
#![no_std]
656-
#![feature(lang_items)]
657+
#![feature(lang_items, box_syntax)]
657658
658659
extern crate libc;
659660

0 commit comments

Comments
 (0)