Skip to content

Commit f557c9e

Browse files
committed
---
yaml --- r: 143903 b: refs/heads/try2 c: 3504027 h: refs/heads/master i: 143901: 51da56a 143899: 96e9e4d 143895: ddf61a5 143887: ed0bcf7 143871: 5ce4cfa v: v3
1 parent f8d3f42 commit f557c9e

File tree

377 files changed

+10337
-10307
lines changed

Some content is hidden

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

377 files changed

+10337
-10307
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: 854e219d0aff3eff1f0b3762efc2d1a05ebb426b
8+
refs/heads/try2: 35040275b3f39618c3cec4a9f702b6e057309604
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ There are several kinds of view item:
744744
##### Extern mod declarations
745745

746746
~~~~~~~~ {.ebnf .gram}
747-
extern_mod_decl : "extern" "mod" ident [ '(' link_attrs ')' ] ? ;
747+
extern_mod_decl : "extern" "mod" ident [ '(' link_attrs ')' ] ? [ '=' string_lit ] ? ;
748748
link_attrs : link_attr [ ',' link_attrs ] + ;
749749
link_attr : ident '=' literal ;
750750
~~~~~~~~
@@ -755,20 +755,34 @@ as the `ident` provided in the `extern_mod_decl`.
755755

756756
The external crate is resolved to a specific `soname` at compile time,
757757
and a runtime linkage requirement to that `soname` is passed to the linker for
758-
loading at runtime. The `soname` is resolved at compile time by scanning the
759-
compiler's library path and matching the `link_attrs` provided in the
760-
`use_decl` against any `#link` attributes that were declared on the external
761-
crate when it was compiled. If no `link_attrs` are provided, a default `name`
762-
attribute is assumed, equal to the `ident` given in the `use_decl`.
763-
764-
Three examples of `extern mod` declarations:
758+
loading at runtime.
759+
The `soname` is resolved at compile time by scanning the compiler's library path
760+
and matching the `link_attrs` provided in the `use_decl` against any `#link` attributes that
761+
were declared on the external crate when it was compiled.
762+
If no `link_attrs` are provided,
763+
a default `name` attribute is assumed,
764+
equal to the `ident` given in the `use_decl`.
765+
766+
Optionally, an identifier in an `extern mod` declaration may be followed by an equals sign,
767+
then a string literal denoting a relative path on the filesystem.
768+
This path should exist in one of the directories in the Rust path,
769+
which by default contains the `.rust` subdirectory of the current directory and each of its parents,
770+
as well as any directories in the colon-separated (or semicolon-separated on Windows)
771+
list of paths that is the `RUST_PATH` environment variable.
772+
The meaning of `extern mod a = "b/c/d";`, supposing that `/a` is in the RUST_PATH,
773+
is that the name `a` should be taken as a reference to the crate whose absolute location is
774+
`/a/b/c/d`.
775+
776+
Four examples of `extern mod` declarations:
765777

766778
~~~~~~~~{.xfail-test}
767779
extern mod pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841");
768780
769781
extern mod extra; // equivalent to: extern mod extra ( name = "extra" );
770782
771783
extern mod rustextra (name = "extra"); // linking to 'extra' under another name
784+
785+
extern mod complicated_mod = "some-file/in/the-rust/path";
772786
~~~~~~~~
773787

774788
##### Use declarations

branches/try2/doc/rustpkg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ When building a package that is in a `git` repository,
103103
When building a package that is not under version control,
104104
or that has no tags, `rustpkg` assumes the intended version is 0.1.
105105

106+
> **Note:** A future version of rustpkg will support semantic versions.
107+
> Also, a future version will add the option to specify a version with a metadata
108+
> attribute like `#[link(vers = "3.1415")]` inside the crate module,
109+
> though this attribute will never be mandatory.
110+
106111
# Dependencies
107112

108113
rustpkg infers dependencies from `extern mod` directives.

branches/try2/doc/tutorial-ffi.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,48 @@ unsafe fn kaboom(ptr: *int) -> int { *ptr }
228228

229229
This function can only be called from an `unsafe` block or another `unsafe` function.
230230

231+
# Accessing foreign globals
232+
233+
Foreign APIs often export a global variable which could do something like track
234+
global state. In order to access these variables, you declare them in `extern`
235+
blocks with the `static` keyword:
236+
237+
~~~{.xfail-test}
238+
use std::libc;
239+
240+
#[link_args = "-lreadline"]
241+
extern {
242+
static rl_readline_version: libc::c_int;
243+
}
244+
245+
fn main() {
246+
println(fmt!("You have readline version %d installed.",
247+
rl_readline_version as int));
248+
}
249+
~~~
250+
251+
Alternatively, you may need to alter global state provided by a foreign
252+
interface. To do this, statics can be declared with `mut` so rust can mutate
253+
them.
254+
255+
~~~{.xfail-test}
256+
use std::libc;
257+
use std::ptr;
258+
259+
#[link_args = "-lreadline"]
260+
extern {
261+
static mut rl_prompt: *libc::c_char;
262+
}
263+
264+
fn main() {
265+
do "[my-awesome-shell] $".as_c_str |buf| {
266+
unsafe { rl_prompt = buf; }
267+
// get a line, process it
268+
unsafe { rl_prompt = ptr::null(); }
269+
}
270+
}
271+
~~~
272+
231273
# Foreign calling conventions
232274

233275
Most foreign code exposes a C ABI, and Rust uses the platform's C calling convention by default when

branches/try2/doc/tutorial-tasks.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ there is no way to "catch" the exception.
424424
All tasks are, by default, _linked_ to each other. That means that the fates
425425
of all tasks are intertwined: if one fails, so do all the others.
426426

427-
~~~
427+
~~~{.xfail-test .linked-failure}
428428
# use std::task::spawn;
429429
# use std::task;
430430
# fn do_some_work() { loop { task::yield() } }
@@ -447,7 +447,7 @@ pattern-match on a result to check whether it's an `Ok` result with an `int`
447447
field (representing a successful result) or an `Err` result (representing
448448
termination with an error).
449449

450-
~~~
450+
~~~{.xfail-test .linked-failure}
451451
# use std::task;
452452
# fn some_condition() -> bool { false }
453453
# fn calculate_result() -> int { 0 }
@@ -490,9 +490,10 @@ proceed). Hence, you will need different _linked failure modes_.
490490
By default, task failure is _bidirectionally linked_, which means that if
491491
either task fails, it kills the other one.
492492

493-
~~~
493+
~~~{.xfail-test .linked-failure}
494494
# use std::task;
495-
# fn sleep_forever() { loop { task::yield() } }
495+
# use std::comm::oneshot;
496+
# fn sleep_forever() { loop { let (p, c) = oneshot::<()>(); p.recv(); } }
496497
# do task::try {
497498
do spawn {
498499
do spawn {
@@ -511,11 +512,12 @@ function `task::try`, which we saw previously, uses `spawn_supervised`
511512
internally, with additional logic to wait for the child task to finish
512513
before returning. Hence:
513514

514-
~~~
515+
~~~{.xfail-test .linked-failure}
515516
# use std::comm::{stream, Chan, Port};
517+
# use std::comm::oneshot;
516518
# use std::task::{spawn, try};
517519
# use std::task;
518-
# fn sleep_forever() { loop { task::yield() } }
520+
# fn sleep_forever() { loop { let (p, c) = oneshot::<()>(); p.recv(); } }
519521
# do task::try {
520522
let (receiver, sender): (Port<int>, Chan<int>) = stream();
521523
do spawn { // Bidirectionally linked
@@ -541,9 +543,10 @@ also fail.
541543
Supervised task failure propagates across multiple generations even if
542544
an intermediate generation has already exited:
543545

544-
~~~
546+
~~~{.xfail-test .linked-failure}
545547
# use std::task;
546-
# fn sleep_forever() { loop { task::yield() } }
548+
# use std::comm::oneshot;
549+
# fn sleep_forever() { loop { let (p, c) = oneshot::<()>(); p.recv(); } }
547550
# fn wait_for_a_while() { for _ in range(0, 1000u) { task::yield() } }
548551
# do task::try::<int> {
549552
do task::spawn_supervised {
@@ -560,7 +563,7 @@ fail!(); // Will kill grandchild even if child has already exited
560563
Finally, tasks can be configured to not propagate failure to each
561564
other at all, using `task::spawn_unlinked` for _isolated failure_.
562565

563-
~~~
566+
~~~{.xfail-test .linked-failure}
564567
# use std::task;
565568
# fn random() -> uint { 100 }
566569
# fn sleep_for(i: uint) { for _ in range(0, i) { task::yield() } }
@@ -588,7 +591,7 @@ that repeatedly receives a `uint` message, converts it to a string, and sends
588591
the string in response. The child terminates when it receives `0`.
589592
Here is the function that implements the child task:
590593

591-
~~~~
594+
~~~{.xfail-test .linked-failure}
592595
# use extra::comm::DuplexStream;
593596
# use std::uint;
594597
fn stringifier(channel: &DuplexStream<~str, uint>) {
@@ -611,7 +614,7 @@ response itself is simply the stringified version of the received value,
611614
612615
Here is the code for the parent task:
613616
614-
~~~~
617+
~~~{.xfail-test .linked-failure}
615618
# use std::task::spawn;
616619
# use std::uint;
617620
# use extra::comm::DuplexStream;

branches/try2/doc/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ match crayons[0] {
13051305
A vector can be destructured using pattern matching:
13061306
13071307
~~~~
1308-
let numbers: [int, ..3] = [1, 2, 3];
1308+
let numbers: &[int] = &[1, 2, 3];
13091309
let score = match numbers {
13101310
[] => 0,
13111311
[a] => a * 10,
@@ -2195,7 +2195,7 @@ use std::float::consts::pi;
21952195
# impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } }
21962196
21972197
let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};
2198-
let mycircle: Circle = concrete as @Circle;
2198+
let mycircle: @Circle = concrete as @Circle;
21992199
let nonsense = mycircle.radius() * mycircle.area();
22002200
~~~
22012201

@@ -2288,8 +2288,8 @@ pub mod farm {
22882288
}
22892289
22902290
impl Farm {
2291-
priv fn feed_chickens(&self) { ... }
2292-
priv fn feed_cows(&self) { ... }
2291+
fn feed_chickens(&self) { ... }
2292+
fn feed_cows(&self) { ... }
22932293
pub fn add_chicken(&self, c: Chicken) { ... }
22942294
}
22952295

branches/try2/mk/install.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ endef
199199
$(foreach target,$(CFG_TARGET_TRIPLES), \
200200
$(if $(findstring $(target),"arm-linux-androideabi"), \
201201
$(if $(findstring adb,$(CFG_ADB)), \
202-
$(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
202+
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
203203
$(info install: install-runtime-target for $(target) enabled \
204204
$(info install: android device attached) \
205205
$(eval $(call DEF_ADB_DEVICE_STATUS, true))), \

branches/try2/mk/rt.mk

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,21 @@ RUNTIME_CXXS_$(1)_$(2) := \
6666
rt/sync/timer.cpp \
6767
rt/sync/lock_and_signal.cpp \
6868
rt/sync/rust_thread.cpp \
69-
rt/rust.cpp \
7069
rt/rust_builtin.cpp \
7170
rt/rust_run_program.cpp \
7271
rt/rust_env.cpp \
7372
rt/rust_rng.cpp \
74-
rt/rust_sched_loop.cpp \
75-
rt/rust_sched_launcher.cpp \
76-
rt/rust_sched_driver.cpp \
77-
rt/rust_scheduler.cpp \
78-
rt/rust_sched_reaper.cpp \
79-
rt/rust_task.cpp \
8073
rt/rust_stack.cpp \
8174
rt/rust_upcall.cpp \
8275
rt/rust_uv.cpp \
8376
rt/rust_crate_map.cpp \
84-
rt/rust_log.cpp \
8577
rt/rust_gc_metadata.cpp \
8678
rt/rust_util.cpp \
79+
rt/rust_log.cpp \
8780
rt/rust_exchange_alloc.cpp \
8881
rt/isaac/randport.cpp \
8982
rt/miniz.cpp \
90-
rt/rust_kernel.cpp \
9183
rt/rust_abi.cpp \
92-
rt/rust_debug.cpp \
9384
rt/memory_region.cpp \
9485
rt/boxed_region.cpp \
9586
rt/arch/$$(HOST_$(1))/context.cpp \

branches/try2/mk/tests.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ endef
123123
$(foreach target,$(CFG_TARGET_TRIPLES), \
124124
$(if $(findstring $(target),"arm-linux-androideabi"), \
125125
$(if $(findstring adb,$(CFG_ADB)), \
126-
$(if $(findstring device,$(shell adb devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
126+
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
127127
$(info check: $(target) test enabled \
128128
$(info check: android device attached) \
129129
$(eval $(call DEF_ADB_DEVICE_STATUS, true))), \
@@ -348,7 +348,9 @@ $(3)/stage$(1)/test/rustpkgtest-$(2)$$(X_$(2)): \
348348
$$(RUSTPKG_LIB) $$(RUSTPKG_INPUTS) \
349349
$$(SREQ$(1)_T_$(2)_H_$(3)) \
350350
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX_$(2)) \
351-
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2))
351+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC_$(2)) \
352+
$$(TBIN$(1)_T_$(2)_H_$(3))/rustpkg$$(X_$(2)) \
353+
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(2))
352354
@$$(call E, compile_and_link: $$@)
353355
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test
354356

branches/try2/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn parse_check_line(line: &str) -> Option<~str> {
142142
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
143143
do parse_name_value_directive(line, ~"exec-env").map |nv| {
144144
// nv is either FOO or FOO=BAR
145-
let mut strs: ~[~str] = nv.splitn_iter('=', 1).transform(|s| s.to_owned()).collect();
145+
let mut strs: ~[~str] = nv.splitn_iter('=', 1).map(|s| s.to_owned()).collect();
146146

147147
match strs.len() {
148148
1u => (strs.pop(), ~""),

branches/try2/src/compiletest/runtest.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
350350
fatal(~"process did not return an error status");
351351
}
352352

353-
let prefixes = expected_errors.iter().transform(|ee| {
353+
let prefixes = expected_errors.iter().map(|ee| {
354354
fmt!("%s:%u:", testfile.to_str(), ee.line)
355355
}).collect::<~[~str]>();
356356

357357
fn to_lower( s : &str ) -> ~str {
358358
let i = s.iter();
359-
let c : ~[char] = i.transform( |c| {
359+
let c : ~[char] = i.map( |c| {
360360
if c.is_ascii() {
361361
c.to_ascii().to_lower().to_char()
362362
} else {
@@ -412,8 +412,8 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
412412
}
413413
}
414414

415-
for i in range(0u, found_flags.len()) {
416-
if !found_flags[i] {
415+
for (i, &flag) in found_flags.iter().enumerate() {
416+
if !flag {
417417
let ee = &expected_errors[i];
418418
fatal_ProcRes(fmt!("expected %s on line %u not found: %s",
419419
ee.kind, ee.line, ee.msg), ProcRes);
@@ -760,7 +760,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
760760
let cmdline = make_cmdline("", args.prog, args.args);
761761

762762
// get bare program string
763-
let mut tvec: ~[~str] = args.prog.split_iter('/').transform(|ts| ts.to_owned()).collect();
763+
let mut tvec: ~[~str] = args.prog.split_iter('/').map(|ts| ts.to_owned()).collect();
764764
let prog_short = tvec.pop();
765765

766766
// copy to target
@@ -938,7 +938,7 @@ fn disassemble_extract(config: &config, _props: &TestProps,
938938

939939
fn count_extracted_lines(p: &Path) -> uint {
940940
let x = io::read_whole_file_str(&p.with_filetype("ll")).unwrap();
941-
x.line_iter().len_()
941+
x.line_iter().len()
942942
}
943943

944944

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929

3030
table))
3131

32+
(defcustom rust-indent-offset default-tab-width
33+
"*Indent Rust code by this number of spaces.
34+
35+
The initializer is `DEFAULT-TAB-WIDTH'.")
36+
3237
(defun rust-paren-level () (nth 0 (syntax-ppss)))
3338
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
3439
(defun rust-rewind-past-str-cmnt () (goto-char (nth 8 (syntax-ppss))))
@@ -49,10 +54,10 @@
4954
(let ((level (rust-paren-level)))
5055
(cond
5156
;; A function return type is 1 level indented
52-
((looking-at "->") (* default-tab-width (+ level 1)))
57+
((looking-at "->") (* rust-indent-offset (+ level 1)))
5358

5459
;; A closing brace is 1 level unindended
55-
((looking-at "}") (* default-tab-width (- level 1)))
60+
((looking-at "}") (* rust-indent-offset (- level 1)))
5661

5762
;; If we're in any other token-tree / sexp, then:
5863
;; - [ or ( means line up with the opening token
@@ -70,18 +75,18 @@
7075
(goto-char pt)
7176
(back-to-indentation)
7277
(if (looking-at "\\<else\\>")
73-
(* default-tab-width (+ 1 level))
78+
(* rust-indent-offset (+ 1 level))
7479
(progn
7580
(goto-char pt)
7681
(beginning-of-line)
7782
(rust-rewind-irrelevant)
7883
(end-of-line)
7984
(if (looking-back "[{};,]")
80-
(* default-tab-width level)
85+
(* rust-indent-offset level)
8186
(back-to-indentation)
8287
(if (looking-at "#")
83-
(* default-tab-width level)
84-
(* default-tab-width (+ 1 level))))))))))
88+
(* rust-indent-offset level)
89+
(* rust-indent-offset (+ 1 level))))))))))
8590

8691
;; Otherwise we're in a column-zero definition
8792
(t 0))))))

0 commit comments

Comments
 (0)