Skip to content

Commit 3e7b5fa

Browse files
committed
---
yaml --- r: 235779 b: refs/heads/stable c: 43edc1c h: refs/heads/master i: 235777: c2691e3 235775: 072bc97 v: v3
1 parent 97ddada commit 3e7b5fa

File tree

165 files changed

+4954
-1459
lines changed

Some content is hidden

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

165 files changed

+4954
-1459
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: b6a0d9e17843a2b078e491e10f64a4005b3a7791
32+
refs/heads/stable: 43edc1c35a60f6698726af1bbddbabe4d7ad1244
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/mk/rt.mk

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ NATIVE_DEPS_miniz_$(1) = miniz.c
5454
NATIVE_DEPS_rust_builtin_$(1) := rust_builtin.c \
5555
rust_android_dummy.c
5656
NATIVE_DEPS_rustrt_native_$(1) := arch/$$(HOST_$(1))/record_sp.S
57-
ifeq ($$(findstring msvc,$(1)),msvc)
58-
ifeq ($$(findstring i686,$(1)),i686)
59-
NATIVE_DEPS_rustrt_native_$(1) += rust_try_msvc_32.ll
60-
else
61-
NATIVE_DEPS_rustrt_native_$(1) += rust_try_msvc_64.ll
62-
endif
63-
else
64-
NATIVE_DEPS_rustrt_native_$(1) += rust_try.ll
65-
endif
6657
NATIVE_DEPS_rust_test_helpers_$(1) := rust_test_helpers.c
6758
NATIVE_DEPS_morestack_$(1) := arch/$$(HOST_$(1))/morestack.S
6859

@@ -76,14 +67,6 @@ NATIVE_DEPS_morestack_$(1) := arch/$$(HOST_$(1))/morestack.S
7667

7768
RT_OUTPUT_DIR_$(1) := $(1)/rt
7869

79-
$$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.ll $$(MKFILE_DEPS) \
80-
$$(LLVM_CONFIG_$$(CFG_BUILD))
81-
@mkdir -p $$(@D)
82-
@$$(call E, compile: $$@)
83-
$$(Q)$$(LLC_$$(CFG_BUILD)) $$(CFG_LLC_FLAGS_$(1)) \
84-
-filetype=obj -mtriple=$$(CFG_LLVM_TARGET_$(1)) \
85-
-relocation-model=pic -o $$@ $$<
86-
8770
$$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.c $$(MKFILE_DEPS)
8871
@mkdir -p $$(@D)
8972
@$$(call E, compile: $$@)
@@ -122,7 +105,6 @@ define THIRD_PARTY_LIB
122105
OBJS_$(2)_$(1) := $$(NATIVE_DEPS_$(2)_$(1):%=$$(RT_OUTPUT_DIR_$(1))/%)
123106
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.c=.o)
124107
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.cpp=.o)
125-
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.ll=.o)
126108
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.S=.o)
127109
NATIVE_$(2)_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),$(2))
128110
$$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)): $$(OBJS_$(2)_$(1))

branches/stable/src/doc/trpl/ffi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ libraries:
340340
Note that frameworks are only available on OSX targets.
341341
342342
The different `kind` values are meant to differentiate how the native library
343-
participates in linkage. From a linkage perspective, the rust compiler creates
343+
participates in linkage. From a linkage perspective, the Rust compiler creates
344344
two flavors of artifacts: partial (rlib/staticlib) and final (dylib/binary).
345345
Native dynamic library and framework dependencies are propagated to the final
346346
artifact boundary, while static library dependencies are not propagated at
@@ -350,9 +350,9 @@ artifact.
350350
A few examples of how this model can be used are:
351351
352352
* A native build dependency. Sometimes some C/C++ glue is needed when writing
353-
some rust code, but distribution of the C/C++ code in a library format is just
353+
some Rust code, but distribution of the C/C++ code in a library format is just
354354
a burden. In this case, the code will be archived into `libfoo.a` and then the
355-
rust crate would declare a dependency via `#[link(name = "foo", kind =
355+
Rust crate would declare a dependency via `#[link(name = "foo", kind =
356356
"static")]`.
357357
358358
Regardless of the flavor of output for the crate, the native static library
@@ -361,7 +361,7 @@ A few examples of how this model can be used are:
361361
362362
* A normal dynamic dependency. Common system libraries (like `readline`) are
363363
available on a large number of systems, and often a static copy of these
364-
libraries cannot be found. When this dependency is included in a rust crate,
364+
libraries cannot be found. When this dependency is included in a Rust crate,
365365
partial targets (like rlibs) will not link to the library, but when the rlib
366366
is included in a final target (like a binary), the native library will be
367367
linked in.

branches/stable/src/doc/trpl/installing-rust.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The first step to using Rust is to install it! There are a number of ways to
44
install Rust, but the easiest is to use the `rustup` script. If you're on Linux
5-
or a Mac, all you need to do is this:
5+
or a Mac, all you need to do is this:
66

77
> Note: you don't need to type in the `$`s, they just indicate the start of
88
> each command. You’ll see many tutorials and examples around the web that
@@ -25,6 +25,12 @@ $ sh rustup.sh
2525
[insecurity]: http://curlpipesh.tumblr.com
2626

2727
If you're on Windows, please download the appropriate [installer][install-page].
28+
**NOTE:** By default, the Windows installer will not add Rust to the %PATH%
29+
system variable. If this is the only version of Rust you are installing and you
30+
want to be able to run it from the command line, click on "Advanced" on the
31+
install dialog and on the "Product Features" page ensure "Add to PATH" is
32+
installed on the local hard drive.
33+
2834

2935
[install-page]: http://www.rust-lang.org/install.html
3036

@@ -87,6 +93,11 @@ rustc 1.0.0 (a59de37e9 2015-05-13)
8793

8894
If you did, Rust has been installed successfully! Congrats!
8995

96+
If you didn't and you're on Windows, check that Rust is in your %PATH% system
97+
variable. If it isn't, run the installer again, select "Change" on the "Change,
98+
repair, or remove installation" page and ensure "Add to PATH" is installed on
99+
the local hard drive.
100+
90101
This installer also installs a copy of the documentation locally, so you can
91102
read it offline. On UNIX systems, `/usr/local/share/doc/rust` is the location.
92103
On Windows, it's in a `share/doc` directory, inside wherever you installed Rust
@@ -101,5 +112,5 @@ resources include [the user’s forum][users], and
101112

102113
[irc]: irc://irc.mozilla.org/#rust
103114
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
104-
[users]: http://users.rust-lang.org/
115+
[users]: http://users.rust-lang.org/
105116
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust

branches/stable/src/doc/trpl/release-channels.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,26 @@ This will help alert the team in case there’s an accidental regression.
4343
Additionally, testing against nightly can catch regressions even sooner, and so
4444
if you don’t mind a third build, we’d appreciate testing against all channels.
4545

46+
As an example, many Rust programmers use [Travis](https://travis-ci.org/) to
47+
test their crates, which is free for open source projects. Travis [supports
48+
Rust directly][travis], and you can use a `.travis.yml` file like this to
49+
test on all channels:
50+
51+
```yaml
52+
language: rust
53+
rust:
54+
- nightly
55+
- beta
56+
- stable
57+
58+
matrix:
59+
allow_failures:
60+
- rust: nightly
61+
```
62+
63+
[travis]: http://docs.travis-ci.com/user/languages/rust/
64+
65+
With this configuration, Travis will test all three channels, but if something
66+
breaks on nightly, it won’t fail your build. A similar configuration is
67+
recommended for any CI system, check the documentation of the one you’re
68+
using for more details.

branches/stable/src/doc/trpl/unsafe.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ that you normally can not do. Just three. Here they are:
100100

101101
That’s it. It’s important that `unsafe` does not, for example, ‘turn off the
102102
borrow checker’. Adding `unsafe` to some random Rust code doesn’t change its
103-
semantics, it won’t just start accepting anything.
103+
semantics, it won’t just start accepting anything. But it will let you write
104+
things that _do_ break some of the rules.
104105

105-
But it will let you write things that _do_ break some of the rules. Let’s go
106-
over these three abilities in order.
106+
You will also encounter the `unsafe` keyword when writing bindings to foreign
107+
(non-Rust) interfaces. You're encouraged to write a safe, native Rust interface
108+
around the methods provided by the library.
109+
110+
Let’s go over the basic three abilities listed, in order.
107111

108112
## Access or update a `static mut`
109113

branches/stable/src/doc/trpl/while-loops.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ for x in 0..10 {
8888
}
8989
```
9090

91+
You may also encounter situations where you have nested loops and need to
92+
specify which one your `break` or `continue` statement is for. Like most
93+
other languages, by default a `break` or `continue` will apply to innermost
94+
loop. In a sitation where you would like to a `break` or `continue` for one
95+
of the outer loops, you can use labels to specify which loop the `break` or
96+
`continue` statement applies to. This will only print when both `x` and `y` are
97+
odd:
98+
99+
```rust
100+
'outer: for x in 0..10 {
101+
'inner: for y in 0..10 {
102+
if x % 2 == 0 { continue 'outer; } // continues the loop over x
103+
if y % 2 == 0 { continue 'inner; } // continues the loop over y
104+
println!("x: {}, y: {}", x, y);
105+
}
106+
}
107+
```
108+
91109
Both `continue` and `break` are valid in both `while` loops and [`for` loops][for].
92110

93111
[for]: for-loops.html

branches/stable/src/liballoc/boxed.rs

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@
5555

5656
use core::prelude::*;
5757

58+
use heap;
59+
5860
use core::any::Any;
5961
use core::cmp::Ordering;
6062
use core::fmt;
6163
use core::hash::{self, Hash};
62-
use core::marker::Unsize;
64+
use core::marker::{self, Unsize};
6365
use core::mem;
6466
use core::ops::{CoerceUnsized, Deref, DerefMut};
67+
use core::ops::{Placer, Boxed, Place, InPlace, BoxPlace};
6568
use core::ptr::Unique;
6669
use core::raw::{TraitObject};
6770

@@ -72,7 +75,7 @@ use core::raw::{TraitObject};
7275
///
7376
/// ```
7477
/// # #![feature(box_heap)]
75-
/// #![feature(box_syntax)]
78+
/// #![feature(box_syntax, placement_in_syntax)]
7679
/// use std::boxed::HEAP;
7780
///
7881
/// fn main() {
@@ -83,15 +86,110 @@ use core::raw::{TraitObject};
8386
#[lang = "exchange_heap"]
8487
#[unstable(feature = "box_heap",
8588
reason = "may be renamed; uncertain about custom allocator design")]
86-
pub const HEAP: () = ();
89+
pub const HEAP: ExchangeHeapSingleton =
90+
ExchangeHeapSingleton { _force_singleton: () };
91+
92+
/// This the singleton type used solely for `boxed::HEAP`.
93+
#[derive(Copy, Clone)]
94+
pub struct ExchangeHeapSingleton { _force_singleton: () }
8795

8896
/// A pointer type for heap allocation.
8997
///
9098
/// See the [module-level documentation](../../std/boxed/index.html) for more.
9199
#[lang = "owned_box"]
92100
#[stable(feature = "rust1", since = "1.0.0")]
93101
#[fundamental]
94-
pub struct Box<T>(Unique<T>);
102+
pub struct Box<T: ?Sized>(Unique<T>);
103+
104+
/// `IntermediateBox` represents uninitialized backing storage for `Box`.
105+
///
106+
/// FIXME (pnkfelix): Ideally we would just reuse `Box<T>` instead of
107+
/// introducing a separate `IntermediateBox<T>`; but then you hit
108+
/// issues when you e.g. attempt to destructure an instance of `Box`,
109+
/// since it is a lang item and so it gets special handling by the
110+
/// compiler. Easier just to make this parallel type for now.
111+
///
112+
/// FIXME (pnkfelix): Currently the `box` protocol only supports
113+
/// creating instances of sized types. This IntermediateBox is
114+
/// designed to be forward-compatible with a future protocol that
115+
/// supports creating instances of unsized types; that is why the type
116+
/// parameter has the `?Sized` generalization marker, and is also why
117+
/// this carries an explicit size. However, it probably does not need
118+
/// to carry the explicit alignment; that is just a work-around for
119+
/// the fact that the `align_of` intrinsic currently requires the
120+
/// input type to be Sized (which I do not think is strictly
121+
/// necessary).
122+
#[unstable(feature = "placement_in", reason = "placement box design is still being worked out.")]
123+
pub struct IntermediateBox<T: ?Sized>{
124+
ptr: *mut u8,
125+
size: usize,
126+
align: usize,
127+
marker: marker::PhantomData<*mut T>,
128+
}
129+
130+
impl<T> Place<T> for IntermediateBox<T> {
131+
fn pointer(&mut self) -> *mut T {
132+
unsafe { ::core::mem::transmute(self.ptr) }
133+
}
134+
}
135+
136+
unsafe fn finalize<T>(b: IntermediateBox<T>) -> Box<T> {
137+
let p = b.ptr as *mut T;
138+
mem::forget(b);
139+
mem::transmute(p)
140+
}
141+
142+
fn make_place<T>() -> IntermediateBox<T> {
143+
let size = mem::size_of::<T>();
144+
let align = mem::align_of::<T>();
145+
146+
let p = if size == 0 {
147+
heap::EMPTY as *mut u8
148+
} else {
149+
let p = unsafe {
150+
heap::allocate(size, align)
151+
};
152+
if p.is_null() {
153+
panic!("Box make_place allocation failure.");
154+
}
155+
p
156+
};
157+
158+
IntermediateBox { ptr: p, size: size, align: align, marker: marker::PhantomData }
159+
}
160+
161+
impl<T> BoxPlace<T> for IntermediateBox<T> {
162+
fn make_place() -> IntermediateBox<T> { make_place() }
163+
}
164+
165+
impl<T> InPlace<T> for IntermediateBox<T> {
166+
type Owner = Box<T>;
167+
unsafe fn finalize(self) -> Box<T> { finalize(self) }
168+
}
169+
170+
impl<T> Boxed for Box<T> {
171+
type Data = T;
172+
type Place = IntermediateBox<T>;
173+
unsafe fn finalize(b: IntermediateBox<T>) -> Box<T> { finalize(b) }
174+
}
175+
176+
impl<T> Placer<T> for ExchangeHeapSingleton {
177+
type Place = IntermediateBox<T>;
178+
179+
fn make_place(self) -> IntermediateBox<T> {
180+
make_place()
181+
}
182+
}
183+
184+
impl<T: ?Sized> Drop for IntermediateBox<T> {
185+
fn drop(&mut self) {
186+
if self.size > 0 {
187+
unsafe {
188+
heap::deallocate(self.ptr, self.size, self.align)
189+
}
190+
}
191+
}
192+
}
95193

96194
impl<T> Box<T> {
97195
/// Allocates memory on the heap and then moves `x` into it.
@@ -199,8 +297,7 @@ impl<T: Clone> Clone for Box<T> {
199297
/// let y = x.clone();
200298
/// ```
201299
#[inline]
202-
fn clone(&self) -> Box<T> { box {(**self).clone()} }
203-
300+
fn clone(&self) -> Box<T> { box (HEAP) {(**self).clone()} }
204301
/// Copies `source`'s contents into `self` without creating a new allocation.
205302
///
206303
/// # Examples

branches/stable/src/liballoc/lib.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
test(no_crate_inject))]
7171
#![no_std]
7272

73+
// SNAP d4432b3
74+
#![allow(unused_features)] // until feature(placement_in_syntax) is in snap
7375
#![feature(allocator)]
7476
#![feature(box_syntax)]
7577
#![feature(coerce_unsized)]
@@ -82,6 +84,8 @@
8284
#![feature(no_std)]
8385
#![feature(nonzero)]
8486
#![feature(optin_builtin_traits)]
87+
#![feature(placement_in_syntax)]
88+
#![feature(placement_new_protocol)]
8589
#![feature(raw)]
8690
#![feature(staged_api)]
8791
#![feature(unboxed_closures)]
@@ -135,20 +139,3 @@ pub fn oom() -> ! {
135139
// allocate.
136140
unsafe { core::intrinsics::abort() }
137141
}
138-
139-
// FIXME(#14344): When linking liballoc with libstd, this library will be linked
140-
// as an rlib (it only exists as an rlib). It turns out that an
141-
// optimized standard library doesn't actually use *any* symbols
142-
// from this library. Everything is inlined and optimized away.
143-
// This means that linkers will actually omit the object for this
144-
// file, even though it may be needed in the future.
145-
//
146-
// To get around this for now, we define a dummy symbol which
147-
// will never get inlined so the stdlib can call it. The stdlib's
148-
// reference to this symbol will cause this library's object file
149-
// to get linked in to libstd successfully (the linker won't
150-
// optimize it out).
151-
#[doc(hidden)]
152-
#[unstable(feature = "issue_14344_fixme")]
153-
#[cfg(stage0)]
154-
pub fn fixme_14344_be_sure_to_link_to_collections() {}

branches/stable/src/libcollections/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,6 @@ pub mod btree_set {
133133
pub use btree::set::*;
134134
}
135135

136-
137-
// FIXME(#14344) this shouldn't be necessary
138-
#[doc(hidden)]
139-
#[unstable(feature = "issue_14344_fixme")]
140-
#[cfg(stage0)]
141-
pub fn fixme_14344_be_sure_to_link_to_collections() {}
142-
143136
#[cfg(not(test))]
144137
mod std {
145138
pub use core::ops; // RangeFull

0 commit comments

Comments
 (0)