Skip to content

Commit 2956ceb

Browse files
committed
---
yaml --- r: 13785 b: refs/heads/try c: 2f0f6c7 h: refs/heads/master i: 13783: 2e45ab6 v: v3
1 parent a774009 commit 2956ceb

Some content is hidden

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

41 files changed

+485
-251
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: fec36de94e02e9c7c6fec05a2aea32bfbdc2f0f8
5+
refs/heads/try: 2f0f6c782a881b19a183b368c11a0b74ef10566c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/AUTHORS.txt

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

branches/try/doc/rust.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@ 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.
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.
10621064

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

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

20232025

20242026
~~~~
2025-
tag list<X> { nil; cons(X, @list<X>); }
2027+
enum list<X> { nil; cons(X, @list<X>); }
20262028
20272029
let x: list<int> = cons(10, @cons(11, @nil));
20282030
@@ -3286,7 +3288,7 @@ such as vectors, strings, and the low level communication system (ports,
32863288
channels, tasks).
32873289

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

32913293

32923294

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, tags, or unique pointers require
1349+
reference count updates, big records, enums, 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 tags *are* passed by pointer, but single-word values, like
1462+
records and enums *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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ 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);
103104
let sess = @{
104105
cm: cm,
105106
mutable next_id: 1,
106-
diagnostic: diagnostic::mk_handler(cm, none),
107+
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
107108
mutable chpos: 0u,
108109
mutable byte_pos: 0u
109110
};

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

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

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

1112
type emitter = fn@(cmsp: option<(codemap::codemap, span)>,
1213
msg: str, lvl: level);
1314

1415

15-
iface handler {
16+
iface span_handler {
1617
fn span_fatal(sp: span, msg: str) -> !;
17-
fn fatal(msg: str) -> !;
1818
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+
26+
iface handler {
27+
fn fatal(msg: str) -> !;
1928
fn err(msg: str);
29+
fn bump_err_count();
2030
fn has_errors() -> bool;
2131
fn abort_if_errors();
22-
fn span_warn(sp: span, msg: str);
2332
fn warn(msg: str);
24-
fn span_note(sp: span, msg: str);
2533
fn note(msg: str);
26-
fn span_bug(sp: span, msg: str) -> !;
2734
fn bug(msg: str) -> !;
28-
fn span_unimpl(sp: span, msg: str) -> !;
2935
fn unimpl(msg: str) -> !;
36+
fn emit(cmsp: option<(codemap::codemap, span)>, msg: str, lvl: level);
3037
}
3138

32-
type codemap_t = @{
33-
cm: codemap::codemap,
39+
type handler_t = @{
3440
mutable err_count: uint,
35-
emit: emitter
41+
_emit: emitter
42+
};
43+
44+
type codemap_t = @{
45+
handler: handler,
46+
cm: codemap::codemap
3647
};
3748

38-
impl codemap_handler of handler for codemap_t {
49+
impl codemap_span_handler of span_handler for codemap_t {
3950
fn span_fatal(sp: span, msg: str) -> ! {
40-
self.emit(some((self.cm, sp)), msg, fatal);
51+
self.handler.emit(some((self.cm, sp)), msg, fatal);
4152
fail;
4253
}
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 {
4376
fn fatal(msg: str) -> ! {
44-
self.emit(none, msg, fatal);
77+
self._emit(none, msg, fatal);
4578
fail;
4679
}
47-
fn span_err(sp: span, msg: str) {
48-
self.emit(some((self.cm, sp)), msg, error);
49-
self.err_count += 1u;
50-
}
5180
fn err(msg: str) {
52-
self.emit(none, msg, error);
81+
self._emit(none, msg, error);
82+
self.bump_err_count();
83+
}
84+
fn bump_err_count() {
5385
self.err_count += 1u;
5486
}
5587
fn has_errors() -> bool { self.err_count > 0u }
@@ -58,36 +90,30 @@ impl codemap_handler of handler for codemap_t {
5890
self.fatal("aborting due to previous errors");
5991
}
6092
}
61-
fn span_warn(sp: span, msg: str) {
62-
self.emit(some((self.cm, sp)), msg, warning);
63-
}
6493
fn warn(msg: str) {
65-
self.emit(none, msg, warning);
66-
}
67-
fn span_note(sp: span, msg: str) {
68-
self.emit(some((self.cm, sp)), msg, note);
94+
self._emit(none, msg, warning);
6995
}
7096
fn note(msg: str) {
71-
self.emit(none, msg, note);
72-
}
73-
fn span_bug(sp: span, msg: str) -> ! {
74-
self.span_fatal(sp, ice_msg(msg));
97+
self._emit(none, msg, note);
7598
}
7699
fn bug(msg: str) -> ! {
77100
self.fatal(ice_msg(msg));
78101
}
79-
fn span_unimpl(sp: span, msg: str) -> ! {
80-
self.span_bug(sp, "unimplemented " + msg);
81-
}
82102
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);
105+
}
83106
}
84107

85108
fn ice_msg(msg: str) -> str {
86109
#fmt["internal compiler error %s", msg]
87110
}
88111

89-
fn mk_handler(cm: codemap::codemap,
90-
emitter: option<emitter>) -> handler {
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 {
91117

92118
let emit = alt emitter {
93119
some(e) { e }
@@ -101,9 +127,8 @@ fn mk_handler(cm: codemap::codemap,
101127
};
102128

103129
@{
104-
cm: cm,
105130
mutable err_count: 0u,
106-
emit: emit
131+
_emit: emit
107132
} as handler
108133
}
109134

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

Lines changed: 7 additions & 5 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::from_bytes(stream.read_whole_stream())
99+
str::unsafe_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.diagnostic, crate, input,
302+
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input,
303303
io::string_reader(src), io::stdout(), ann);
304304
}
305305

@@ -481,21 +481,23 @@ 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(codemap, some(demitter));
484+
diagnostic::mk_handler(some(demitter));
485+
let span_diagnostic_handler =
486+
diagnostic::mk_span_handler(diagnostic_handler, codemap);
485487
@{targ_cfg: target_cfg,
486488
opts: sopts,
487489
cstore: cstore,
488490
parse_sess: @{
489491
cm: codemap,
490492
mutable next_id: 1,
491-
diagnostic: diagnostic_handler,
493+
span_diagnostic: span_diagnostic_handler,
492494
mutable chpos: 0u,
493495
mutable byte_pos: 0u
494496
},
495497
codemap: codemap,
496498
// For a library crate, this is always none
497499
mutable main_fn: none,
498-
diagnostic: diagnostic_handler,
500+
span_diagnostic: span_diagnostic_handler,
499501
filesearch: filesearch,
500502
mutable building_library: false,
501503
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-
diagnostic: diagnostic::handler,
63+
span_diagnostic: diagnostic::span_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.diagnostic.span_fatal(sp, msg)
70+
self.span_diagnostic.span_fatal(sp, msg)
7171
}
7272
fn fatal(msg: str) -> ! {
73-
self.diagnostic.fatal(msg)
73+
self.span_diagnostic.handler().fatal(msg)
7474
}
7575
fn span_err(sp: span, msg: str) {
76-
self.diagnostic.span_err(sp, msg)
76+
self.span_diagnostic.span_err(sp, msg)
7777
}
7878
fn err(msg: str) {
79-
self.diagnostic.err(msg)
79+
self.span_diagnostic.handler().err(msg)
8080
}
8181
fn has_errors() -> bool {
82-
self.diagnostic.has_errors()
82+
self.span_diagnostic.handler().has_errors()
8383
}
8484
fn abort_if_errors() {
85-
self.diagnostic.abort_if_errors()
85+
self.span_diagnostic.handler().abort_if_errors()
8686
}
8787
fn span_warn(sp: span, msg: str) {
88-
self.diagnostic.span_warn(sp, msg)
88+
self.span_diagnostic.span_warn(sp, msg)
8989
}
9090
fn warn(msg: str) {
91-
self.diagnostic.warn(msg)
91+
self.span_diagnostic.handler().warn(msg)
9292
}
9393
fn span_note(sp: span, msg: str) {
94-
self.diagnostic.span_note(sp, msg)
94+
self.span_diagnostic.span_note(sp, msg)
9595
}
9696
fn note(msg: str) {
97-
self.diagnostic.note(msg)
97+
self.span_diagnostic.handler().note(msg)
9898
}
9999
fn span_bug(sp: span, msg: str) -> ! {
100-
self.diagnostic.span_bug(sp, msg)
100+
self.span_diagnostic.span_bug(sp, msg)
101101
}
102102
fn bug(msg: str) -> ! {
103-
self.diagnostic.bug(msg)
103+
self.span_diagnostic.handler().bug(msg)
104104
}
105105
fn span_unimpl(sp: span, msg: str) -> ! {
106-
self.diagnostic.span_unimpl(sp, msg)
106+
self.span_diagnostic.span_unimpl(sp, msg)
107107
}
108108
fn unimpl(msg: str) -> ! {
109-
self.diagnostic.unimpl(msg)
109+
self.span_diagnostic.handler().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)