Skip to content

Commit 4064360

Browse files
committed
---
yaml --- r: 105399 b: refs/heads/master c: 8b6592e h: refs/heads/master i: 105397: 763b6fa 105395: 4641d26 105391: 8810cf8 v: v3
1 parent 96610b8 commit 4064360

File tree

574 files changed

+3400
-3828
lines changed

Some content is hidden

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

574 files changed

+3400
-3828
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9e89ffc60e4a72dd0e6e9b1930111235b18e595e
2+
refs/heads/master: 8b6592ef1a29360716e49545cff42d7103366b02
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
55
refs/heads/try: db814977d07bd798feb24f6b74c00800ef458a13

trunk/mk/clean.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ define CLEAN_HOST_STAGE_N
7878
clean$(1)_H_$(2): \
7979
$$(foreach crate,$$(CRATES),clean$(1)_H_$(2)-lib-$$(crate)) \
8080
$$(foreach tool,$$(TOOLS),clean$(1)_H_$(2)-tool-$$(tool))
81-
$$(Q)rm -fr $(2)/rt/libbacktrace
8281

8382
clean$(1)_H_$(2)-tool-%:
8483
$$(Q)rm -f $$(HBIN$(1)_H_$(2))/$$*$$(X_$(2))

trunk/mk/crates.mk

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#
3838
# DEPS_<crate>
3939
# These lists are the dependencies of the <crate> that is to be built.
40-
# Rust dependencies are listed bare (i.e. std, green) and native
40+
# Rust dependencies are listed bare (i.e. std, extra, green) and native
4141
# dependencies have a "native:" prefix (i.e. native:sundown). All deps
4242
# will be built before the crate itself is built.
4343
#
@@ -49,26 +49,26 @@
4949
# automatically generated for all stage/host/target combinations.
5050
################################################################################
5151

52-
TARGET_CRATES := std green rustuv native flate arena glob term semver \
53-
uuid serialize sync getopts collections num test time rand \
54-
workcache url log
52+
TARGET_CRATES := std extra green rustuv native flate arena glob term semver \
53+
uuid serialize sync getopts collections num test time rand
5554
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat
5655
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5756
TOOLS := compiletest rustdoc rustc
5857

5958
DEPS_std := native:rustrt native:compiler-rt native:backtrace
59+
DEPS_extra := std term sync serialize getopts collections time rand
6060
DEPS_green := std rand native:context_switch
6161
DEPS_rustuv := std native:uv native:uv_support
6262
DEPS_native := std
63-
DEPS_syntax := std term serialize collections log
63+
DEPS_syntax := std term serialize collections
6464
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
65-
collections time log
65+
collections time extra
6666
DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
6767
test time
68-
DEPS_flate := std native:miniz
68+
DEPS_flate := std extra native:miniz
6969
DEPS_arena := std collections
7070
DEPS_glob := std
71-
DEPS_serialize := std collections log
71+
DEPS_serialize := std collections
7272
DEPS_term := std collections
7373
DEPS_semver := std
7474
DEPS_uuid := std serialize rand
@@ -78,12 +78,9 @@ DEPS_collections := std rand
7878
DEPS_fourcc := syntax std
7979
DEPS_hexfloat := syntax std
8080
DEPS_num := std rand
81-
DEPS_test := std collections getopts serialize term time
81+
DEPS_test := std extra collections getopts serialize term
8282
DEPS_time := std serialize
8383
DEPS_rand := std
84-
DEPS_url := std collections
85-
DEPS_workcache := std serialize collections log
86-
DEPS_log := std sync
8784

8885
TOOL_DEPS_compiletest := test green rustuv getopts
8986
TOOL_DEPS_rustdoc := rustdoc native

trunk/mk/docs.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
DOCS := index tutorial guide-ffi guide-macros guide-lifetimes \
3030
guide-tasks guide-container guide-pointers guide-testing \
3131
guide-runtime complement-bugreport complement-cheatsheet \
32-
complement-lang-faq complement-project-faq rust rustdoc \
33-
guide-unsafe
32+
complement-lang-faq complement-project-faq rust rustdoc
3433

3534
PDF_DOCS := tutorial rust
3635

trunk/src/compiletest/compiletest.rs

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

1111
#[crate_type = "bin"];
12-
#[feature(phase)];
1312

1413
#[allow(non_camel_case_types)];
1514
#[deny(warnings)];
16-
#[allow(deprecated_owned_vector)];
1715

1816
extern crate test;
1917
extern crate getopts;
20-
#[phase(link, syntax)]
21-
extern crate log;
2218

2319
use std::os;
2420
use std::io;

trunk/src/doc/guide-ffi.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,85 @@ Foreign libraries often hand off ownership of resources to the calling code.
170170
When this occurs, we must use Rust's destructors to provide safety and guarantee
171171
the release of these resources (especially in the case of failure).
172172

173+
As an example, we give a reimplementation of owned boxes by wrapping `malloc`
174+
and `free`:
175+
176+
~~~~
177+
use std::cast;
178+
use std::libc::{c_void, size_t, malloc, free};
179+
use std::mem;
180+
use std::ptr;
181+
182+
// Define a wrapper around the handle returned by the foreign code.
183+
// Unique<T> has the same semantics as ~T
184+
pub struct Unique<T> {
185+
// It contains a single raw, mutable pointer to the object in question.
186+
priv ptr: *mut T
187+
}
188+
189+
// Implement methods for creating and using the values in the box.
190+
// NB: For simplicity and correctness, we require that T has kind Send
191+
// (owned boxes relax this restriction, and can contain managed (GC) boxes).
192+
// This is because, as implemented, the garbage collector would not know
193+
// about any shared boxes stored in the malloc'd region of memory.
194+
impl<T: Send> Unique<T> {
195+
pub fn new(value: T) -> Unique<T> {
196+
unsafe {
197+
let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
198+
assert!(!ptr.is_null());
199+
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
200+
// move_val_init moves a value into this memory without
201+
// attempting to drop the original value.
202+
mem::move_val_init(&mut *ptr, value);
203+
Unique{ptr: ptr}
204+
}
205+
}
206+
207+
// the 'r lifetime results in the same semantics as `&*x` with ~T
208+
pub fn borrow<'r>(&'r self) -> &'r T {
209+
unsafe { cast::copy_lifetime(self, &*self.ptr) }
210+
}
211+
212+
// the 'r lifetime results in the same semantics as `&mut *x` with ~T
213+
pub fn borrow_mut<'r>(&'r mut self) -> &'r mut T {
214+
unsafe { cast::copy_mut_lifetime(self, &mut *self.ptr) }
215+
}
216+
}
217+
218+
// The key ingredient for safety, we associate a destructor with
219+
// Unique<T>, making the struct manage the raw pointer: when the
220+
// struct goes out of scope, it will automatically free the raw pointer.
221+
// NB: This is an unsafe destructor, because rustc will not normally
222+
// allow destructors to be associated with parametrized types, due to
223+
// bad interaction with managed boxes. (With the Send restriction,
224+
// we don't have this problem.)
225+
#[unsafe_destructor]
226+
impl<T: Send> Drop for Unique<T> {
227+
fn drop(&mut self) {
228+
unsafe {
229+
let x = mem::uninit(); // dummy value to swap in
230+
// We need to move the object out of the box, so that
231+
// the destructor is called (at the end of this scope.)
232+
ptr::replace(self.ptr, x);
233+
free(self.ptr as *mut c_void)
234+
}
235+
}
236+
}
237+
238+
// A comparison between the built-in ~ and this reimplementation
239+
fn main() {
240+
{
241+
let mut x = ~5;
242+
*x = 10;
243+
} // `x` is freed here
244+
245+
{
246+
let mut y = Unique::new(5);
247+
*y.borrow_mut() = 10;
248+
} // `y` is freed here
249+
}
250+
~~~~
251+
173252
# Callbacks from C code to Rust functions
174253

175254
Some external libraries require the usage of callbacks to report back their

trunk/src/doc/guide-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ fn pnorm(nums: &~[f64], p: uint) -> f64 {
351351
352352
fn main() {
353353
let numbers = vec::from_fn(1000000, |_| rand::random::<f64>());
354+
println!("Inf-norm = {}", *numbers.iter().max().unwrap());
355+
354356
let numbers_arc = Arc::new(numbers);
355357
356358
for num in range(1u, 10) {

0 commit comments

Comments
 (0)