Skip to content

Commit c41b999

Browse files
author
Nick Desaulniers
committed
---
yaml --- r: 42883 b: refs/heads/try c: 7868b6b h: refs/heads/master i: 42881: ebbf5f9 42879: 7970bfd v: v3
1 parent be5cfe8 commit c41b999

Some content is hidden

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

78 files changed

+392
-340
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: 76679c1f91fc68134c850b2d77ff2b83b32a108f
5+
refs/heads/try: 7868b6bf550dcb1b74f25178bcac73d6ec767993
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/doc/lib/codemirror-rust.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CodeMirror.defineMode("rust", function() {
22
var indentUnit = 4, altIndentUnit = 2;
33
var valKeywords = {
44
"if": "if-style", "while": "if-style", "loop": "if-style", "else": "else-style",
5-
"do": "else-style", "return": "else-style", "fail": "else-style",
5+
"do": "else-style", "return": "else-style",
66
"break": "atom", "cont": "atom", "const": "let", "resource": "fn",
77
"let": "let", "fn": "fn", "for": "for", "match": "match", "trait": "trait",
88
"impl": "impl", "type": "type", "enum": "enum", "struct": "atom", "mod": "mod",

branches/try/doc/rust.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ break
216216
const copy
217217
do drop
218218
else enum extern
219-
fail false fn for
219+
false fn for
220220
if impl
221221
let log loop
222222
match mod move mut
@@ -692,15 +692,15 @@ mod math {
692692
type complex = (f64, f64);
693693
fn sin(f: f64) -> f64 {
694694
...
695-
# fail;
695+
# die!();
696696
}
697697
fn cos(f: f64) -> f64 {
698698
...
699-
# fail;
699+
# die!();
700700
}
701701
fn tan(f: f64) -> f64 {
702702
...
703-
# fail;
703+
# die!();
704704
}
705705
}
706706
~~~~~~~~
@@ -989,13 +989,13 @@ output slot type would normally be. For example:
989989
~~~~
990990
fn my_err(s: &str) -> ! {
991991
log(info, s);
992-
fail;
992+
die!();
993993
}
994994
~~~~
995995

996996
We call such functions "diverging" because they never return a value to the
997997
caller. Every control path in a diverging function must end with a
998-
[`fail`](#fail-expressions) or a call to another diverging function on every
998+
`fail!()` or a call to another diverging function on every
999999
control path. The `!` annotation does *not* denote a type. Rather, the result
10001000
type of a diverging function is a special type called $\bot$ ("bottom") that
10011001
unifies with any type. Rust has no syntax for $\bot$.
@@ -1007,7 +1007,7 @@ were declared without the `!` annotation, the following code would not
10071007
typecheck:
10081008

10091009
~~~~
1010-
# fn my_err(s: &str) -> ! { fail }
1010+
# fn my_err(s: &str) -> ! { die!() }
10111011
10121012
fn f(i: int) -> int {
10131013
if i == 42 {
@@ -2291,9 +2291,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
22912291
let x: List<int> = Cons(10, @Cons(11, @Nil));
22922292
22932293
match x {
2294-
Cons(_, @Nil) => fail ~"singleton list",
2294+
Cons(_, @Nil) => die!(~"singleton list"),
22952295
Cons(*) => return,
2296-
Nil => fail ~"empty list"
2296+
Nil => die!(~"empty list")
22972297
}
22982298
~~~~
22992299

@@ -2330,7 +2330,7 @@ match x {
23302330
return;
23312331
}
23322332
_ => {
2333-
fail;
2333+
die!();
23342334
}
23352335
}
23362336
~~~~
@@ -2418,23 +2418,10 @@ guard may refer to the variables bound within the pattern they follow.
24182418
let message = match maybe_digit {
24192419
Some(x) if x < 10 => process_digit(x),
24202420
Some(x) => process_other(x),
2421-
None => fail
2421+
None => die!()
24222422
};
24232423
~~~~
24242424

2425-
2426-
### Fail expressions
2427-
2428-
~~~~~~~~{.ebnf .gram}
2429-
fail_expr : "fail" expr ? ;
2430-
~~~~~~~~
2431-
2432-
Evaluating a `fail` expression causes a task to enter the *failing* state. In
2433-
the *failing* state, a task unwinds its stack, destroying all frames and
2434-
running all destructors until it reaches its entry frame, at which point it
2435-
halts execution in the *dead* state.
2436-
2437-
24382425
### Return expressions
24392426

24402427
~~~~~~~~{.ebnf .gram}
@@ -3154,7 +3141,7 @@ unblock and transition back to *running*.
31543141

31553142
A task may transition to the *failing* state at any time, due being
31563143
killed by some external event or internally, from the evaluation of a
3157-
`fail` expression. Once *failing*, a task unwinds its stack and
3144+
`fail!()` macro. Once *failing*, a task unwinds its stack and
31583145
transitions to the *dead* state. Unwinding the stack of a task is done by
31593146
the task itself, on its own control stack. If a value with a destructor is
31603147
freed during unwinding, the code for the destructor is run, also on the task's

branches/try/doc/tutorial-macros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ match x {
218218
// complicated stuff goes here
219219
return result + val;
220220
},
221-
_ => fail ~"Didn't get good_2"
221+
_ => die!(~"Didn't get good_2")
222222
}
223223
}
224224
_ => return 0 // default value
@@ -260,7 +260,7 @@ macro_rules! biased_match (
260260
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
261261
binds g1, val )
262262
biased_match!((g1.body) ~ (good_2(result) )
263-
else { fail ~"Didn't get good_2" };
263+
else { die!(~"Didn't get good_2") };
264264
binds result )
265265
// complicated stuff goes here
266266
return result + val;
@@ -362,7 +362,7 @@ macro_rules! biased_match (
362362
# fn f(x: t1) -> uint {
363363
biased_match!(
364364
(x) ~ (good_1(g1, val)) else { return 0 };
365-
(g1.body) ~ (good_2(result) ) else { fail ~"Didn't get good_2" };
365+
(g1.body) ~ (good_2(result) ) else { die!(~"Didn't get good_2") };
366366
binds val, result )
367367
// complicated stuff goes here
368368
return result + val;

branches/try/doc/tutorial-tasks.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cheaper to create than traditional threads, Rust can create hundreds of
1313
thousands of concurrent tasks on a typical 32-bit system.
1414

1515
Tasks provide failure isolation and recovery. When an exception occurs in Rust
16-
code (as a result of an explicit call to `fail`, an assertion failure, or
16+
code (as a result of an explicit call to `fail!()`, an assertion failure, or
1717
another invalid operation), the runtime system destroys the entire
1818
task. Unlike in languages such as Java and C++, there is no way to `catch` an
1919
exception. Instead, tasks may monitor each other for failure.
@@ -296,9 +296,9 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() );
296296

297297
# Handling task failure
298298

299-
Rust has a built-in mechanism for raising exceptions. The `fail` construct
300-
(which can also be written with an error string as an argument: `fail
301-
~reason`) and the `assert` construct (which effectively calls `fail` if a
299+
Rust has a built-in mechanism for raising exceptions. The `fail!()` macro
300+
(which can also be written with an error string as an argument: `fail!(
301+
~reason)`) and the `assert` construct (which effectively calls `fail!()` if a
302302
boolean expression is false) are both ways to raise exceptions. When a task
303303
raises an exception the task unwinds its stack---running destructors and
304304
freeing memory along the way---and then exits. Unlike exceptions in C++,
@@ -313,7 +313,7 @@ of all tasks are intertwined: if one fails, so do all the others.
313313
# fn do_some_work() { loop { task::yield() } }
314314
# do task::try {
315315
// Create a child task that fails
316-
do spawn { fail }
316+
do spawn { die!() }
317317
318318
// This will also fail because the task we spawned failed
319319
do_some_work();
@@ -337,7 +337,7 @@ let result: Result<int, ()> = do task::try {
337337
if some_condition() {
338338
calculate_result()
339339
} else {
340-
fail ~"oops!";
340+
die!(~"oops!");
341341
}
342342
};
343343
assert result.is_err();
@@ -354,7 +354,7 @@ an `Error` result.
354354
> ***Note:*** A failed task does not currently produce a useful error
355355
> value (`try` always returns `Err(())`). In the
356356
> future, it may be possible for tasks to intercept the value passed to
357-
> `fail`.
357+
> `fail!()`.
358358
359359
TODO: Need discussion of `future_result` in order to make failure
360360
modes useful.
@@ -377,7 +377,7 @@ either task dies, it kills the other one.
377377
# do task::try {
378378
do task::spawn {
379379
do task::spawn {
380-
fail; // All three tasks will die.
380+
die!(); // All three tasks will die.
381381
}
382382
sleep_forever(); // Will get woken up by force, then fail
383383
}
@@ -432,7 +432,7 @@ do task::spawn_supervised {
432432
// Intermediate task immediately exits
433433
}
434434
wait_for_a_while();
435-
fail; // Will kill grandchild even if child has already exited
435+
die!(); // Will kill grandchild even if child has already exited
436436
# };
437437
~~~
438438

@@ -446,10 +446,10 @@ other at all, using `task::spawn_unlinked` for _isolated failure_.
446446
let (time1, time2) = (random(), random());
447447
do task::spawn_unlinked {
448448
sleep_for(time2); // Won't get forced awake
449-
fail;
449+
die!();
450450
}
451451
sleep_for(time1); // Won't get forced awake
452-
fail;
452+
die!();
453453
// It will take MAX(time1,time2) for the program to finish.
454454
# };
455455
~~~

branches/try/mk/target.mk

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# $(2) is the target triple
1515
# $(3) is the host triple
1616

17+
# If you are making non-backwards compatible changes to the runtime
18+
# (resp. corelib), set this flag to 1. It will cause stage1 to use
19+
# the snapshot runtime (resp. corelib) rather than the runtime
20+
# (resp. corelib) from the working directory.
21+
USE_SNAPSHOT_RUNTIME=0
22+
USE_SNAPSHOT_CORELIB=0
23+
USE_SNAPSHOT_STDLIB=0
1724

1825
define TARGET_STAGE_N
1926

@@ -52,17 +59,86 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX): \
5259
@$$(call E, compile_and_link: $$@)
5360
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< && touch $$@
5461

62+
endef
63+
64+
# The stage0 (snapshot) compiler produces binaries that expect the
65+
# snapshot runtime. Normally the working directory runtime and
66+
# snapshot runtime are compatible, so this is no problem. But
67+
# sometimes we want to make non-backwards-compatible changes. In
68+
# those cases, the stage1 compiler and libraries (which are produced
69+
# by stage0) should use the runtime from the snapshot. The stage2
70+
# compiler and libraries (which are produced by stage1) will be the
71+
# first that are expecting to run against the runtime as defined in
72+
# the working directory.
73+
#
74+
# The catch is that you may not add new functions to the runtime
75+
# in this case!
76+
#
77+
# Arguments are the same as for TARGET_BASE_STAGE_N
78+
define TARGET_RT_FROM_SNAPSHOT
79+
80+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \
81+
$$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME)
82+
@$$(call E, cp: $$@)
83+
$$(Q)cp $$< $$@
84+
85+
endef
86+
87+
# This rule copies from the runtime for the working directory. It
88+
# applies to targets produced by stage1 or later. See comment on
89+
# previous rule.
90+
#
91+
# Arguments are the same as for TARGET_BASE_STAGE_N
92+
define TARGET_RT_FROM_WD
93+
5594
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \
5695
rt/$(2)/$$(CFG_RUNTIME)
5796
@$$(call E, cp: $$@)
5897
$$(Q)cp $$< $$@
5998

99+
endef
100+
101+
# As above, but builds the corelib either by taking it out of the
102+
# snapshot or from the working directory.
103+
104+
define TARGET_CORELIB_FROM_SNAPSHOT
105+
106+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
107+
$$(HLIB$(1)_H_$(3))/$$(CFG_CORELIB) \
108+
$$(CORELIB_INPUTS) \
109+
$$(TSREQ$(1)_T_$(2)_H_$(3))
110+
@$$(call E, cp: $$@)
111+
$$(Q)cp $$< $$@
112+
$$(Q)cp $$(HLIB$(1)_H_$(3))/$$(CORELIB_GLOB) \
113+
$$(TLIB$(1)_T_$(2)_H_$(3))
114+
115+
endef
116+
117+
define TARGET_CORELIB_FROM_WD
118+
60119
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
61120
$$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
62121
$$(TSREQ$(1)_T_$(2)_H_$(3))
63122
@$$(call E, compile_and_link: $$@)
64123
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
65124

125+
endef
126+
127+
define TARGET_STDLIB_FROM_SNAPSHOT
128+
129+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
130+
$$(HLIB$(1)_H_$(3))/$$(CFG_STDLIB) \
131+
$$(STDLIB_INPUTS) \
132+
$$(TSREQ$(1)_T_$(2)_H_$(3))
133+
@$$(call E, cp: $$@)
134+
$$(Q)cp $$< $$@
135+
$$(Q)cp $$(HLIB$(1)_H_$(3))/$$(STDLIB_GLOB) \
136+
$$(TLIB$(1)_T_$(2)_H_$(3))
137+
138+
endef
139+
140+
define TARGET_STDLIB_FROM_WD
141+
66142
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
67143
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
68144
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
@@ -79,3 +155,52 @@ $(foreach source,$(CFG_TARGET_TRIPLES), \
79155
$(eval $(call TARGET_STAGE_N,1,$(target),$(source))) \
80156
$(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \
81157
$(eval $(call TARGET_STAGE_N,3,$(target),$(source)))))
158+
159+
# Host triple either uses the snapshot runtime or runtime from
160+
# working directory, depending on the USE_SNAPSHOT_RUNTIME var.
161+
ifeq ($(USE_SNAPSHOT_RUNTIME),1)
162+
$(foreach src,$(CFG_HOST_TRIPLE),\
163+
$(eval $(call TARGET_RT_FROM_SNAPSHOT,0,$(src),$(src))))
164+
else
165+
$(foreach src,$(CFG_HOST_TRIPLE),\
166+
$(eval $(call TARGET_RT_FROM_WD,0,$(src),$(src))))
167+
endif
168+
169+
ifeq ($(USE_SNAPSHOT_CORELIB),1)
170+
$(foreach src,$(CFG_HOST_TRIPLE),\
171+
$(eval $(call TARGET_CORELIB_FROM_SNAPSHOT,0,$(src),$(src))))
172+
else
173+
$(foreach src,$(CFG_HOST_TRIPLE),\
174+
$(eval $(call TARGET_CORELIB_FROM_WD,0,$(src),$(src))))
175+
endif
176+
177+
ifeq ($(USE_SNAPSHOT_STDLIB),1)
178+
$(foreach src,$(CFG_HOST_TRIPLE),\
179+
$(eval $(call TARGET_STDLIB_FROM_SNAPSHOT,0,$(src),$(src))))
180+
else
181+
$(foreach src,$(CFG_HOST_TRIPLE),\
182+
$(eval $(call TARGET_STDLIB_FROM_WD,0,$(src),$(src))))
183+
endif
184+
185+
# Non-host triples build the stage0 runtime from the working directory
186+
$(foreach source,$(CFG_TARGET_TRIPLES), \
187+
$(foreach target,$(NON_HOST_TRIPLES), \
188+
$(eval $(call TARGET_RT_FROM_WD,0,$(target),$(source))) \
189+
$(eval $(call TARGET_CORELIB_FROM_WD,0,$(target),$(source))) \
190+
$(eval $(call TARGET_STDLIB_FROM_WD,0,$(target),$(source))) \
191+
))
192+
193+
# After stage0, always build the stage0 runtime from the working directory
194+
$(foreach source,$(CFG_TARGET_TRIPLES), \
195+
$(foreach target,$(CFG_TARGET_TRIPLES), \
196+
$(eval $(call TARGET_RT_FROM_WD,1,$(target),$(source))) \
197+
$(eval $(call TARGET_RT_FROM_WD,2,$(target),$(source))) \
198+
$(eval $(call TARGET_RT_FROM_WD,3,$(target),$(source))) \
199+
$(eval $(call TARGET_CORELIB_FROM_WD,1,$(target),$(source))) \
200+
$(eval $(call TARGET_CORELIB_FROM_WD,2,$(target),$(source))) \
201+
$(eval $(call TARGET_CORELIB_FROM_WD,3,$(target),$(source))) \
202+
$(eval $(call TARGET_STDLIB_FROM_WD,1,$(target),$(source))) \
203+
$(eval $(call TARGET_STDLIB_FROM_WD,2,$(target),$(source))) \
204+
$(eval $(call TARGET_STDLIB_FROM_WD,3,$(target),$(source))) \
205+
))
206+

branches/try/src/libcargo/cargo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
460460
json::Object(j) => {
461461
let mut url = match j.find(&~"url") {
462462
Some(&json::String(u)) => copy u,
463-
_ => fail ~"needed 'url' field in source"
463+
_ => die!(~"needed 'url' field in source")
464464
};
465465
let method = match j.find(&~"method") {
466466
Some(&json::String(u)) => copy u,

0 commit comments

Comments
 (0)