Skip to content

Commit 84d5d38

Browse files
committed
---
yaml --- r: 149053 b: refs/heads/try2 c: 1b77331 h: refs/heads/master i: 149051: 1ec2df6 v: v3
1 parent c699df5 commit 84d5d38

File tree

13 files changed

+84
-139
lines changed

13 files changed

+84
-139
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5bad63cef541d295e1fc4e4246d493f9837e0d18
8+
refs/heads/try2: 1b7733109d7b692c2ddd404f1bb6c751c3194750
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7474
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
7575
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
7676
| $$(TLIB$(1)_T_$(2)_H_$(3))/
77-
@$$(call E, oxidize: $$(@D)/lib$(4))
77+
@$$(call E, compile_and_link: $$(@D)/lib$(4))
7878
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
7979
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
8080
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
@@ -113,7 +113,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
113113
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
114114
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
115115
| $$(TBIN$(1)_T_$(4)_H_$(3))/
116-
@$$(call E, oxidize: $$@)
116+
@$$(call E, compile_and_link: $$@)
117117
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
118118

119119
endef

branches/try2/mk/tests.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
347347
$$(CRATEFILE_$(4)) \
348348
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
349349
$$(STDTESTDEP_$(1)_$(2)_$(3)_$(4))
350-
@$$(call E, oxidize: $$@)
350+
@$$(call E, compile_and_link: $$@)
351351
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
352352
-L "$$(RT_OUTPUT_DIR_$(2))" \
353353
-L "$$(LLVM_LIBDIR_$(2))"
@@ -835,15 +835,15 @@ define DEF_CHECK_FAST_FOR_T_H
835835
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
836836
tmp/$$(FT).rc \
837837
$$(SREQ2_T_$(2)_H_$(3))
838-
@$$(call E, oxidize: $$@)
838+
@$$(call E, compile_and_link: $$@)
839839
$$(STAGE2_T_$(2)_H_$(3)) --crate-type=dylib --out-dir $$(@D) $$< \
840840
-L "$$(RT_OUTPUT_DIR_$(2))"
841841

842842
$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
843843
tmp/$$(FT_DRIVER).rs \
844844
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
845845
$$(SREQ2_T_$(2)_H_$(3))
846-
@$$(call E, oxidize: $$@ $$<)
846+
@$$(call E, compile_and_link: $$@ $$<)
847847
$$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$< \
848848
-L "$$(RT_OUTPUT_DIR_$(2))"
849849

branches/try2/src/doc/tutorial.md

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,31 @@ match mypoint {
647647

648648
## Enums
649649

650-
Enums are datatypes with several alternate representations. A simple `enum`
651-
defines one or more constants, all of which have the same type:
650+
Enums are datatypes that have several alternate representations. For
651+
example, consider the following type:
652+
653+
~~~~
654+
# struct Point { x: f64, y: f64 }
655+
enum Shape {
656+
Circle(Point, f64),
657+
Rectangle(Point, Point)
658+
}
659+
~~~~
660+
661+
A value of this type is either a `Circle`, in which case it contains a
662+
`Point` struct and a f64, or a `Rectangle`, in which case it contains
663+
two `Point` structs. The run-time representation of such a value
664+
includes an identifier of the actual form that it holds, much like the
665+
"tagged union" pattern in C, but with better static guarantees.
666+
667+
The above declaration will define a type `Shape` that can refer to
668+
such shapes, and two functions, `Circle` and `Rectangle`, which can be
669+
used to construct values of the type (taking arguments of the
670+
specified types). So `Circle(Point { x: 0.0, y: 0.0 }, 10.0)` is the way to
671+
create a new circle.
672+
673+
Enum variants need not have parameters. This `enum` declaration,
674+
for example, is equivalent to a C enum:
652675

653676
~~~~
654677
enum Direction {
@@ -659,21 +682,12 @@ enum Direction {
659682
}
660683
~~~~
661684

662-
Each variant of this enum has a unique and constant integral discriminator
663-
value. If no explicit discriminator is specified for a variant, the value
664-
defaults to the value of the previous variant plus one. If the first variant
665-
does not have a discriminator, it defaults to 0. For example, the value of
666-
`North` is 0, `East` is 1, `South` is 2, and `West` is 3.
685+
This declaration defines `North`, `East`, `South`, and `West` as constants,
686+
all of which have type `Direction`.
667687

668-
When an enum has simple integer discriminators, you can apply the `as` cast
669-
operator to convert a variant to its discriminator value as an `int`:
670-
671-
~~~~
672-
# enum Direction { North }
673-
println!( "{:?} => {}", North, North as int );
674-
~~~~
675-
676-
It is possible to set the discriminator values to chosen constant values:
688+
When an enum is C-like (that is, when none of the variants have
689+
parameters), it is possible to explicitly set the discriminator values
690+
to a constant value:
677691

678692
~~~~
679693
enum Color {
@@ -683,30 +697,17 @@ enum Color {
683697
}
684698
~~~~
685699

686-
Variants do not have to be simple values; they may be more complex:
700+
If an explicit discriminator is not specified for a variant, the value
701+
defaults to the value of the previous variant plus one. If the first
702+
variant does not have a discriminator, it defaults to 0. For example,
703+
the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3.
687704

688-
~~~~
689-
# struct Point { x: f64, y: f64 }
690-
enum Shape {
691-
Circle(Point, f64),
692-
Rectangle(Point, Point)
693-
}
694-
~~~~
705+
When an enum is C-like, you can apply the `as` cast operator to
706+
convert it to its discriminator value as an `int`.
695707

696-
A value of this type is either a `Circle`, in which case it contains a
697-
`Point` struct and a f64, or a `Rectangle`, in which case it contains
698-
two `Point` structs. The run-time representation of such a value
699-
includes an identifier of the actual form that it holds, much like the
700-
"tagged union" pattern in C, but with better static guarantees.
701-
702-
This declaration defines a type `Shape` that can refer to such shapes, and two
703-
functions, `Circle` and `Rectangle`, which can be used to construct values of
704-
the type. To create a new Circle, write `Circle(Point { x: 0.0, y: 0.0 },
705-
10.0)`.
706-
707-
All of these variant constructors may be used as patterns. The only way to
708-
access the contents of an enum instance is the destructuring of a match. For
709-
example:
708+
For enum types with multiple variants, destructuring is the only way to
709+
get at their contents. All variant constructors can be used as
710+
patterns, as in this definition of `area`:
710711

711712
~~~~
712713
use std::f64;
@@ -720,8 +721,10 @@ fn area(sh: Shape) -> f64 {
720721
}
721722
~~~~
722723

723-
Use a lone `_` to ignore an individual field. Ignore all fields of a variant
724-
like: `Circle(..)`. Nullary enum patterns are written without parentheses:
724+
You can write a lone `_` to ignore an individual field, and can
725+
ignore all fields of a variant like: `Circle(..)`. As in their
726+
introduction form, nullary enum patterns are written without
727+
parentheses.
725728

726729
~~~~
727730
# struct Point { x: f64, y: f64 }

branches/try2/src/libcollections/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn foldl<T:Clone,U>(z: T, ls: @List<U>, f: |&T, &U| -> T) -> T {
4646
/**
4747
* Search for an element that matches a given predicate
4848
*
49-
* Apply function `f` to each element of `ls`, starting from the first.
49+
* Apply function `f` to each element of `v`, starting from the first.
5050
* When function `f` returns true then an option containing the element
5151
* is returned. If `f` matches no elements then none is returned.
5252
*/

branches/try2/src/libnative/io/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
746746
super::mkerr_winbool(as_utf16_p(src.as_str().unwrap(), |src| {
747747
as_utf16_p(dst.as_str().unwrap(), |dst| {
748748
unsafe { libc::CreateSymbolicLinkW(dst, src, 0) }
749-
}) as libc::BOOL
749+
})
750750
}))
751751
}
752752

branches/try2/src/librustc/middle/region.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,12 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor,
501501
visitor.region_maps.mark_as_terminating_scope(otherwise.id);
502502
}
503503

504-
ast::ExprIf(expr, then, None) => {
505-
visitor.region_maps.mark_as_terminating_scope(expr.id);
504+
ast::ExprIf(_, then, None) => {
506505
visitor.region_maps.mark_as_terminating_scope(then.id);
507506
}
508507

509-
ast::ExprLoop(body, _) => {
510-
visitor.region_maps.mark_as_terminating_scope(body.id);
511-
}
512-
513-
ast::ExprWhile(expr, body) => {
514-
visitor.region_maps.mark_as_terminating_scope(expr.id);
508+
ast::ExprLoop(body, _) |
509+
ast::ExprWhile(_, body) => {
515510
visitor.region_maps.mark_as_terminating_scope(body.id);
516511
}
517512

branches/try2/src/libstd/cast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//! Unsafe casting functions
1212
13-
use ptr::RawPtr;
1413
use mem;
1514
use unstable::intrinsics;
1615
use ptr::copy_nonoverlapping_memory;
@@ -72,13 +71,13 @@ pub unsafe fn transmute_region<'a,'b,T>(ptr: &'a T) -> &'b T {
7271

7372
/// Coerce an immutable reference to be mutable.
7473
#[inline]
75-
pub unsafe fn transmute_mut_unsafe<T,P:RawPtr<T>>(ptr: P) -> *mut T {
74+
pub unsafe fn transmute_mut_unsafe<T>(ptr: *T) -> *mut T {
7675
transmute(ptr)
7776
}
7877

7978
/// Coerce an immutable reference to be mutable.
8079
#[inline]
81-
pub unsafe fn transmute_immut_unsafe<T,P:RawPtr<T>>(ptr: P) -> *T {
80+
pub unsafe fn transmute_immut_unsafe<T>(ptr: *mut T) -> *T {
8281
transmute(ptr)
8382
}
8483

branches/try2/src/libstd/libc.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ pub mod types {
970970

971971
pub type BOOL = c_int;
972972
pub type BYTE = u8;
973-
pub type BOOLEAN = BYTE;
974973
pub type CCHAR = c_char;
975974
pub type CHAR = c_char;
976975

@@ -3985,16 +3984,15 @@ pub mod funcs {
39853984

39863985
pub mod kernel32 {
39873986
use libc::types::os::arch::c95::{c_uint};
3988-
use libc::types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE,
3989-
LPCWSTR, LPWSTR, LPCSTR, LPSTR,
3990-
LPCH, LPDWORD, LPVOID,
3991-
LPCVOID, LPOVERLAPPED,
3992-
LPSECURITY_ATTRIBUTES,
3993-
LPSTARTUPINFO,
3987+
use libc::types::os::arch::extra::{BOOL, DWORD, SIZE_T, HMODULE};
3988+
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPCSTR, LPSTR, LPCH,
3989+
LPDWORD, LPVOID,
3990+
LPCVOID, LPOVERLAPPED};
3991+
use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, LPSTARTUPINFO,
39943992
LPPROCESS_INFORMATION,
39953993
LPMEMORY_BASIC_INFORMATION,
3996-
LPSYSTEM_INFO, BOOLEAN,
3997-
HANDLE, LPHANDLE, LARGE_INTEGER,
3994+
LPSYSTEM_INFO};
3995+
use libc::types::os::arch::extra::{HANDLE, LPHANDLE, LARGE_INTEGER,
39983996
PLARGE_INTEGER, LPFILETIME};
39993997

40003998
extern "system" {
@@ -4107,7 +4105,7 @@ pub mod funcs {
41074105
dwFlags: DWORD) -> BOOL;
41084106
pub fn CreateSymbolicLinkW(lpSymlinkFileName: LPCWSTR,
41094107
lpTargetFileName: LPCWSTR,
4110-
dwFlags: DWORD) -> BOOLEAN;
4108+
dwFlags: DWORD) -> BOOL;
41114109
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
41124110
lpTargetFileName: LPCWSTR,
41134111
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)

branches/try2/src/libstd/ptr.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ pub fn is_not_null<T,P:RawPtr<T>>(ptr: P) -> bool { ptr.is_not_null() }
9292
* and destination may overlap.
9393
*/
9494
#[inline]
95-
pub unsafe fn copy_memory<T,P:RawPtr<T>>(dst: *mut T, src: P, count: uint) {
96-
intrinsics::copy_memory(dst, cast::transmute_immut_unsafe(src), count)
95+
pub unsafe fn copy_memory<T>(dst: *mut T, src: *T, count: uint) {
96+
intrinsics::copy_memory(dst, src, count)
9797
}
9898

9999
/**
@@ -103,10 +103,10 @@ pub unsafe fn copy_memory<T,P:RawPtr<T>>(dst: *mut T, src: P, count: uint) {
103103
* and destination may *not* overlap.
104104
*/
105105
#[inline]
106-
pub unsafe fn copy_nonoverlapping_memory<T,P:RawPtr<T>>(dst: *mut T,
107-
src: P,
108-
count: uint) {
109-
intrinsics::copy_nonoverlapping_memory(dst, cast::transmute_immut_unsafe(src), count)
106+
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T,
107+
src: *T,
108+
count: uint) {
109+
intrinsics::copy_nonoverlapping_memory(dst, src, count)
110110
}
111111

112112
/**
@@ -137,9 +137,9 @@ pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
137137
let t: *mut T = &mut tmp;
138138

139139
// Perform the swap
140-
copy_nonoverlapping_memory(t, x, 1);
141-
copy_memory(x, y, 1); // `x` and `y` may overlap
142-
copy_nonoverlapping_memory(y, t, 1);
140+
copy_nonoverlapping_memory(t, &*x, 1);
141+
copy_memory(x, &*y, 1); // `x` and `y` may overlap
142+
copy_nonoverlapping_memory(y, &*t, 1);
143143

144144
// y and t now point to the same thing, but we need to completely forget `tmp`
145145
// because it's no longer relevant.

branches/try2/src/libstd/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
3232
// Perform the swap, `&mut` pointers never alias
3333
let x_raw: *mut T = x;
3434
let y_raw: *mut T = y;
35-
ptr::copy_nonoverlapping_memory(t, x_raw, 1);
36-
ptr::copy_nonoverlapping_memory(x, y_raw, 1);
37-
ptr::copy_nonoverlapping_memory(y, t, 1);
35+
ptr::copy_nonoverlapping_memory(t, &*x_raw, 1);
36+
ptr::copy_nonoverlapping_memory(x, &*y_raw, 1);
37+
ptr::copy_nonoverlapping_memory(y, &*t, 1);
3838

3939
// y and t now point to the same thing, but we need to completely forget `tmp`
4040
// because it's no longer relevant.

branches/try2/src/libstd/vec.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ impl<T> OwnedVector<T> for ~[T] {
15481548
let p = self.as_mut_ptr().offset(i as int);
15491549
// Shift everything over to make space. (Duplicating the
15501550
// `i`th element into two consecutive places.)
1551-
ptr::copy_memory(p.offset(1), p, len - i);
1551+
ptr::copy_memory(p.offset(1), &*p, len - i);
15521552
// Write it in, overwriting the first copy of the `i`th
15531553
// element.
15541554
mem::move_val_init(&mut *p, x);
@@ -1567,7 +1567,7 @@ impl<T> OwnedVector<T> for ~[T] {
15671567
let ret = Some(ptr::read_ptr(ptr as *T));
15681568

15691569
// Shift everything down to fill in that spot.
1570-
ptr::copy_memory(ptr, ptr.offset(1), len - i - 1);
1570+
ptr::copy_memory(ptr, &*ptr.offset(1), len - i - 1);
15711571
self.set_len(len - 1);
15721572

15731573
ret
@@ -1842,7 +1842,7 @@ fn insertion_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
18421842
if i != j {
18431843
let tmp = ptr::read_ptr(read_ptr);
18441844
ptr::copy_memory(buf_v.offset(j + 1),
1845-
buf_v.offset(j),
1845+
&*buf_v.offset(j),
18461846
(i - j) as uint);
18471847
ptr::copy_nonoverlapping_memory(buf_v.offset(j),
18481848
&tmp as *T,
@@ -1920,7 +1920,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
19201920
// that case, `i == j` so we don't copy. The
19211921
// `.offset(j)` is always in bounds.
19221922
ptr::copy_memory(buf_dat.offset(j + 1),
1923-
buf_dat.offset(j),
1923+
&*buf_dat.offset(j),
19241924
i - j as uint);
19251925
ptr::copy_nonoverlapping_memory(buf_dat.offset(j), read_ptr, 1);
19261926
}
@@ -1970,11 +1970,11 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
19701970
if left == right_start {
19711971
// the number remaining in this run.
19721972
let elems = (right_end as uint - right as uint) / mem::size_of::<T>();
1973-
ptr::copy_nonoverlapping_memory(out, right, elems);
1973+
ptr::copy_nonoverlapping_memory(out, &*right, elems);
19741974
break;
19751975
} else if right == right_end {
19761976
let elems = (right_start as uint - left as uint) / mem::size_of::<T>();
1977-
ptr::copy_nonoverlapping_memory(out, left, elems);
1977+
ptr::copy_nonoverlapping_memory(out, &*left, elems);
19781978
break;
19791979
}
19801980

@@ -1988,7 +1988,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
19881988
} else {
19891989
step(&mut left)
19901990
};
1991-
ptr::copy_nonoverlapping_memory(out, to_copy, 1);
1991+
ptr::copy_nonoverlapping_memory(out, &*to_copy, 1);
19921992
step(&mut out);
19931993
}
19941994
}
@@ -2002,7 +2002,7 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
20022002
// write the result to `v` in one go, so that there are never two copies
20032003
// of the same object in `v`.
20042004
unsafe {
2005-
ptr::copy_nonoverlapping_memory(v.as_mut_ptr(), buf_dat, len);
2005+
ptr::copy_nonoverlapping_memory(v.as_mut_ptr(), &*buf_dat, len);
20062006
}
20072007

20082008
// increment the pointer, returning the old pointer.

0 commit comments

Comments
 (0)