Skip to content

Commit 6ceb3e7

Browse files
committed
---
yaml --- r: 38909 b: refs/heads/incoming c: fe02814 h: refs/heads/master i: 38907: cbfaa67 v: v3
1 parent 06e5135 commit 6ceb3e7

File tree

22 files changed

+381
-64
lines changed

22 files changed

+381
-64
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: 7c35f7ed049c43346381922822ca816bcdeb70e2
9+
refs/heads/incoming: fe02814a63bd759f6727c7479fc4aeb04f0be9b4
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/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-
$ curl -O http://dl.rust-lang.org/dist/rust-0.4.tar.gz
103+
$ wget 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, take remainder, add, subtract). `-` is
493+
`*`, `/`, `%`, `+`, and `-` (multiply, divide, remainder, plus, minus). `-` 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 a match arm are followed by a fat arrow, `=>`, then an
611+
The patterns in an 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 field, and can
868+
You can write a lone `_` to ignore an individual fields, 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 managed box, as happens during assignment, only
1099+
expression. Copying a shared 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 an owned box you must say so explicitly.
1161+
If you really want to copy a unique 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 an owned
1193+
memory. In contrast with owned pointers, where the holder of a unique
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 managed_box : @Point = @Point {x: 5.0, y: 1.0};
1214-
let owned_box : ~Point = ~Point {x: 7.0, y: 9.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};
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-
`managed_box`, or between `managed_box` and `owned_box`. One option is
1220+
`shared_box`, or between `shared_box` and `unique_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 managed_box : @Point = @Point {x: 5.0, y: 1.0};
1245-
# let owned_box : ~Point = ~Point {x: 7.0, y: 9.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};
12461246
# fn compute_distance(p1: &Point, p2: &Point) -> float { 0f }
1247-
compute_distance(&on_the_stack, managed_box);
1248-
compute_distance(managed_box, owned_box);
1247+
compute_distance(&on_the_stack, shared_box);
1248+
compute_distance(shared_box, unique_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 `managed_box` and `owned_box`, however, no
1258+
In the case of the boxes `shared_box` and `unique_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 managed/owned box is being lent out.
1262+
contents of the shared/unique 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/incoming/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/incoming/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/incoming/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)

branches/incoming/src/librustc/middle/ty.rs

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use util::ppaux::{ty_to_str, proto_ty_to_str, tys_to_str};
2121

2222
export ProvidedMethodSource;
2323
export InstantiatedTraitRef;
24-
export TyVid, IntVid, FnVid, RegionVid, vid;
24+
export TyVid, IntVid, FloatVid, FnVid, RegionVid, vid;
2525
export br_hashmap;
2626
export is_instantiable;
2727
export node_id_to_type;
@@ -86,6 +86,7 @@ export ty_fn, FnTy, FnTyBase, FnMeta, FnSig, mk_fn;
8686
export ty_fn_proto, ty_fn_purity, ty_fn_ret, ty_fn_ret_style, tys_in_fn_ty;
8787
export ty_int, mk_int, mk_mach_int, mk_char;
8888
export mk_i8, mk_u8, mk_i16, mk_u16, mk_i32, mk_u32, mk_i64, mk_u64;
89+
export mk_f32, mk_f64;
8990
export ty_estr, mk_estr, type_is_str;
9091
export ty_evec, mk_evec, type_is_vec;
9192
export ty_unboxed_vec, mk_unboxed_vec, mk_mut_unboxed_vec;
@@ -102,8 +103,8 @@ export ty_tup, mk_tup;
102103
export ty_type, mk_type;
103104
export ty_uint, mk_uint, mk_mach_uint;
104105
export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
105-
export ty_infer, mk_infer, type_is_ty_var, mk_var, mk_int_var;
106-
export InferTy, TyVar, IntVar;
106+
export ty_infer, mk_infer, type_is_ty_var, mk_var, mk_int_var, mk_float_var;
107+
export InferTy, TyVar, IntVar, FloatVar;
107108
export ty_self, mk_self, type_has_self;
108109
export ty_class;
109110
export Region, bound_region, encl_region;
@@ -172,7 +173,8 @@ export ty_sort_str;
172173
export normalize_ty;
173174
export to_str;
174175
export bound_const;
175-
export terr_no_integral_type, terr_ty_param_size, terr_self_substs;
176+
export terr_no_integral_type, terr_no_floating_point_type;
177+
export terr_ty_param_size, terr_self_substs;
176178
export terr_in_field, terr_record_fields, terr_vstores_differ, terr_arg_count;
177179
export terr_sorts, terr_vec, terr_str, terr_record_size, terr_tuple_size;
178180
export terr_regions_does_not_outlive, terr_mutability, terr_purity_mismatch;
@@ -666,6 +668,7 @@ enum type_err {
666668
terr_sorts(expected_found<t>),
667669
terr_self_substs,
668670
terr_no_integral_type,
671+
terr_no_floating_point_type,
669672
}
670673

671674
enum param_bound {
@@ -678,21 +681,24 @@ enum param_bound {
678681

679682
enum TyVid = uint;
680683
enum IntVid = uint;
684+
enum FloatVid = uint;
681685
enum FnVid = uint;
682686
#[auto_serialize]
683687
#[auto_deserialize]
684688
enum RegionVid = uint;
685689

686690
enum InferTy {
687691
TyVar(TyVid),
688-
IntVar(IntVid)
692+
IntVar(IntVid),
693+
FloatVar(FloatVid)
689694
}
690695

691696
impl InferTy : to_bytes::IterBytes {
692697
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
693698
match self {
694699
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
695-
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f)
700+
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f),
701+
FloatVar(ref fv) => to_bytes::iter_bytes_2(&2u8, fv, lsb0, f)
696702
}
697703
}
698704
}
@@ -758,6 +764,11 @@ impl IntVid: vid {
758764
pure fn to_str() -> ~str { fmt!("<VI%u>", self.to_uint()) }
759765
}
760766

767+
impl FloatVid: vid {
768+
pure fn to_uint() -> uint { *self }
769+
pure fn to_str() -> ~str { fmt!("<VF%u>", self.to_uint()) }
770+
}
771+
761772
impl FnVid: vid {
762773
pure fn to_uint() -> uint { *self }
763774
pure fn to_str() -> ~str { fmt!("<F%u>", self.to_uint()) }
@@ -773,13 +784,15 @@ impl InferTy {
773784
match self {
774785
TyVar(v) => v.to_uint() << 1,
775786
IntVar(v) => (v.to_uint() << 1) + 1,
787+
FloatVar(v) => (v.to_uint() << 1) + 2
776788
}
777789
}
778790

779791
pure fn to_str() -> ~str {
780792
match self {
781793
TyVar(v) => v.to_str(),
782794
IntVar(v) => v.to_str(),
795+
FloatVar(v) => v.to_str()
783796
}
784797
}
785798
}
@@ -812,6 +825,12 @@ impl IntVid : to_bytes::IterBytes {
812825
}
813826
}
814827

828+
impl FloatVid : to_bytes::IterBytes {
829+
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
830+
(*self).iter_bytes(lsb0, f)
831+
}
832+
}
833+
815834
impl FnVid : to_bytes::IterBytes {
816835
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
817836
(*self).iter_bytes(lsb0, f)
@@ -1030,6 +1049,10 @@ fn mk_u32(cx: ctxt) -> t { mk_t(cx, ty_uint(ast::ty_u32)) }
10301049

10311050
fn mk_u64(cx: ctxt) -> t { mk_t(cx, ty_uint(ast::ty_u64)) }
10321051

1052+
fn mk_f32(cx: ctxt) -> t { mk_t(cx, ty_float(ast::ty_f32)) }
1053+
1054+
fn mk_f64(cx: ctxt) -> t { mk_t(cx, ty_float(ast::ty_f64)) }
1055+
10331056
fn mk_mach_int(cx: ctxt, tm: ast::int_ty) -> t { mk_t(cx, ty_int(tm)) }
10341057

10351058
fn mk_mach_uint(cx: ctxt, tm: ast::uint_ty) -> t { mk_t(cx, ty_uint(tm)) }
@@ -1110,9 +1133,9 @@ fn mk_class(cx: ctxt, class_id: ast::def_id, +substs: substs) -> t {
11101133

11111134
fn mk_var(cx: ctxt, v: TyVid) -> t { mk_infer(cx, TyVar(v)) }
11121135

1113-
fn mk_int_var(cx: ctxt, v: IntVid) -> t {
1114-
mk_infer(cx, IntVar(v))
1115-
}
1136+
fn mk_int_var(cx: ctxt, v: IntVid) -> t { mk_infer(cx, IntVar(v)) }
1137+
1138+
fn mk_float_var(cx: ctxt, v: FloatVid) -> t { mk_infer(cx, FloatVar(v)) }
11161139

11171140
fn mk_infer(cx: ctxt, it: InferTy) -> t { mk_t(cx, ty_infer(it)) }
11181141

@@ -1661,7 +1684,8 @@ pure fn type_is_unique(ty: t) -> bool {
16611684
pure fn type_is_scalar(ty: t) -> bool {
16621685
match get(ty).sty {
16631686
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
1664-
ty_infer(IntVar(_)) | ty_type | ty_ptr(_) => true,
1687+
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
1688+
ty_ptr(_) => true,
16651689
_ => false
16661690
}
16671691
}
@@ -2428,7 +2452,7 @@ fn type_is_integral(ty: t) -> bool {
24282452
24292453
fn type_is_fp(ty: t) -> bool {
24302454
match get(ty).sty {
2431-
ty_float(_) => true,
2455+
ty_infer(FloatVar(_)) | ty_float(_) => true,
24322456
_ => false
24332457
}
24342458
}
@@ -3260,6 +3284,7 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str {
32603284
ty_tup(_) => ~"tuple",
32613285
ty_infer(TyVar(_)) => ~"inferred type",
32623286
ty_infer(IntVar(_)) => ~"integral variable",
3287+
ty_infer(FloatVar(_)) => ~"floating-point variable",
32633288
ty_param(_) => ~"type parameter",
32643289
ty_self => ~"self"
32653290
}
@@ -3387,6 +3412,10 @@ fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
33873412
~"couldn't determine an appropriate integral type for integer \
33883413
literal"
33893414
}
3415+
terr_no_floating_point_type => {
3416+
~"couldn't determine an appropriate floating point type for \
3417+
floating point literal"
3418+
}
33903419
}
33913420
}
33923421

@@ -4000,7 +4029,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
40004029
match get(ty).sty {
40014030
ty_bool => tycat_bool,
40024031
ty_int(_) | ty_uint(_) | ty_infer(IntVar(_)) => tycat_int,
4003-
ty_float(_) => tycat_float,
4032+
ty_float(_) | ty_infer(FloatVar(_)) => tycat_float,
40044033
ty_rec(_) | ty_tup(_) | ty_enum(_, _) => tycat_struct,
40054034
ty_bot => tycat_bot,
40064035
_ => tycat_other
@@ -4230,6 +4259,11 @@ impl IntVid : cmp::Eq {
42304259
pure fn ne(other: &IntVid) -> bool { *self != *(*other) }
42314260
}
42324261

4262+
impl FloatVid : cmp::Eq {
4263+
pure fn eq(other: &FloatVid) -> bool { *self == *(*other) }
4264+
pure fn ne(other: &FloatVid) -> bool { *self != *(*other) }
4265+
}
4266+
42334267
impl FnVid : cmp::Eq {
42344268
pure fn eq(other: &FnVid) -> bool { *self == *(*other) }
42354269
pure fn ne(other: &FnVid) -> bool { *self != *(*other) }

branches/incoming/src/librustc/middle/typeck/check.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
850850
ty::mk_int_var(tcx, fcx.infcx().next_int_var_id())
851851
}
852852
ast::lit_float(_, t) => ty::mk_mach_float(tcx, t),
853+
ast::lit_float_unsuffixed(_) => {
854+
// An unsuffixed floating point literal could have any floating point
855+
// type, so we create a floating point type variable for it.
856+
ty::mk_float_var(tcx, fcx.infcx().next_float_var_id())
857+
}
853858
ast::lit_nil => ty::mk_nil(tcx),
854859
ast::lit_bool(_) => ty::mk_bool(tcx)
855860
}

branches/incoming/src/librustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ impl LookupContext {
664664
match ty::get(self_ty).sty {
665665
ty_box(*) | ty_uniq(*) | ty_rptr(*) |
666666
ty_infer(IntVar(_)) | // FIXME(#3211)---should be resolved
667+
ty_infer(FloatVar(_)) | // FIXME(#3211)---should be resolved
667668
ty_self | ty_param(*) | ty_nil | ty_bot | ty_bool |
668669
ty_int(*) | ty_uint(*) |
669670
ty_float(*) | ty_enum(*) | ty_ptr(*) | ty_rec(*) |

0 commit comments

Comments
 (0)