Skip to content

Commit ffda839

Browse files
committed
---
yaml --- r: 12276 b: refs/heads/master c: 21be137 h: refs/heads/master v: v3
1 parent de66119 commit ffda839

Some content is hidden

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

59 files changed

+309
-587
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: e1858882a49bf0666d4ffb3f45989ac9dbe9c843
2+
refs/heads/master: 21be1379d561b6679a8a2ea47dce88f948c5acca
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ for the parameter list, as in `{|| ...}`.
919919
Partial application is done using the `bind` keyword in Rust.
920920

921921
~~~~
922-
let daynum = bind vec::position_elem(["mo", "tu", "we", "do",
922+
let daynum = bind vec::position_elem(["mo", "tu", "we", "th",
923923
"fr", "sa", "su"], _);
924924
~~~~
925925

@@ -1551,7 +1551,7 @@ programs that just can't be typed.
15511551

15521552
~~~~
15531553
let n = option::none;
1554-
# option::may(n, fn&(&&x:int) {})
1554+
# option::with_option_do(n, fn&(&&x:int) {})
15551555
~~~~
15561556

15571557
If you never do anything else with `n`, the compiler will not be able

trunk/mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ RUNTIME_CS_$(1) := \
6464
rt/rust_port_selector.cpp \
6565
rt/circular_buffer.cpp \
6666
rt/isaac/randport.cpp \
67-
rt/rust_srv.cpp \
6867
rt/rust_kernel.cpp \
6968
rt/rust_shape.cpp \
7069
rt/rust_abi.cpp \

trunk/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn load_props(testfile: str) -> test_props {
4040
pp_exact = parse_pp_exact(ln, testfile);
4141
}
4242

43-
option::may(parse_aux_build(ln)) {|ab|
43+
option::with_option_do(parse_aux_build(ln)) {|ab|
4444
aux_builds += [ab];
4545
}
4646
};

trunk/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<A> of iterable<A> for [A] {
2929

3030
impl<A> of iterable<A> for option<A> {
3131
fn iter(blk: fn(A)) {
32-
option::may(self, blk)
32+
option::with_option_do(self, blk)
3333
}
3434
}
3535

trunk/src/libcore/option.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ pure fn is_some<T>(opt: option<T>) -> bool {
5252
!is_none(opt)
5353
}
5454

55-
pure fn from_maybe<T: copy>(opt: option<T>, def: T) -> T {
55+
pure fn get_or_default<T: copy>(opt: option<T>, def: T) -> T {
5656
#[doc = "Returns the contained value or a default"];
5757

5858
alt opt { some(x) { x } none { def } }
5959
}
6060

61-
fn maybe<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
61+
fn with_option<T, U: copy>(opt: option<T>, def: U, f: fn(T) -> U) -> U {
6262
#[doc = "Applies a function to the contained value or returns a default"];
6363

6464
alt opt { none { def } some(t) { f(t) } }
6565
}
6666

67-
fn may<T>(opt: option<T>, f: fn(T)) {
67+
fn with_option_do<T>(opt: option<T>, f: fn(T)) {
6868
#[doc = "Performs an operation on the contained value or does nothing"];
6969

7070
alt opt { none { } some(t) { f(t); } }
@@ -94,11 +94,12 @@ impl extensions<T:copy> for option<T> {
9494
"]
9595
fn chain<U>(f: fn(T) -> option<U>) -> option<U> { chain(self, f) }
9696
#[doc = "Returns the contained value or a default"]
97-
fn from_maybe(def: T) -> T { from_maybe(self, def) }
97+
fn get_or_default(def: T) -> T { get_or_default(self, def) }
9898
#[doc = "Applies a function to the contained value or returns a default"]
99-
fn maybe<U: copy>(def: U, f: fn(T) -> U) -> U { maybe(self, def, f) }
99+
fn with_option<U: copy>(def: U, f: fn(T) -> U) -> U
100+
{ with_option(self, def, f) }
100101
#[doc = "Performs an operation on the contained value or does nothing"]
101-
fn may(f: fn(T)) { may(self, f) }
102+
fn with_option_do(f: fn(T)) { with_option_do(self, f) }
102103
#[doc = "
103104
Gets the value out of an option
104105

trunk/src/libcore/os.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ mod tests {
702702
setenv("HOME", "");
703703
assert os::homedir() == none;
704704

705-
option::may(oldhome, {|s| setenv("HOME", s)});
705+
option::with_option_do(oldhome, {|s| setenv("HOME", s)});
706706
}
707707

708708
#[test]
@@ -732,8 +732,9 @@ mod tests {
732732
setenv("USERPROFILE", "/home/PaloAlto");
733733
assert os::homedir() == some("/home/MountainView");
734734

735-
option::may(oldhome, {|s| setenv("HOME", s)});
736-
option::may(olduserprofile, {|s| setenv("USERPROFILE", s)});
735+
option::with_option_do(oldhome, {|s| setenv("HOME", s)});
736+
option::with_option_do(olduserprofile,
737+
{|s| setenv("USERPROFILE", s)});
737738
}
738739

739740
// Issue #712

trunk/src/libcore/result.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ If the result is an error
2020
pure fn get<T: copy, U>(res: result<T, U>) -> T {
2121
alt res {
2222
ok(t) { t }
23-
err(_) {
24-
// FIXME: Serialize the error value
25-
// and include it in the fail message (maybe just note it)
26-
fail "get called on error result";
23+
err(the_err) {
24+
// FIXME: have a run-fail test for this
25+
unchecked{ fail #fmt("get called on error result: %?", the_err); }
2726
}
2827
}
2928
}

trunk/src/libcore/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
498498
}
499499
};
500500

501-
option::may(opts.notify_chan) {|c|
501+
option::with_option_do(opts.notify_chan) {|c|
502502
// FIXME (1087): Would like to do notification in Rust
503503
rustrt::rust_task_config_notify(new_task, c);
504504
}

trunk/src/librustsyntax/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
243243
}
244244

245245
fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
246-
option::may (sp.expn_info) {|ei|
247-
let ss = option::maybe(ei.callie.span, "",
246+
option::with_option_do (sp.expn_info) {|ei|
247+
let ss = option::with_option(ei.callie.span, "",
248248
bind codemap::span_to_str(_, cm));
249249
print_diagnostic(ss, note,
250250
#fmt("in expansion of #%s", ei.callie.name));

trunk/src/librustsyntax/ext/qquote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
135135
-> @ast::expr
136136
{
137137
let mut what = "expr";
138-
option::may(arg) {|arg|
138+
option::with_option_do(arg) {|arg|
139139
let args: [@ast::expr] =
140140
alt arg.node {
141141
ast::expr_vec(elts, _) { elts }

trunk/src/librustsyntax/parse/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: [@ast::crate_directive],
2323
-> (ast::_mod, [ast::attribute]) {
2424
#debug("eval crate prefix: %s", prefix);
2525
#debug("eval crate suffix: %s",
26-
option::from_maybe(suffix, "none"));
26+
option::get_or_default(suffix, "none"));
2727
let (cview_items, citems, cattrs)
2828
= parse_companion_mod(cx, prefix, suffix);
2929
let mut view_items: [@ast::view_item] = [];

trunk/src/librustsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ fn print_mac(s: ps, m: ast::mac) {
792792
some(@{node: ast::expr_vec(_, _), _}) { }
793793
_ { word(s.s, " "); }
794794
}
795-
option::may(arg, bind print_expr(s, _));
795+
option::with_option_do(arg, bind print_expr(s, _));
796796
// FIXME: extension 'body'
797797
}
798798
ast::mac_embed_type(ty) {

trunk/src/librustsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
225225
}
226226
pat_ident(path, inner) {
227227
visit_path(path, e, v);
228-
option::may(inner, {|subpat| v.visit_pat(subpat, e, v)});
228+
option::with_option_do(inner, {|subpat| v.visit_pat(subpat, e, v)});
229229
}
230230
pat_lit(ex) { v.visit_expr(ex, e, v); }
231231
pat_range(e1, e2) { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); }

trunk/src/rt/circular_buffer.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ circular_buffer::circular_buffer(rust_kernel *kernel, size_t unit_sz) :
1212
_unread(0),
1313
_buffer((uint8_t *)kernel->malloc(_buffer_sz, "circular_buffer")) {
1414

15-
A(kernel, unit_sz, "Unit size must be larger than zero.");
15+
assert(unit_sz && "Unit size must be larger than zero.");
1616

1717
KLOG(kernel, mem, "new circular_buffer(buffer_sz=%d, unread=%d)"
1818
"-> circular_buffer=0x%" PRIxPTR,
1919
_buffer_sz, _unread, this);
2020

21-
A(kernel, _buffer, "Failed to allocate buffer.");
21+
assert(_buffer && "Failed to allocate buffer.");
2222
}
2323

2424
circular_buffer::~circular_buffer() {
2525
KLOG(kernel, mem, "~circular_buffer 0x%" PRIxPTR, this);
26-
I(kernel, _buffer);
27-
W(kernel, _unread == 0,
28-
"freeing circular_buffer with %d unread bytes", _unread);
26+
assert(_buffer);
27+
assert(_unread == 0 && "didn't expect bytes in the circular buffer");
28+
2929
kernel->free(_buffer);
3030
}
3131

3232
size_t
3333
circular_buffer::initial_size() {
34-
I(kernel, unit_sz > 0);
34+
assert(unit_sz > 0);
3535
return INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS * unit_sz;
3636
}
3737

@@ -40,8 +40,8 @@ circular_buffer::initial_size() {
4040
*/
4141
void
4242
circular_buffer::transfer(void *dst) {
43-
I(kernel, dst);
44-
I(kernel, _unread <= _buffer_sz);
43+
assert(dst);
44+
assert(_unread <= _buffer_sz);
4545

4646
uint8_t *ptr = (uint8_t *) dst;
4747

@@ -53,13 +53,13 @@ circular_buffer::transfer(void *dst) {
5353
} else {
5454
head_sz = _buffer_sz - _next;
5555
}
56-
I(kernel, _next + head_sz <= _buffer_sz);
56+
assert(_next + head_sz <= _buffer_sz);
5757
memcpy(ptr, _buffer + _next, head_sz);
5858

5959
// Then copy any other items from the beginning of the buffer
60-
I(kernel, _unread >= head_sz);
60+
assert(_unread >= head_sz);
6161
size_t tail_sz = _unread - head_sz;
62-
I(kernel, head_sz + tail_sz <= _buffer_sz);
62+
assert(head_sz + tail_sz <= _buffer_sz);
6363
memcpy(ptr + head_sz, _buffer, tail_sz);
6464
}
6565

@@ -69,9 +69,9 @@ circular_buffer::transfer(void *dst) {
6969
*/
7070
void
7171
circular_buffer::enqueue(void *src) {
72-
I(kernel, src);
73-
I(kernel, _unread <= _buffer_sz);
74-
I(kernel, _buffer);
72+
assert(src);
73+
assert(_unread <= _buffer_sz);
74+
assert(_buffer);
7575

7676
// Grow if necessary.
7777
if (_unread == _buffer_sz) {
@@ -82,20 +82,20 @@ circular_buffer::enqueue(void *src) {
8282
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
8383
_unread, _next, _buffer_sz, unit_sz);
8484

85-
I(kernel, _unread < _buffer_sz);
86-
I(kernel, _unread + unit_sz <= _buffer_sz);
85+
assert(_unread < _buffer_sz);
86+
assert(_unread + unit_sz <= _buffer_sz);
8787

8888
// Copy data
8989
size_t dst_idx = _next + _unread;
90-
I(kernel, dst_idx >= _buffer_sz || dst_idx + unit_sz <= _buffer_sz);
90+
assert(dst_idx >= _buffer_sz || dst_idx + unit_sz <= _buffer_sz);
9191
if (dst_idx >= _buffer_sz) {
9292
dst_idx -= _buffer_sz;
9393

94-
I(kernel, _next >= unit_sz);
95-
I(kernel, dst_idx <= _next - unit_sz);
94+
assert(_next >= unit_sz);
95+
assert(dst_idx <= _next - unit_sz);
9696
}
9797

98-
I(kernel, dst_idx + unit_sz <= _buffer_sz);
98+
assert(dst_idx + unit_sz <= _buffer_sz);
9999
memcpy(&_buffer[dst_idx], src, unit_sz);
100100
_unread += unit_sz;
101101

@@ -109,17 +109,17 @@ circular_buffer::enqueue(void *src) {
109109
*/
110110
void
111111
circular_buffer::dequeue(void *dst) {
112-
I(kernel, unit_sz > 0);
113-
I(kernel, _unread >= unit_sz);
114-
I(kernel, _unread <= _buffer_sz);
115-
I(kernel, _buffer);
112+
assert(unit_sz > 0);
113+
assert(_unread >= unit_sz);
114+
assert(_unread <= _buffer_sz);
115+
assert(_buffer);
116116

117117
KLOG(kernel, mem,
118118
"circular_buffer dequeue "
119119
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
120120
_unread, _next, _buffer_sz, unit_sz);
121121

122-
I(kernel, _next + unit_sz <= _buffer_sz);
122+
assert(_next + unit_sz <= _buffer_sz);
123123
if (dst != NULL) {
124124
memcpy(dst, &_buffer[_next], unit_sz);
125125
}
@@ -153,7 +153,7 @@ circular_buffer::grow() {
153153
void
154154
circular_buffer::shrink() {
155155
size_t new_buffer_sz = _buffer_sz / 2;
156-
I(kernel, initial_size() <= new_buffer_sz);
156+
assert(initial_size() <= new_buffer_sz);
157157
KLOG(kernel, mem, "circular_buffer is shrinking to %d bytes",
158158
new_buffer_sz);
159159
void *new_buffer = kernel->malloc(new_buffer_sz,

0 commit comments

Comments
 (0)