Skip to content

Commit 34ee767

Browse files
committed
---
yaml --- r: 13781 b: refs/heads/try c: 87320a9 h: refs/heads/master i: 13779: 7f481c6 v: v3
1 parent 12dc9a7 commit 34ee767

39 files changed

+241
-474
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: edd86126f7d35c698d93236cdcc713e5f0a2db53
5+
refs/heads/try: 87320a9f2768e5e011a6c8edaceb3d3b7ddc2747
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/AUTHORS.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Jeff Balogh <[email protected]>
2626
Jeff Muizelaar <[email protected]>
2727
Jeffrey Yasskin <[email protected]>
2828
Jesse Ruderman <[email protected]>
29-
Joe Pletcher <[email protected]>
3029
Josh Matthews <[email protected]>
3130
Joshua Clark <[email protected]>
3231
Joshua Wise <[email protected]>

branches/try/doc/rust.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,9 +1058,7 @@ accessed through the components `x` and `y`, and laid out in memory with the
10581058
An _enumeration item_ simultaneously declares a new nominal
10591059
[enumerated type](#enumerated-types) as well as a set of *constructors* that
10601060
can be used to create or pattern-match values of the corresponding enumerated
1061-
type. Note that `enum` previously was refered to as a `tag`, however this
1062-
definition has been deprecated. While `tag` is no longer used, the two are
1063-
synonymous.
1061+
type.
10641062

10651063
The constructors of an `enum` type may be recursive: that is, each constructor
10661064
may take an argument that refers, directly or indirectly, to the enumerated
@@ -2009,7 +2007,7 @@ alt_pat : pat [ "to" pat ] ? [ "if" expr ] ;
20092007

20102008
An `alt` expression branches on a *pattern*. The exact form of matching that
20112009
occurs depends on the pattern. Patterns consist of some combination of
2012-
literals, destructured enum constructors, records and tuples, variable binding
2010+
literals, destructured tag constructors, records and tuples, variable binding
20132011
specifications and placeholders (`_`). An `alt` expression has a *head
20142012
expression*, which is the value to compare to the patterns. The type of the
20152013
patterns must equal the type of the head expression.
@@ -2024,7 +2022,7 @@ An example of an `alt` expression:
20242022

20252023

20262024
~~~~
2027-
enum list<X> { nil; cons(X, @list<X>); }
2025+
tag list<X> { nil; cons(X, @list<X>); }
20282026
20292027
let x: list<int> = cons(10, @cons(11, @nil));
20302028
@@ -3288,7 +3286,7 @@ such as vectors, strings, and the low level communication system (ports,
32883286
channels, tasks).
32893287

32903288
Support for other built-in types such as simple types, tuples, records, and
3291-
enums is open-coded by the Rust compiler.
3289+
tags is open-coded by the Rust compiler.
32923290

32933291

32943292

branches/try/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ destructors. Resources might go away in the future.
13461346
Rust datatypes are not trivial to copy (the way, for example,
13471347
JavaScript values can be copied by simply taking one or two machine
13481348
words and plunking them somewhere else). Shared boxes require
1349-
reference count updates, big records, enums, or unique pointers require
1349+
reference count updates, big records, tags, or unique pointers require
13501350
an arbitrary amount of data to be copied (plus updating the reference
13511351
counts of shared boxes hanging off them).
13521352

@@ -1459,7 +1459,7 @@ alt my_rec {
14591459

14601460
The fact that arguments are conceptually passed by safe reference does
14611461
not mean all arguments are passed by pointer. Composite types like
1462-
records and enums *are* passed by pointer, but single-word values, like
1462+
records and tags *are* passed by pointer, but single-word values, like
14631463
integers and pointers, are simply passed by value. Most of the time,
14641464
the programmer does not have to worry about this, as the compiler will
14651465
simply pick the most efficient passing style. There is one exception,

branches/try/src/cargo/cargo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,10 @@ fn load_link(mis: [@ast::meta_item]) -> (option::t<str>,
100100

101101
fn load_pkg(filename: str) -> option::t<pkg> {
102102
let cm = codemap::new_codemap();
103-
let handler = diagnostic::mk_handler(none);
104103
let sess = @{
105104
cm: cm,
106105
mutable next_id: 1,
107-
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
106+
diagnostic: diagnostic::mk_handler(cm, none),
108107
mutable chpos: 0u,
109108
mutable byte_pos: 0u
110109
};

branches/try/src/comp/driver/diagnostic.rs

Lines changed: 36 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,83 +5,51 @@ import codemap::span;
55

66
export emitter, emit;
77
export level, fatal, error, warning, note;
8-
export span_handler, handler, mk_span_handler, mk_handler;
9-
export codemap_span_handler, codemap_handler;
8+
export handler, mk_handler;
109
export ice_msg;
1110

1211
type emitter = fn@(cmsp: option<(codemap::codemap, span)>,
1312
msg: str, lvl: level);
1413

1514

16-
iface span_handler {
17-
fn span_fatal(sp: span, msg: str) -> !;
18-
fn span_err(sp: span, msg: str);
19-
fn span_warn(sp: span, msg: str);
20-
fn span_note(sp: span, msg: str);
21-
fn span_bug(sp: span, msg: str) -> !;
22-
fn span_unimpl(sp: span, msg: str) -> !;
23-
fn handler() -> handler;
24-
}
25-
2615
iface handler {
16+
fn span_fatal(sp: span, msg: str) -> !;
2717
fn fatal(msg: str) -> !;
18+
fn span_err(sp: span, msg: str);
2819
fn err(msg: str);
29-
fn bump_err_count();
3020
fn has_errors() -> bool;
3121
fn abort_if_errors();
22+
fn span_warn(sp: span, msg: str);
3223
fn warn(msg: str);
24+
fn span_note(sp: span, msg: str);
3325
fn note(msg: str);
26+
fn span_bug(sp: span, msg: str) -> !;
3427
fn bug(msg: str) -> !;
28+
fn span_unimpl(sp: span, msg: str) -> !;
3529
fn unimpl(msg: str) -> !;
36-
fn emit(cmsp: option<(codemap::codemap, span)>, msg: str, lvl: level);
3730
}
3831

39-
type handler_t = @{
40-
mutable err_count: uint,
41-
_emit: emitter
42-
};
43-
4432
type codemap_t = @{
45-
handler: handler,
46-
cm: codemap::codemap
33+
cm: codemap::codemap,
34+
mutable err_count: uint,
35+
emit: emitter
4736
};
4837

49-
impl codemap_span_handler of span_handler for codemap_t {
38+
impl codemap_handler of handler for codemap_t {
5039
fn span_fatal(sp: span, msg: str) -> ! {
51-
self.handler.emit(some((self.cm, sp)), msg, fatal);
40+
self.emit(some((self.cm, sp)), msg, fatal);
5241
fail;
5342
}
54-
fn span_err(sp: span, msg: str) {
55-
self.handler.emit(some((self.cm, sp)), msg, error);
56-
self.handler.bump_err_count();
57-
}
58-
fn span_warn(sp: span, msg: str) {
59-
self.handler.emit(some((self.cm, sp)), msg, warning);
60-
}
61-
fn span_note(sp: span, msg: str) {
62-
self.handler.emit(some((self.cm, sp)), msg, note);
63-
}
64-
fn span_bug(sp: span, msg: str) -> ! {
65-
self.span_fatal(sp, ice_msg(msg));
66-
}
67-
fn span_unimpl(sp: span, msg: str) -> ! {
68-
self.span_bug(sp, "unimplemented " + msg);
69-
}
70-
fn handler() -> handler {
71-
self.handler
72-
}
73-
}
74-
75-
impl codemap_handler of handler for handler_t {
7643
fn fatal(msg: str) -> ! {
77-
self._emit(none, msg, fatal);
44+
self.emit(none, msg, fatal);
7845
fail;
7946
}
80-
fn err(msg: str) {
81-
self._emit(none, msg, error);
82-
self.bump_err_count();
47+
fn span_err(sp: span, msg: str) {
48+
self.emit(some((self.cm, sp)), msg, error);
49+
self.err_count += 1u;
8350
}
84-
fn bump_err_count() {
51+
fn err(msg: str) {
52+
self.emit(none, msg, error);
8553
self.err_count += 1u;
8654
}
8755
fn has_errors() -> bool { self.err_count > 0u }
@@ -90,30 +58,36 @@ impl codemap_handler of handler for handler_t {
9058
self.fatal("aborting due to previous errors");
9159
}
9260
}
61+
fn span_warn(sp: span, msg: str) {
62+
self.emit(some((self.cm, sp)), msg, warning);
63+
}
9364
fn warn(msg: str) {
94-
self._emit(none, msg, warning);
65+
self.emit(none, msg, warning);
66+
}
67+
fn span_note(sp: span, msg: str) {
68+
self.emit(some((self.cm, sp)), msg, note);
9569
}
9670
fn note(msg: str) {
97-
self._emit(none, msg, note);
71+
self.emit(none, msg, note);
72+
}
73+
fn span_bug(sp: span, msg: str) -> ! {
74+
self.span_fatal(sp, ice_msg(msg));
9875
}
9976
fn bug(msg: str) -> ! {
10077
self.fatal(ice_msg(msg));
10178
}
102-
fn unimpl(msg: str) -> ! { self.bug("unimplemented " + msg); }
103-
fn emit(cmsp: option<(codemap::codemap, span)>, msg: str, lvl: level) {
104-
self._emit(cmsp, msg, lvl);
79+
fn span_unimpl(sp: span, msg: str) -> ! {
80+
self.span_bug(sp, "unimplemented " + msg);
10581
}
82+
fn unimpl(msg: str) -> ! { self.bug("unimplemented " + msg); }
10683
}
10784

10885
fn ice_msg(msg: str) -> str {
10986
#fmt["internal compiler error %s", msg]
11087
}
11188

112-
fn mk_span_handler(handler: handler, cm: codemap::codemap) -> span_handler {
113-
@{ handler: handler, cm: cm } as span_handler
114-
}
115-
116-
fn mk_handler(emitter: option<emitter>) -> handler {
89+
fn mk_handler(cm: codemap::codemap,
90+
emitter: option<emitter>) -> handler {
11791

11892
let emit = alt emitter {
11993
some(e) { e }
@@ -127,8 +101,9 @@ fn mk_handler(emitter: option<emitter>) -> handler {
127101
};
128102

129103
@{
104+
cm: cm,
130105
mutable err_count: 0u,
131-
_emit: emit
106+
emit: emit
132107
} as handler
133108
}
134109

branches/try/src/comp/driver/driver.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn get_input_str(sess: session, infile: str) -> str {
9696
}
9797
}
9898
} else { io::stdin() };
99-
str::unsafe_from_bytes(stream.read_whole_stream())
99+
str::from_bytes(stream.read_whole_stream())
100100
}
101101

102102
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
@@ -299,7 +299,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
299299
}
300300
ppm_expanded | ppm_normal {}
301301
}
302-
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input,
302+
pprust::print_crate(sess.codemap, sess.diagnostic, crate, input,
303303
io::string_reader(src), io::stdout(), ann);
304304
}
305305

@@ -481,23 +481,21 @@ fn build_session(sopts: @session::options, input: str,
481481
sopts.addl_lib_search_paths);
482482
let codemap = codemap::new_codemap();
483483
let diagnostic_handler =
484-
diagnostic::mk_handler(some(demitter));
485-
let span_diagnostic_handler =
486-
diagnostic::mk_span_handler(diagnostic_handler, codemap);
484+
diagnostic::mk_handler(codemap, some(demitter));
487485
@{targ_cfg: target_cfg,
488486
opts: sopts,
489487
cstore: cstore,
490488
parse_sess: @{
491489
cm: codemap,
492490
mutable next_id: 1,
493-
span_diagnostic: span_diagnostic_handler,
491+
diagnostic: diagnostic_handler,
494492
mutable chpos: 0u,
495493
mutable byte_pos: 0u
496494
},
497495
codemap: codemap,
498496
// For a library crate, this is always none
499497
mutable main_fn: none,
500-
span_diagnostic: span_diagnostic_handler,
498+
diagnostic: diagnostic_handler,
501499
filesearch: filesearch,
502500
mutable building_library: false,
503501
working_dir: fs::dirname(input)}

branches/try/src/comp/driver/session.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,53 +60,53 @@ type session = @{targ_cfg: @config,
6060
codemap: codemap::codemap,
6161
// For a library crate, this is always none
6262
mutable main_fn: option::t<node_id>,
63-
span_diagnostic: diagnostic::span_handler,
63+
diagnostic: diagnostic::handler,
6464
filesearch: filesearch::filesearch,
6565
mutable building_library: bool,
6666
working_dir: str};
6767

6868
impl session for session {
6969
fn span_fatal(sp: span, msg: str) -> ! {
70-
self.span_diagnostic.span_fatal(sp, msg)
70+
self.diagnostic.span_fatal(sp, msg)
7171
}
7272
fn fatal(msg: str) -> ! {
73-
self.span_diagnostic.handler().fatal(msg)
73+
self.diagnostic.fatal(msg)
7474
}
7575
fn span_err(sp: span, msg: str) {
76-
self.span_diagnostic.span_err(sp, msg)
76+
self.diagnostic.span_err(sp, msg)
7777
}
7878
fn err(msg: str) {
79-
self.span_diagnostic.handler().err(msg)
79+
self.diagnostic.err(msg)
8080
}
8181
fn has_errors() -> bool {
82-
self.span_diagnostic.handler().has_errors()
82+
self.diagnostic.has_errors()
8383
}
8484
fn abort_if_errors() {
85-
self.span_diagnostic.handler().abort_if_errors()
85+
self.diagnostic.abort_if_errors()
8686
}
8787
fn span_warn(sp: span, msg: str) {
88-
self.span_diagnostic.span_warn(sp, msg)
88+
self.diagnostic.span_warn(sp, msg)
8989
}
9090
fn warn(msg: str) {
91-
self.span_diagnostic.handler().warn(msg)
91+
self.diagnostic.warn(msg)
9292
}
9393
fn span_note(sp: span, msg: str) {
94-
self.span_diagnostic.span_note(sp, msg)
94+
self.diagnostic.span_note(sp, msg)
9595
}
9696
fn note(msg: str) {
97-
self.span_diagnostic.handler().note(msg)
97+
self.diagnostic.note(msg)
9898
}
9999
fn span_bug(sp: span, msg: str) -> ! {
100-
self.span_diagnostic.span_bug(sp, msg)
100+
self.diagnostic.span_bug(sp, msg)
101101
}
102102
fn bug(msg: str) -> ! {
103-
self.span_diagnostic.handler().bug(msg)
103+
self.diagnostic.bug(msg)
104104
}
105105
fn span_unimpl(sp: span, msg: str) -> ! {
106-
self.span_diagnostic.span_unimpl(sp, msg)
106+
self.diagnostic.span_unimpl(sp, msg)
107107
}
108108
fn unimpl(msg: str) -> ! {
109-
self.span_diagnostic.handler().unimpl(msg)
109+
self.diagnostic.unimpl(msg)
110110
}
111111
fn next_node_id() -> ast::node_id {
112112
ret syntax::parse::parser::next_node_id(self.parse_sess);

0 commit comments

Comments
 (0)