Skip to content

Commit 5179d5d

Browse files
committed
---
yaml --- r: 13813 b: refs/heads/try c: 5847cf0 h: refs/heads/master i: 13811: a393f10 v: v3
1 parent f6e8c96 commit 5179d5d

Some content is hidden

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

76 files changed

+862
-1687
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: 566a4be1f892eee66f88b832ff04421ad70cb1ee
5+
refs/heads/try: 5847cf0367287d89377c57a431f38419ec1db008
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: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ packages:
9292
* curl
9393

9494
Assuming you're on a relatively modern Linux system and have met the
95-
prerequisites, something along these lines should work. Building from source on
96-
Windows requires some extra steps: please see the
97-
[getting started][wiki-get-started] page on the Rust wiki.
95+
prerequisites, something along these lines should work:
9896

9997
~~~~
10098
## notrust
@@ -105,9 +103,8 @@ $ ./configure
105103
$ make && make install
106104
~~~~
107105

108-
You may need to use `sudo make install` if you do not normally have
109-
permission to modify the destination directory (either `/usr/local/bin`
110-
or the directory specified with to `configure` with `--prefix`).
106+
Building from source on windows requires some extra steps, please see
107+
the [getting started][wiki-get-started] page on the Rust wiki.
111108

112109
When complete, `make install` will place the following programs into
113110
`/usr/local/bin`:
@@ -1349,7 +1346,7 @@ destructors. Resources might go away in the future.
13491346
Rust datatypes are not trivial to copy (the way, for example,
13501347
JavaScript values can be copied by simply taking one or two machine
13511348
words and plunking them somewhere else). Shared boxes require
1352-
reference count updates, big records, enums, or unique pointers require
1349+
reference count updates, big records, tags, or unique pointers require
13531350
an arbitrary amount of data to be copied (plus updating the reference
13541351
counts of shared boxes hanging off them).
13551352

@@ -1462,7 +1459,7 @@ alt my_rec {
14621459

14631460
The fact that arguments are conceptually passed by safe reference does
14641461
not mean all arguments are passed by pointer. Composite types like
1465-
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
14661463
integers and pointers, are simply passed by value. Most of the time,
14671464
the programmer does not have to worry about this, as the compiler will
14681465
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: 46 additions & 62 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

@@ -193,6 +168,15 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
193168
// pull out the lines
194169
if lines.name == "-" { ret; }
195170

171+
// FIXME: reading in the entire file is the worst possible way to
172+
// get access to the necessary lines.
173+
let file = alt io::read_whole_file_str(lines.name) {
174+
result::ok(file) { file }
175+
result::err(e) {
176+
// Hard to report errors while reporting an error
177+
ret;
178+
}
179+
};
196180
let fm = codemap::get_filemap(cm, lines.name);
197181

198182
// arbitrarily only print up to six lines of the error
@@ -206,7 +190,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
206190
// Print the offending lines
207191
for line: uint in display_lines {
208192
io::stdout().write_str(#fmt["%s:%u ", fm.name, line + 1u]);
209-
let s = codemap::get_line(fm, line as int);
193+
let s = codemap::get_line(fm, line as int, file);
210194
if !str::ends_with(s, "\n") { s += "\n"; }
211195
io::stdout().write_str(s);
212196
}

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg {
7777
fn input_is_stdin(filename: str) -> bool { filename == "-" }
7878

7979
fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
80-
-> {crate: @ast::crate, src: @str} {
80+
-> {crate: @ast::crate, src: str} {
8181
let src = get_input_str(sess, input);
8282
let crate = if !input_is_stdin(input) {
8383
parser::parse_crate_from_file(input, cfg, sess.parse_sess)
@@ -87,7 +87,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
8787
{crate: crate, src: src}
8888
}
8989

90-
fn get_input_str(sess: session, infile: str) -> @str {
90+
fn get_input_str(sess: session, infile: str) -> str {
9191
let stream = if !input_is_stdin(infile) {
9292
alt io::file_reader(infile) {
9393
result::ok(reader) { reader }
@@ -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 {
@@ -141,7 +141,7 @@ enum compile_upto {
141141
fn compile_upto(sess: session, cfg: ast::crate_cfg,
142142
input: str, upto: compile_upto,
143143
outputs: option::t<output_filenames>)
144-
-> {crate: @ast::crate, tcx: option::t<ty::ctxt>, src: @str} {
144+
-> {crate: @ast::crate, tcx: option::t<ty::ctxt>, src: str} {
145145
let time_passes = sess.opts.time_passes;
146146
let {crate, src} =
147147
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
@@ -299,8 +299,8 @@ 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,
303-
io::string_reader(*src), io::stdout(), ann);
302+
pprust::print_crate(sess.codemap, sess.diagnostic, crate, input,
303+
io::string_reader(src), io::stdout(), ann);
304304
}
305305

306306
fn get_os(triple: str) -> option<session::os> {
@@ -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)}

0 commit comments

Comments
 (0)