Skip to content

Commit 6c5ce38

Browse files
committed
---
yaml --- r: 149047 b: refs/heads/try2 c: 66c036c h: refs/heads/master i: 149045: 0a2d5b3 149043: bacb7e5 149039: f5bda0d v: v3
1 parent d368095 commit 6c5ce38

35 files changed

+153
-223
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: cf243f9b593d322f6bfaed906c42d2fc8e3d0ce7
8+
refs/heads/try2: 66c036c293626bf38cd3c3635abbf0fa8c80260c
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/guide-ffi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ and `free`:
176176
~~~~
177177
use std::cast;
178178
use std::libc::{c_void, size_t, malloc, free};
179-
use std::mem;
180179
use std::ptr;
180+
use std::unstable::intrinsics;
181181
182182
// Define a wrapper around the handle returned by the foreign code.
183183
// Unique<T> has the same semantics as ~T
@@ -199,7 +199,7 @@ impl<T: Send> Unique<T> {
199199
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
200200
// move_val_init moves a value into this memory without
201201
// attempting to drop the original value.
202-
mem::move_val_init(&mut *ptr, value);
202+
intrinsics::move_val_init(&mut *ptr, value);
203203
Unique{ptr: ptr}
204204
}
205205
}
@@ -226,7 +226,7 @@ impl<T: Send> Unique<T> {
226226
impl<T: Send> Drop for Unique<T> {
227227
fn drop(&mut self) {
228228
unsafe {
229-
let x = mem::uninit(); // dummy value to swap in
229+
let x = intrinsics::uninit(); // dummy value to swap in
230230
// We need to move the object out of the box, so that
231231
// the destructor is called (at the end of this scope.)
232232
ptr::replace_ptr(self.ptr, x);

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/libarena/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ use collections::list;
3232
use std::cast::{transmute, transmute_mut, transmute_mut_region};
3333
use std::cast;
3434
use std::cell::{Cell, RefCell};
35-
use std::mem;
3635
use std::num;
3736
use std::ptr;
3837
use std::kinds::marker;
38+
use std::mem;
3939
use std::rc::Rc;
4040
use std::rt::global_heap;
4141
use std::unstable::intrinsics::{TyDesc, get_tydesc};
@@ -216,7 +216,7 @@ impl Arena {
216216
unsafe {
217217
let ptr = self.alloc_pod_inner(mem::size_of::<T>(), mem::min_align_of::<T>());
218218
let ptr: *mut T = transmute(ptr);
219-
mem::move_val_init(&mut (*ptr), op());
219+
intrinsics::move_val_init(&mut (*ptr), op());
220220
return transmute(ptr);
221221
}
222222
}
@@ -278,7 +278,7 @@ impl Arena {
278278
// has *not* been initialized yet.
279279
*ty_ptr = transmute(tydesc);
280280
// Actually initialize it
281-
mem::move_val_init(&mut(*ptr), op());
281+
intrinsics::move_val_init(&mut(*ptr), op());
282282
// Now that we are done, update the tydesc to indicate that
283283
// the object is there.
284284
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
@@ -379,7 +379,7 @@ impl TypedArenaChunk {
379379
let mut chunk = unsafe {
380380
let chunk = global_heap::exchange_malloc(size);
381381
let mut chunk: ~TypedArenaChunk = cast::transmute(chunk);
382-
mem::move_val_init(&mut chunk.next, next);
382+
intrinsics::move_val_init(&mut chunk.next, next);
383383
chunk
384384
};
385385

@@ -466,7 +466,7 @@ impl<T> TypedArena<T> {
466466
}
467467

468468
let ptr: &'a mut T = cast::transmute(this.ptr);
469-
mem::move_val_init(ptr, object);
469+
intrinsics::move_val_init(ptr, object);
470470
this.ptr = this.ptr.offset(1);
471471
let ptr: &'a T = ptr;
472472
ptr

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 `v`, starting from the first.
49+
* Apply function `f` to each element of `ls`, 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/libcollections/priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#[allow(missing_doc)];
1414

1515
use std::clone::Clone;
16-
use std::mem::{move_val_init, init};
16+
use std::unstable::intrinsics::{move_val_init, init};
1717
use std::util::{replace, swap};
1818
use std::vec;
1919

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use std::io::IoError;
1616
use std::io;
1717
use std::libc::{c_int, c_void};
1818
use std::libc;
19-
use std::mem;
2019
use std::os;
2120
use std::rt::rtio;
21+
use std::unstable::intrinsics;
2222
use std::vec;
2323

2424
use io::{IoResult, retry};
@@ -147,7 +147,7 @@ impl rtio::RtioFileStream for FileDesc {
147147
#[cfg(windows)]
148148
fn os_pread(fd: c_int, buf: *u8, amt: uint, offset: u64) -> IoResult<int> {
149149
unsafe {
150-
let mut overlap: libc::OVERLAPPED = mem::init();
150+
let mut overlap: libc::OVERLAPPED = intrinsics::init();
151151
let handle = libc::get_osfhandle(fd) as libc::HANDLE;
152152
let mut bytes_read = 0;
153153
overlap.Offset = offset as libc::DWORD;
@@ -179,7 +179,7 @@ impl rtio::RtioFileStream for FileDesc {
179179
#[cfg(windows)]
180180
fn os_pwrite(fd: c_int, buf: *u8, amt: uint, offset: u64) -> IoResult<()> {
181181
unsafe {
182-
let mut overlap: libc::OVERLAPPED = mem::init();
182+
let mut overlap: libc::OVERLAPPED = intrinsics::init();
183183
let handle = libc::get_osfhandle(fd) as libc::HANDLE;
184184
overlap.Offset = offset as libc::DWORD;
185185
overlap.OffsetHigh = (offset >> 32) as libc::DWORD;
@@ -867,7 +867,7 @@ pub fn stat(p: &CString) -> IoResult<io::FileStat> {
867867

868868
#[cfg(windows)]
869869
fn os_stat(p: &CString) -> IoResult<io::FileStat> {
870-
let mut stat: libc::stat = unsafe { mem::uninit() };
870+
let mut stat: libc::stat = unsafe { intrinsics::uninit() };
871871
as_utf16_p(p.as_str().unwrap(), |up| {
872872
match retry(|| unsafe { libc::wstat(up, &mut stat) }) {
873873
0 => Ok(mkstat(&stat, p)),
@@ -878,7 +878,7 @@ pub fn stat(p: &CString) -> IoResult<io::FileStat> {
878878

879879
#[cfg(unix)]
880880
fn os_stat(p: &CString) -> IoResult<io::FileStat> {
881-
let mut stat: libc::stat = unsafe { mem::uninit() };
881+
let mut stat: libc::stat = unsafe { intrinsics::uninit() };
882882
match retry(|| unsafe { libc::stat(p.with_ref(|p| p), &mut stat) }) {
883883
0 => Ok(mkstat(&stat, p)),
884884
_ => Err(super::last_error()),
@@ -897,7 +897,7 @@ pub fn lstat(p: &CString) -> IoResult<io::FileStat> {
897897

898898
#[cfg(unix)]
899899
fn os_lstat(p: &CString) -> IoResult<io::FileStat> {
900-
let mut stat: libc::stat = unsafe { mem::uninit() };
900+
let mut stat: libc::stat = unsafe { intrinsics::uninit() };
901901
match retry(|| unsafe { libc::lstat(p.with_ref(|p| p), &mut stat) }) {
902902
0 => Ok(mkstat(&stat, p)),
903903
_ => Err(super::last_error()),

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::libc;
1515
use std::mem;
1616
use std::rt::rtio;
1717
use std::sync::arc::UnsafeArc;
18+
use std::unstable::intrinsics;
1819

1920
use super::{IoResult, retry};
2021
use super::file::keep_going;
@@ -27,10 +28,10 @@ use super::file::keep_going;
2728
#[cfg(unix)] pub type sock_t = super::file::fd_t;
2829

2930
pub fn htons(u: u16) -> u16 {
30-
mem::to_be16(u as i16) as u16
31+
intrinsics::to_be16(u as i16) as u16
3132
}
3233
pub fn ntohs(u: u16) -> u16 {
33-
mem::from_be16(u as i16) as u16
34+
intrinsics::from_be16(u as i16) as u16
3435
}
3536

3637
enum InAddr {
@@ -67,7 +68,7 @@ fn ip_to_inaddr(ip: ip::IpAddr) -> InAddr {
6768

6869
fn addr_to_sockaddr(addr: ip::SocketAddr) -> (libc::sockaddr_storage, uint) {
6970
unsafe {
70-
let storage: libc::sockaddr_storage = mem::init();
71+
let storage: libc::sockaddr_storage = intrinsics::init();
7172
let len = match ip_to_inaddr(addr.ip) {
7273
InAddr(inaddr) => {
7374
let storage: *mut libc::sockaddr_in = cast::transmute(&storage);
@@ -137,7 +138,7 @@ fn sockname(fd: sock_t,
137138
*mut libc::socklen_t) -> libc::c_int)
138139
-> IoResult<ip::SocketAddr>
139140
{
140-
let mut storage: libc::sockaddr_storage = unsafe { mem::init() };
141+
let mut storage: libc::sockaddr_storage = unsafe { intrinsics::init() };
141142
let mut len = mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;
142143
unsafe {
143144
let storage = &mut storage as *mut libc::sockaddr_storage;
@@ -224,7 +225,7 @@ pub fn init() {
224225

225226
LOCK.lock();
226227
if !INITIALIZED {
227-
let mut data: WSADATA = mem::init();
228+
let mut data: WSADATA = intrinsics::init();
228229
let ret = WSAStartup(0x202, // version 2.2
229230
&mut data);
230231
assert_eq!(ret, 0);
@@ -437,7 +438,7 @@ impl TcpAcceptor {
437438

438439
pub fn native_accept(&mut self) -> IoResult<TcpStream> {
439440
unsafe {
440-
let mut storage: libc::sockaddr_storage = mem::init();
441+
let mut storage: libc::sockaddr_storage = intrinsics::init();
441442
let storagep = &mut storage as *mut libc::sockaddr_storage;
442443
let size = mem::size_of::<libc::sockaddr_storage>();
443444
let mut size = size as libc::socklen_t;
@@ -542,7 +543,7 @@ impl rtio::RtioSocket for UdpSocket {
542543
impl rtio::RtioUdpSocket for UdpSocket {
543544
fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, ip::SocketAddr)> {
544545
unsafe {
545-
let mut storage: libc::sockaddr_storage = mem::init();
546+
let mut storage: libc::sockaddr_storage = intrinsics::init();
546547
let storagep = &mut storage as *mut libc::sockaddr_storage;
547548
let mut addrlen: libc::socklen_t =
548549
mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;

0 commit comments

Comments
 (0)