Skip to content

Commit fbf031f

Browse files
committed
---
yaml --- r: 13816 b: refs/heads/try c: ec4d05d h: refs/heads/master v: v3
1 parent bc48af3 commit fbf031f

Some content is hidden

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

79 files changed

+1726
-991
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: 3afc16f7a4ce66910107843b8f5cfbea3ad28a09
5+
refs/heads/try: ec4d05de3b71a6286b24f9223731b7bdcfc097f8
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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ 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:
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.
9698

9799
~~~~
98100
## notrust
@@ -103,8 +105,9 @@ $ ./configure
103105
$ make && make install
104106
~~~~
105107

106-
Building from source on windows requires some extra steps, please see
107-
the [getting started][wiki-get-started] page on the Rust wiki.
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`).
108111

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

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

14601463
The fact that arguments are conceptually passed by safe reference does
14611464
not mean all arguments are passed by pointer. Composite types like
1462-
records and tags *are* passed by pointer, but single-word values, like
1465+
records and enums *are* passed by pointer, but single-word values, like
14631466
integers and pointers, are simply passed by value. Most of the time,
14641467
the programmer does not have to worry about this, as the compiler will
14651468
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: 62 additions & 46 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
3642
};
3743

38-
impl codemap_handler of handler for codemap_t {
44+
type codemap_t = @{
45+
handler: handler,
46+
cm: codemap::codemap
47+
};
48+
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

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

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-
};
180196
let fm = codemap::get_filemap(cm, lines.name);
181197

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

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

Lines changed: 11 additions & 9 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::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 {
@@ -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.diagnostic, crate, input,
303-
io::string_reader(src), io::stdout(), ann);
302+
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input,
303+
io::string_reader(*src), io::stdout(), ann);
304304
}
305305

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

0 commit comments

Comments
 (0)