Skip to content

Commit 6df6454

Browse files
committed
---
yaml --- r: 37541 b: refs/heads/try c: 2b93ab5 h: refs/heads/master i: 37539: 60d7797 v: v3
1 parent ee8f856 commit 6df6454

Some content is hidden

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

51 files changed

+790
-398
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5-
refs/heads/try: 38b9740668f596989a2a714e556d59d5b49112dc
5+
refs/heads/try: 2b93ab5a210066abab30e46e54e999fadbcf5e70
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/doc/tutorial.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ If you've fulfilled those prerequisites, something along these lines
100100
should work.
101101

102102
~~~~ {.notrust}
103-
$ wget http://dl.rust-lang.org/dist/rust-0.4.tar.gz
103+
$ curl -O http://dl.rust-lang.org/dist/rust-0.4.tar.gz
104104
$ tar -xzf rust-0.4.tar.gz
105105
$ cd rust-0.4
106106
$ ./configure
@@ -490,7 +490,7 @@ const MY_STRUCTY_PASSWORD: Password = Password { value: MY_PASSWORD };
490490
## Operators
491491

492492
Rust's set of operators contains very few surprises. Arithmetic is done with
493-
`*`, `/`, `%`, `+`, and `-` (multiply, divide, remainder, plus, minus). `-` is
493+
`*`, `/`, `%`, `+`, and `-` (multiply, divide, take remainder, add, subtract). `-` is
494494
also a unary prefix operator that negates numbers. As in C, the bit operators
495495
`>>`, `<<`, `&`, `|`, and `^` are also supported.
496496

@@ -608,7 +608,7 @@ a wildcard pattern that matches any single value. The asterisk (`*`)
608608
is a different wildcard that can match one or more fields in an `enum`
609609
variant.
610610

611-
The patterns in an match arm are followed by a fat arrow, `=>`, then an
611+
The patterns in a match arm are followed by a fat arrow, `=>`, then an
612612
expression to evaluate. Each case is separated by commas. It's often
613613
convenient to use a block expression for each case, in which case the
614614
commas are optional.
@@ -865,7 +865,7 @@ fn area(sh: Shape) -> float {
865865
}
866866
~~~~
867867

868-
You can write a lone `_` to ignore an individual fields, and can
868+
You can write a lone `_` to ignore an individual field, and can
869869
ignore all fields of a variant like: `Circle(*)`. As in their
870870
introduction form, nullary enum patterns are written without
871871
parentheses.
@@ -1096,7 +1096,7 @@ All pointer types can be dereferenced with the `*` unary operator.
10961096
Managed boxes are pointers to heap-allocated, garbage collected
10971097
memory. Applying the unary `@` operator to an expression creates a
10981098
managed box. The resulting box contains the result of the
1099-
expression. Copying a shared box, as happens during assignment, only
1099+
expression. Copying a managed box, as happens during assignment, only
11001100
copies a pointer, never the contents of the box.
11011101

11021102
~~~~
@@ -1145,7 +1145,7 @@ Managed boxes never cross task boundaries.
11451145
In contrast with managed boxes, owned boxes have a single owning
11461146
memory slot and thus two owned boxes may not refer to the same
11471147
memory. All owned boxes across all tasks are allocated on a single
1148-
_exchange heap_, where their uniquely owned nature allows tasks to
1148+
_exchange heap_, where their uniquely-owned nature allows tasks to
11491149
exchange them efficiently.
11501150

11511151
Because owned boxes are uniquely owned, copying them requires allocating
@@ -1158,7 +1158,7 @@ let x = ~10;
11581158
let y = x; // error: copying a non-implicitly copyable type
11591159
~~~~
11601160

1161-
If you really want to copy a unique box you must say so explicitly.
1161+
If you really want to copy an owned box you must say so explicitly.
11621162

11631163
~~~~
11641164
let x = ~10;
@@ -1190,7 +1190,7 @@ become the sole owner of the box.
11901190

11911191
Rust borrowed pointers are a general purpose reference/pointer type,
11921192
similar to the C++ reference type, but guaranteed to point to valid
1193-
memory. In contrast with owned pointers, where the holder of a unique
1193+
memory. In contrast with owned pointers, where the holder of an owned
11941194
pointer is the owner of the pointed-to memory, borrowed pointers never
11951195
imply ownership. Pointers may be borrowed from any type, in which case
11961196
the pointer is guaranteed not to outlive the value it points to.
@@ -1210,14 +1210,14 @@ contains a point, but allocated in a different location:
12101210
~~~
12111211
# struct Point { x: float, y: float }
12121212
let on_the_stack : Point = Point {x: 3.0, y: 4.0};
1213-
let shared_box : @Point = @Point {x: 5.0, y: 1.0};
1214-
let unique_box : ~Point = ~Point {x: 7.0, y: 9.0};
1213+
let managed_box : @Point = @Point {x: 5.0, y: 1.0};
1214+
let owned_box : ~Point = ~Point {x: 7.0, y: 9.0};
12151215
~~~
12161216
12171217
Suppose we wanted to write a procedure that computed the distance
12181218
between any two points, no matter where they were stored. For example,
12191219
we might like to compute the distance between `on_the_stack` and
1220-
`shared_box`, or between `shared_box` and `unique_box`. One option is
1220+
`managed_box`, or between `managed_box` and `owned_box`. One option is
12211221
to define a function that takes two arguments of type point—that is,
12221222
it takes the points by value. But this will cause the points to be
12231223
copied when we call the function. For points, this is probably not so
@@ -1241,11 +1241,11 @@ Now we can call `compute_distance()` in various ways:
12411241
~~~
12421242
# struct Point{ x: float, y: float };
12431243
# let on_the_stack : Point = Point {x: 3.0, y: 4.0};
1244-
# let shared_box : @Point = @Point {x: 5.0, y: 1.0};
1245-
# let unique_box : ~Point = ~Point {x: 7.0, y: 9.0};
1244+
# let managed_box : @Point = @Point {x: 5.0, y: 1.0};
1245+
# let owned_box : ~Point = ~Point {x: 7.0, y: 9.0};
12461246
# fn compute_distance(p1: &Point, p2: &Point) -> float { 0f }
1247-
compute_distance(&on_the_stack, shared_box);
1248-
compute_distance(shared_box, unique_box);
1247+
compute_distance(&on_the_stack, managed_box);
1248+
compute_distance(managed_box, owned_box);
12491249
~~~
12501250
12511251
Here the `&` operator is used to take the address of the variable
@@ -1255,11 +1255,11 @@ value. We also call this _borrowing_ the local variable
12551255
`on_the_stack`, because we are created an alias: that is, another
12561256
route to the same data.
12571257
1258-
In the case of the boxes `shared_box` and `unique_box`, however, no
1258+
In the case of the boxes `managed_box` and `owned_box`, however, no
12591259
explicit action is necessary. The compiler will automatically convert
12601260
a box like `@point` or `~point` to a borrowed pointer like
12611261
`&point`. This is another form of borrowing; in this case, the
1262-
contents of the shared/unique box is being lent out.
1262+
contents of the managed/owned box is being lent out.
12631263
12641264
Whenever a value is borrowed, there are some limitations on what you
12651265
can do with the original. For example, if the contents of a variable

branches/try/src/libcore/result.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ pub pure fn to_either<T: Copy, U: Copy>(res: &Result<U, T>)
103103
* ok(parse_bytes(buf))
104104
* }
105105
*/
106-
pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T)
106+
pub fn chain<T, U, V>(res: Result<T, V>, op: fn(t: T)
107107
-> Result<U, V>) -> Result<U, V> {
108108
match move res {
109109
Ok(move t) => op(move t),
110-
Err(move e) => Err(e)
110+
Err(move e) => Err(move e)
111111
}
112112
}
113113

@@ -119,13 +119,13 @@ pub fn chain<T, U: Copy, V: Copy>(res: Result<T, V>, op: fn(t: T)
119119
* immediately returned. This function can be used to pass through a
120120
* successful result while handling an error.
121121
*/
122-
pub fn chain_err<T: Copy, U: Copy, V: Copy>(
122+
pub fn chain_err<T, U, V>(
123123
res: Result<T, V>,
124124
op: fn(t: V) -> Result<T, U>)
125125
-> Result<T, U> {
126126
match move res {
127-
Ok(move t) => Ok(t),
128-
Err(move v) => op(v)
127+
Ok(move t) => Ok(move t),
128+
Err(move v) => op(move v)
129129
}
130130
}
131131

branches/try/src/libfuzzer/fuzzer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn as_str(f: fn@(+x: io::Writer)) -> ~str {
225225
io::with_str_writer(f)
226226
}
227227

228-
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
228+
fn check_variants_of_ast(crate: ast::crate, codemap: codemap::CodeMap,
229229
filename: &Path, cx: context) {
230230
let stolen = steal(crate, cx.mode);
231231
let extra_exprs = vec::filter(common_exprs(),
@@ -239,7 +239,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
239239

240240
fn check_variants_T<T: Copy>(
241241
crate: ast::crate,
242-
codemap: @codemap::CodeMap,
242+
codemap: codemap::CodeMap,
243243
filename: &Path,
244244
thing_label: ~str,
245245
things: ~[T],

branches/try/src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: input,
354354
ppm_expanded | ppm_normal => pprust::no_ann()
355355
};
356356
let is_expanded = upto != cu_parse;
357-
let src = sess.codemap.get_filemap(source_name(input)).src;
357+
let src = codemap::get_filemap(sess.codemap, source_name(input)).src;
358358
do io::with_str_reader(*src) |rdr| {
359359
pprust::print_crate(sess.codemap, sess.parse_sess.interner,
360360
sess.span_diagnostic, crate,
@@ -574,7 +574,7 @@ fn build_session_options(binary: ~str,
574574

575575
fn build_session(sopts: @session::options,
576576
demitter: diagnostic::emitter) -> Session {
577-
let codemap = @codemap::CodeMap::new();
577+
let codemap = codemap::new_codemap();
578578
let diagnostic_handler =
579579
diagnostic::mk_handler(Some(demitter));
580580
let span_diagnostic_handler =
@@ -583,7 +583,7 @@ fn build_session(sopts: @session::options,
583583
}
584584

585585
fn build_session_(sopts: @session::options,
586-
cm: @codemap::CodeMap,
586+
cm: codemap::CodeMap,
587587
demitter: diagnostic::emitter,
588588
span_diagnostic_handler: diagnostic::span_handler)
589589
-> Session {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type Session_ = {targ_cfg: @config,
131131
opts: @options,
132132
cstore: metadata::cstore::CStore,
133133
parse_sess: parse_sess,
134-
codemap: @codemap::CodeMap,
134+
codemap: codemap::CodeMap,
135135
// For a library crate, this is always none
136136
mut main_fn: Option<(node_id, codemap::span)>,
137137
span_diagnostic: diagnostic::span_handler,

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
557557
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
558558

559559
debug!("encoding info for item at %s",
560-
ecx.tcx.sess.codemap.span_to_str(item.span));
560+
syntax::codemap::span_to_str(item.span, ecx.tcx.sess.codemap));
561561

562562
match item.node {
563563
item_const(_, _) => {

branches/try/src/librustc/metadata/tyencode.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ fn enc_sty(w: io::Writer, cx: @ctxt, st: ty::sty) {
286286
w.write_char('I');
287287
w.write_uint(id.to_uint());
288288
}
289+
ty::ty_infer(ty::FloatVar(id)) => {
290+
w.write_char('X');
291+
w.write_char('F');
292+
w.write_uint(id.to_uint());
293+
}
289294
ty::ty_param({idx: id, def_id: did}) => {
290295
w.write_char('p');
291296
w.write_str(cx.ds(did));

branches/try/src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ fn lit_to_const(lit: @lit) -> const_val {
389389
lit_uint(n, _) => const_uint(n),
390390
lit_int_unsuffixed(n) => const_int(n),
391391
lit_float(n, _) => const_float(float::from_str(*n).get() as f64),
392+
lit_float_unsuffixed(n) =>
393+
const_float(float::from_str(*n).get() as f64),
392394
lit_nil => const_int(0i64),
393395
lit_bool(b) => const_bool(b)
394396
}

branches/try/src/librustc/middle/liveness.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use std::map::HashMap;
9797
use syntax::{visit, ast_util};
9898
use syntax::print::pprust::{expr_to_str, block_to_str};
9999
use visit::vt;
100-
use syntax::codemap::span;
100+
use syntax::codemap::{span, span_to_str};
101101
use syntax::ast::*;
102102
use io::WriterUtil;
103103
use capture::{cap_move, cap_drop, cap_copy, cap_ref};
@@ -170,9 +170,9 @@ impl LiveNodeKind : cmp::Eq {
170170
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
171171
let cm = cx.sess.codemap;
172172
match lnk {
173-
FreeVarNode(s) => fmt!("Free var node [%s]", cm.span_to_str(s)),
174-
ExprNode(s) => fmt!("Expr node [%s]", cm.span_to_str(s)),
175-
VarDefNode(s) => fmt!("Var def node [%s]", cm.span_to_str(s)),
173+
FreeVarNode(s) => fmt!("Free var node [%s]", span_to_str(s, cm)),
174+
ExprNode(s) => fmt!("Expr node [%s]", span_to_str(s, cm)),
175+
VarDefNode(s) => fmt!("Var def node [%s]", span_to_str(s, cm)),
176176
ExitNode => ~"Exit node"
177177
}
178178
}

branches/try/src/librustc/middle/resolve.rs

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,29 +1299,76 @@ impl Resolver {
12991299
let (name_bindings, new_parent) =
13001300
self.add_child(ident, parent, ForbidDuplicateTypes, sp);
13011301

1302+
// If the trait has static methods, then add all the static
1303+
// methods within to a new module.
1304+
//
1305+
// We only need to create the module if the trait has static
1306+
// methods, so check that first.
1307+
let mut has_static_methods = false;
1308+
for methods.each |method| {
1309+
let ty_m = trait_method_to_ty_method(*method);
1310+
match ty_m.self_ty.node {
1311+
sty_static => {
1312+
has_static_methods = true;
1313+
break;
1314+
}
1315+
_ => {}
1316+
}
1317+
}
1318+
1319+
// Create the module if necessary.
1320+
let module_parent_opt;
1321+
if has_static_methods {
1322+
let parent_link = self.get_parent_link(parent, ident);
1323+
name_bindings.define_module(privacy,
1324+
parent_link,
1325+
Some(local_def(item.id)),
1326+
false,
1327+
sp);
1328+
module_parent_opt = Some(ModuleReducedGraphParent(
1329+
name_bindings.get_module()));
1330+
} else {
1331+
module_parent_opt = None;
1332+
}
1333+
13021334
// Add the names of all the methods to the trait info.
13031335
let method_names = @HashMap();
13041336
for methods.each |method| {
13051337
let ty_m = trait_method_to_ty_method(*method);
13061338

13071339
let ident = ty_m.ident;
13081340
// Add it to the trait info if not static,
1309-
// add it as a name in the enclosing module otherwise.
1341+
// add it as a name in the trait module otherwise.
13101342
match ty_m.self_ty.node {
1311-
sty_static => {
1312-
// which parent to use??
1313-
let (method_name_bindings, _) =
1314-
self.add_child(ident, new_parent,
1315-
ForbidDuplicateValues, ty_m.span);
1316-
let def = def_static_method(local_def(ty_m.id),
1317-
Some(local_def(item.id)),
1318-
ty_m.purity);
1319-
(*method_name_bindings).define_value
1320-
(Public, def, ty_m.span);
1321-
}
1322-
_ => {
1323-
(*method_names).insert(ident, ());
1324-
}
1343+
sty_static => {
1344+
let def = def_static_method(
1345+
local_def(ty_m.id),
1346+
Some(local_def(item.id)),
1347+
ty_m.purity);
1348+
1349+
// For now, add to both the trait module and the
1350+
// enclosing module, for backwards compatibility.
1351+
let (method_name_bindings, _) =
1352+
self.add_child(ident,
1353+
new_parent,
1354+
ForbidDuplicateValues,
1355+
ty_m.span);
1356+
method_name_bindings.define_value(Public,
1357+
def,
1358+
ty_m.span);
1359+
1360+
let (method_name_bindings, _) =
1361+
self.add_child(ident,
1362+
module_parent_opt.get(),
1363+
ForbidDuplicateValues,
1364+
ty_m.span);
1365+
method_name_bindings.define_value(Public,
1366+
def,
1367+
ty_m.span);
1368+
}
1369+
_ => {
1370+
method_names.insert(ident, ());
1371+
}
13251372
}
13261373
}
13271374

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ fn trans_trace(bcx: block, sp_opt: Option<span>, trace_str: ~str) {
919919
let {V_filename, V_line} = match sp_opt {
920920
Some(sp) => {
921921
let sess = bcx.sess();
922-
let loc = sess.parse_sess.cm.lookup_char_pos(sp.lo);
922+
let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo);
923923
{V_filename: C_cstr(bcx.ccx(), loc.file.name),
924924
V_line: loc.line as int}
925925
}

branches/try/src/librustc/middle/trans/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
645645
fn add_span_comment(bcx: block, sp: span, text: ~str) {
646646
let ccx = bcx.ccx();
647647
if !ccx.sess.no_asm_comments() {
648-
let s = text + ~" (" + ccx.sess.codemap.span_to_str(sp)
648+
let s = text + ~" (" + codemap::span_to_str(sp, ccx.sess.codemap)
649649
+ ~")";
650650
log(debug, s);
651651
add_comment(bcx, s);

branches/try/src/librustc/middle/trans/consts.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
2222
}
2323
}
2424
ast::lit_float(fs, t) => C_floating(*fs, T_float_ty(cx, t)),
25+
ast::lit_float_unsuffixed(fs) => {
26+
let lit_float_ty = ty::node_id_to_type(cx.tcx, e.id);
27+
match ty::get(lit_float_ty).sty {
28+
ty::ty_float(t) => {
29+
C_floating(*fs, T_float_ty(cx, t))
30+
}
31+
_ => {
32+
cx.sess.span_bug(lit.span,
33+
~"floating point literal doesn't have the right \
34+
type");
35+
}
36+
}
37+
}
2538
ast::lit_bool(b) => C_bool(b),
2639
ast::lit_nil => C_nil(),
2740
ast::lit_str(s) => C_estr_slice(cx, *s)

0 commit comments

Comments
 (0)