Skip to content

Commit ff90bfa

Browse files
committed
---
yaml --- r: 150801 b: refs/heads/try2 c: 189584e h: refs/heads/master i: 150799: ba2f112 v: v3
1 parent a159880 commit ff90bfa

File tree

588 files changed

+2725
-2185
lines changed

Some content is hidden

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

588 files changed

+2725
-2185
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0162f8e6e16152224de4704ecd72d537c27046fe
8+
refs/heads/try2: 189584e792bfc10142793ca1117e803c2201991a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/docs.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# L10N_LANGS are the languages for which the docs have been
2727
# translated.
2828
######################################################################
29-
DOCS := index tutorial guide-ffi guide-macros guide-lifetimes \
29+
DOCS := index intro tutorial guide-ffi guide-macros guide-lifetimes \
3030
guide-tasks guide-container guide-pointers guide-testing \
3131
guide-runtime complement-bugreport complement-cheatsheet \
3232
complement-lang-faq complement-project-faq rust rustdoc \

branches/try2/mk/main.mk

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,44 @@ EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
349349

350350
CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
351351

352+
endef
353+
354+
# Same macro/variables as above, but defined in a separate loop so it can use
355+
# all the varibles above for all archs. The RPATH_VAR setup sometimes needs to
356+
# reach across triples to get things in order.
357+
define SREQ_CMDS
358+
359+
ifeq ($$(OSTYPE_$(3)),apple-darwin)
360+
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
361+
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
362+
else
363+
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
364+
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
365+
endif
366+
352367
# Pass --cfg stage0 only for the build->host part of stage0;
353368
# if you're building a cross config, the host->* parts are
354369
# effectively stage1, since it uses the just-built stage0.
370+
#
371+
# This logic is similar to how the LD_LIBRARY_PATH variable must
372+
# change be slightly different when doing cross compilations.
373+
# The build doesn't copy over all target libraries into
374+
# a new directory, so we need to point the library path at
375+
# the build directory where all the target libraries came
376+
# from (the stage0 build host). Otherwise the relative rpaths
377+
# inside of the rustc binary won't get resolved correctly.
355378
ifeq ($(1),0)
356379
ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
357380
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
358-
endif
359-
endif
360381

361382
ifeq ($$(OSTYPE_$(3)),apple-darwin)
362383
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
363-
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
384+
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
364385
else
365386
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
366-
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
387+
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))"
388+
endif
389+
endif
367390
endif
368391

369392
STAGE$(1)_T_$(2)_H_$(3) := \
@@ -390,6 +413,11 @@ $(foreach build,$(CFG_HOST), \
390413
$(eval $(foreach stage,$(STAGES), \
391414
$(eval $(call SREQ,$(stage),$(target),$(build))))))))
392415

416+
$(foreach build,$(CFG_HOST), \
417+
$(eval $(foreach target,$(CFG_TARGET), \
418+
$(eval $(foreach stage,$(STAGES), \
419+
$(eval $(call SREQ_CMDS,$(stage),$(target),$(build))))))))
420+
393421
######################################################################
394422
# rustc-H-targets
395423
#

branches/try2/src/doc/guide-ffi.md

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ snappy includes a C interface (documented in
1111
The following is a minimal example of calling a foreign function which will
1212
compile if snappy is installed:
1313

14-
~~~~ {.ignore}
14+
~~~~
1515
extern crate libc;
1616
use libc::size_t;
1717
1818
#[link(name = "snappy")]
19+
# #[cfg(ignore_this)]
1920
extern {
2021
fn snappy_max_compressed_length(source_length: size_t) -> size_t;
2122
}
23+
# unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a }
2224
2325
fn main() {
2426
let x = unsafe { snappy_max_compressed_length(100) };
@@ -78,7 +80,11 @@ vectors as pointers to memory. Rust's vectors are guaranteed to be a contiguous
7880
length is number of elements currently contained, and the capacity is the total size in elements of
7981
the allocated memory. The length is less than or equal to the capacity.
8082

81-
~~~~ {.ignore}
83+
~~~~
84+
# extern crate libc;
85+
# use libc::{c_int, size_t};
86+
# unsafe fn snappy_validate_compressed_buffer(_: *u8, _: size_t) -> c_int { 0 }
87+
# fn main() {}
8288
pub fn validate_compressed_buffer(src: &[u8]) -> bool {
8389
unsafe {
8490
snappy_validate_compressed_buffer(src.as_ptr(), src.len() as size_t) == 0
@@ -98,14 +104,20 @@ required capacity to hold the compressed output. The vector can then be passed t
98104
`snappy_compress` function as an output parameter. An output parameter is also passed to retrieve
99105
the true length after compression for setting the length.
100106

101-
~~~~ {.ignore}
102-
pub fn compress(src: &[u8]) -> ~[u8] {
107+
~~~~
108+
# extern crate libc;
109+
# use libc::{size_t, c_int};
110+
# unsafe fn snappy_compress(a: *u8, b: size_t, c: *mut u8,
111+
# d: *mut size_t) -> c_int { 0 }
112+
# unsafe fn snappy_max_compressed_length(a: size_t) -> size_t { a }
113+
# fn main() {}
114+
pub fn compress(src: &[u8]) -> Vec<u8> {
103115
unsafe {
104116
let srclen = src.len() as size_t;
105117
let psrc = src.as_ptr();
106118
107119
let mut dstlen = snappy_max_compressed_length(srclen);
108-
let mut dst = slice::with_capacity(dstlen as uint);
120+
let mut dst = Vec::with_capacity(dstlen as uint);
109121
let pdst = dst.as_mut_ptr();
110122
111123
snappy_compress(psrc, srclen, pdst, &mut dstlen);
@@ -118,16 +130,26 @@ pub fn compress(src: &[u8]) -> ~[u8] {
118130
Decompression is similar, because snappy stores the uncompressed size as part of the compression
119131
format and `snappy_uncompressed_length` will retrieve the exact buffer size required.
120132

121-
~~~~ {.ignore}
122-
pub fn uncompress(src: &[u8]) -> Option<~[u8]> {
133+
~~~~
134+
# extern crate libc;
135+
# use libc::{size_t, c_int};
136+
# unsafe fn snappy_uncompress(compressed: *u8,
137+
# compressed_length: size_t,
138+
# uncompressed: *mut u8,
139+
# uncompressed_length: *mut size_t) -> c_int { 0 }
140+
# unsafe fn snappy_uncompressed_length(compressed: *u8,
141+
# compressed_length: size_t,
142+
# result: *mut size_t) -> c_int { 0 }
143+
# fn main() {}
144+
pub fn uncompress(src: &[u8]) -> Option<Vec<u8>> {
123145
unsafe {
124146
let srclen = src.len() as size_t;
125147
let psrc = src.as_ptr();
126148
127149
let mut dstlen: size_t = 0;
128150
snappy_uncompressed_length(psrc, srclen, &mut dstlen);
129151
130-
let mut dst = slice::with_capacity(dstlen as uint);
152+
let mut dst = Vec::with_capacity(dstlen as uint);
131153
let pdst = dst.as_mut_ptr();
132154
133155
if snappy_uncompress(psrc, srclen, pdst, &mut dstlen) == 0 {
@@ -187,16 +209,19 @@ A basic example is:
187209

188210
Rust code:
189211

190-
~~~~ {.ignore}
212+
~~~~
191213
extern fn callback(a:i32) {
192214
println!("I'm called from C with value {0}", a);
193215
}
194216
195217
#[link(name = "extlib")]
218+
# #[cfg(ignore)]
196219
extern {
197-
fn register_callback(cb: extern "C" fn(i32)) -> i32;
220+
fn register_callback(cb: extern fn(i32)) -> i32;
198221
fn trigger_callback();
199222
}
223+
# unsafe fn register_callback(cb: extern fn(i32)) -> i32 { 0 }
224+
# unsafe fn trigger_callback() { }
200225
201226
fn main() {
202227
unsafe {
@@ -240,33 +265,39 @@ referenced Rust object.
240265

241266
Rust code:
242267

243-
~~~~ {.ignore}
268+
~~~~
244269
245270
struct RustObject {
246271
a: i32,
247272
// other members
248273
}
249274
250-
extern fn callback(target: *RustObject, a:i32) {
275+
extern fn callback(target: *mut RustObject, a:i32) {
251276
println!("I'm called from C with value {0}", a);
252-
(*target).a = a; // Update the value in RustObject with the value received from the callback
277+
unsafe {
278+
// Update the value in RustObject with the value received from the callback
279+
(*target).a = a;
280+
}
253281
}
254282
255283
#[link(name = "extlib")]
284+
# #[cfg(ignore)]
256285
extern {
257-
fn register_callback(target: *RustObject, cb: extern "C" fn(*RustObject, i32)) -> i32;
286+
fn register_callback(target: *mut RustObject,
287+
cb: extern fn(*mut RustObject, i32)) -> i32;
258288
fn trigger_callback();
259289
}
290+
# unsafe fn register_callback(a: *mut RustObject,
291+
# b: extern fn(*mut RustObject, i32)) -> i32 { 0 }
292+
# unsafe fn trigger_callback() {}
260293
261294
fn main() {
262295
// Create the object that will be referenced in the callback
263-
let rust_object = ~RustObject{a: 5, ...};
296+
let mut rust_object = ~RustObject{ a: 5 };
264297
265298
unsafe {
266-
// Gets a raw pointer to the object
267-
let target_addr:*RustObject = ptr::to_unsafe_ptr(rust_object);
268-
register_callback(target_addr, callback);
269-
trigger_callback(); // Triggers the callback
299+
register_callback(&mut *rust_object, callback);
300+
trigger_callback();
270301
}
271302
}
272303
~~~~
@@ -403,13 +434,15 @@ Foreign APIs often export a global variable which could do something like track
403434
global state. In order to access these variables, you declare them in `extern`
404435
blocks with the `static` keyword:
405436

406-
~~~{.ignore}
437+
~~~
407438
extern crate libc;
408439
409440
#[link(name = "readline")]
441+
# #[cfg(ignore)]
410442
extern {
411443
static rl_readline_version: libc::c_int;
412444
}
445+
# static rl_readline_version: libc::c_int = 0;
413446
414447
fn main() {
415448
println!("You have readline version {} installed.",
@@ -421,21 +454,23 @@ Alternatively, you may need to alter global state provided by a foreign
421454
interface. To do this, statics can be declared with `mut` so rust can mutate
422455
them.
423456

424-
~~~{.ignore}
457+
~~~
425458
extern crate libc;
426459
use std::ptr;
427460
428461
#[link(name = "readline")]
462+
# #[cfg(ignore)]
429463
extern {
430464
static mut rl_prompt: *libc::c_char;
431465
}
466+
# static mut rl_prompt: *libc::c_char = 0 as *libc::c_char;
432467
433468
fn main() {
434-
do "[my-awesome-shell] $".as_c_str |buf| {
469+
"[my-awesome-shell] $".with_c_str(|buf| {
435470
unsafe { rl_prompt = buf; }
436471
// get a line, process it
437472
unsafe { rl_prompt = ptr::null(); }
438-
}
473+
});
439474
}
440475
~~~
441476

branches/try2/src/doc/guide-macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ As an example, `loop` and `for-loop` labels (discussed in the lifetimes guide)
407407
will not clash. The following code will print "Hello!" only once:
408408

409409
~~~
410-
#[feature(macro_rules)];
410+
#![feature(macro_rules)]
411411
412412
macro_rules! loop_x (
413413
($e: expr) => (

branches/try2/src/doc/guide-pointers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ struct.
250250
# Managed Pointers
251251

252252
> **Note**: the `@` form of managed pointers is deprecated and behind a
253-
> feature gate (it requires a `#[feature(managed_pointers)];` attribute on
253+
> feature gate (it requires a `#![feature(managed_pointers)]` attribute on
254254
> the crate root; remember the semicolon!). There are replacements, currently
255255
> there is `std::rc::Rc` and `std::gc::Gc` for shared ownership via reference
256256
> counting and garbage collection respectively.

branches/try2/src/doc/guide-testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ amount.
185185
For example:
186186

187187
~~~
188-
# #[allow(unused_imports)];
188+
# #![allow(unused_imports)]
189189
extern crate test;
190190
191191
use std::slice;
@@ -247,7 +247,7 @@ recognize that some calculation has no external effects and remove
247247
it entirely.
248248

249249
~~~
250-
# #[allow(unused_imports)];
250+
# #![allow(unused_imports)]
251251
extern crate test;
252252
use test::Bencher;
253253

branches/try2/src/doc/guide-unsafe.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,14 @@ Current valid options are:
424424
# Avoiding the standard library
425425

426426
By default, `std` is linked to every Rust crate. In some contexts,
427-
this is undesirable, and can be avoided with the `#[no_std];`
427+
this is undesirable, and can be avoided with the `#![no_std]`
428428
attribute attached to the crate.
429429

430430
```ignore
431431
# // FIXME #12903: linking failures due to no_std
432432
// the minimal library
433-
#[crate_type="lib"];
434-
#[no_std];
433+
#![crate_type="lib"]
434+
#![no_std]
435435
436436
# // fn main() {} tricked you, rustdoc!
437437
```
@@ -446,7 +446,7 @@ in the same format as a C:
446446

447447
```ignore
448448
# // FIXME #12903: linking failures due to no_std
449-
#[no_std];
449+
#![no_std]
450450
451451
extern "rust-intrinsic" { fn abort() -> !; }
452452
#[no_mangle] pub extern fn rust_stack_exhausted() {
@@ -462,14 +462,14 @@ fn start(_argc: int, _argv: **u8) -> int {
462462
```
463463

464464
To override the compiler-inserted `main` shim, one has to disable it
465-
with `#[no_main];` and then create the appropriate symbol with the
465+
with `#![no_main]` and then create the appropriate symbol with the
466466
correct ABI and the correct name, which requires overriding the
467467
compiler's name mangling too:
468468

469469
```ignore
470470
# // FIXME #12903: linking failures due to no_std
471-
#[no_std];
472-
#[no_main];
471+
#![no_std]
472+
#![no_main]
473473
474474
extern "rust-intrinsic" { fn abort() -> !; }
475475
#[no_mangle] pub extern fn rust_stack_exhausted() {
@@ -543,7 +543,7 @@ sugar for dynamic allocations via `malloc` and `free`:
543543

544544
```ignore
545545
# // FIXME #12903: linking failures due to no_std
546-
#[no_std];
546+
#![no_std]
547547
548548
#[allow(ctypes)] // `uint` == `size_t` on Rust's platforms
549549
extern {

branches/try2/src/doc/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
li {list-style-type: none; }
88
</style>
99

10+
* [A 30-minute Intro to Rust](intro.html)
1011
* [The Rust tutorial](tutorial.html) (* [PDF](tutorial.pdf))
1112
* [The Rust reference manual](rust.html) (* [PDF](rust.pdf))
1213

0 commit comments

Comments
 (0)