diff --git a/doc/tutorial.md b/doc/tutorial.md
index f9408761877..d31fbbb0c07 100644
--- a/doc/tutorial.md
+++ b/doc/tutorial.md
@@ -2304,11 +2304,10 @@ mod farm {
farmer: Human
}
- // Note - visibility modifiers on impls currently have no effect
impl Farm {
priv fn feed_chickens(&self) { ... }
priv fn feed_cows(&self) { ... }
- fn add_chicken(&self, c: Chicken) { ... }
+ pub fn add_chicken(&self, c: Chicken) { ... }
}
pub fn feed_animals(farm: &Farm) {
diff --git a/src/etc/gedit/readme.txt b/src/etc/gedit/readme.txt
new file mode 100644
index 00000000000..735b0236276
--- /dev/null
+++ b/src/etc/gedit/readme.txt
@@ -0,0 +1,11 @@
+Add syntax highlighting for Mozilla Rust in GtkSourceView (used by GEdit).
+
+
+Instructions for Ubuntu Linux 12.04+
+
+1) Close all instances of GEdit
+
+2) Copy the included "share" folder into "~/.local/"
+
+3) Open a shell in "~/.local/share/" and run "update-mime-database mime"
+
diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
new file mode 100644
index 00000000000..0b23808b765
--- /dev/null
+++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
@@ -0,0 +1,264 @@
+
+
+
+
+
+
+ text/x-rust
+ *.rs;*.rc
+ //
+ /*
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ fn
+
+
+
+ type
+
+
+
+ as
+ assert
+ break
+ const
+ copy
+ do
+ drop
+ else
+ enum
+ export
+ extern
+ fail
+ for
+ if
+ impl
+ let
+ log
+ loop
+ match
+ mod
+ move
+ mut
+ priv
+ pub
+ pure
+ ref
+ return
+ static
+ struct
+ trait
+ unsafe
+ use
+ while
+
+
+
+ bool
+ int
+ uint
+ i8
+ i16
+ i32
+ i64
+ u8
+ u16
+ u32
+ u64
+ f32
+ f64
+ float
+ char
+ str
+ Either
+ Option
+ Result
+
+
+
+ c_float
+ c_double
+ c_void
+ FILE
+ fpos_t
+ DIR
+ dirent
+ c_char
+ c_schar
+ c_uchar
+ c_short
+ c_ushort
+ c_int
+ c_uint
+ c_long
+ c_ulong
+ size_t
+ ptrdiff_t
+ clock_t
+ time_t
+ c_longlong
+ c_ulonglong
+ intptr_t
+ uintptr_t
+ off_t
+ dev_t
+ ino_t
+ pid_t
+ mode_t
+ ssize_t
+
+
+
+ self
+
+
+
+ true
+ false
+ Some
+ None
+ Left
+ Right
+ Ok
+ Err
+ Success
+ Failure
+ Cons
+ Nil
+
+
+
+ EXIT_FAILURE
+ EXIT_SUCCESS
+ RAND_MAX
+ EOF
+ SEEK_SET
+ SEEK_CUR
+ SEEK_END
+ _IOFBF
+ _IONBF
+ _IOLBF
+ BUFSIZ
+ FOPEN_MAX
+ FILENAME_MAX
+ L_tmpnam
+ TMP_MAX
+ O_RDONLY
+ O_WRONLY
+ O_RDWR
+ O_APPEND
+ O_CREAT
+ O_EXCL
+ O_TRUNC
+ S_IFIFO
+ S_IFCHR
+ S_IFBLK
+ S_IFDIR
+ S_IFREG
+ S_IFMT
+ S_IEXEC
+ S_IWRITE
+ S_IREAD
+ S_IRWXU
+ S_IXUSR
+ S_IWUSR
+ S_IRUSR
+ F_OK
+ R_OK
+ W_OK
+ X_OK
+ STDIN_FILENO
+ STDOUT_FILENO
+ STDERR_FILENO
+
+
+
+
+
+
+
+
+ (?<![\w\.])
+ (
+ 0x[0-9a-fA-F_]+(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?|
+ 0b[0-1_]+(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?|
+ [0-9][0-9_]*\.[0-9_]*([eE][+-]?[0-9_]+)?(f32|f64|f)?|
+ [0-9][0-9_]*(u8|u16|u32|u64|i8|i16|i32|i64|u|i)?
+ )
+ (?![\w\.])
+
+
+
+
+
+ [a-zA-Z_][a-zA-Z0-9_]*::
+
+
+
+
+ "
+ "
+
+
+
+
+
+
+
+ '
+ '
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/etc/gedit/share/mime/packages/rust.xml b/src/etc/gedit/share/mime/packages/rust.xml
new file mode 100644
index 00000000000..65168aae1d9
--- /dev/null
+++ b/src/etc/gedit/share/mime/packages/rust.xml
@@ -0,0 +1,7 @@
+
+
+ Rust Source
+
+
+
+
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 5887df6802f..6c35c62c3a7 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -28,7 +28,7 @@ pub pure fn empty_cell() -> Cell {
Cell { value: None }
}
-impl Cell {
+pub impl Cell {
/// Yields the value, failing if the cell is empty.
fn take() -> T {
if self.is_empty() {
diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs
index 7939644e51c..b0825816626 100644
--- a/src/libcore/comm.rs
+++ b/src/libcore/comm.rs
@@ -8,9 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// Transitional -- needs snapshot
-#[allow(structural_records)];
-
use either::{Either, Left, Right};
use kinds::Owned;
use option;
@@ -190,7 +187,7 @@ pub fn PortSet() -> PortSet{
}
}
-impl PortSet {
+pub impl PortSet {
fn add(port: Port) {
self.ports.push(port)
@@ -323,12 +320,12 @@ pub fn oneshot() -> (PortOne, ChanOne) {
(port, chan)
}
-impl PortOne {
+pub impl PortOne {
fn recv(self) -> T { recv_one(self) }
fn try_recv(self) -> Option { try_recv_one(self) }
}
-impl ChanOne {
+pub impl ChanOne {
fn send(self, data: T) { send_one(self, data) }
fn try_send(self, data: T) -> bool { try_send_one(self, data) }
}
diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs
index a7c8c1f4d66..00048beae5a 100644
--- a/src/libcore/condition.rs
+++ b/src/libcore/condition.rs
@@ -25,7 +25,7 @@ pub struct Condition {
key: task::local_data::LocalDataKey>
}
-impl Condition {
+pub impl Condition {
fn trap(&self, h: &self/fn(T) -> U) -> Trap/&self {
unsafe {
let p : *RustClosure = ::cast::transmute(&h);
@@ -69,7 +69,7 @@ struct Trap {
handler: @Handler
}
-impl Trap {
+pub impl Trap {
fn in(&self, inner: &self/fn() -> V) -> V {
unsafe {
let _g = Guard { cond: self.cond };
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index ed18388f578..91eb61e342e 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -227,10 +227,6 @@ pub const debug : u32 = 4_u32;
// The runtime interface used by the compiler
#[cfg(notest)] pub mod rt;
-// The runtime and compiler interface to fmt!
-#[cfg(stage0)]
-#[path = "private/extfmt.rs"]
-pub mod extfmt;
// Private APIs
pub mod private;
diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs
index 35807364889..f1f4e558661 100644
--- a/src/libcore/dlist.rs
+++ b/src/libcore/dlist.rs
@@ -62,7 +62,7 @@ priv impl DListNode {
}
}
-impl DListNode {
+pub impl DListNode {
/// Get the next node in the list, if there is one.
pure fn next_link(@mut self) -> DListLink {
self.assert_links();
@@ -208,7 +208,7 @@ priv impl DList {
}
}
-impl DList {
+pub impl DList {
/// Get the size of the list. O(1).
pure fn len(@mut self) -> uint { self.size }
/// Returns true if the list is empty. O(1).
@@ -457,7 +457,7 @@ impl DList {
}
}
-impl DList {
+pub impl DList {
/// Remove data from the head of the list. O(1).
fn pop(@mut self) -> Option {
self.pop_n().map(|nobe| nobe.data)
diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs
index 9f2036c5f41..1fef4ad42f1 100644
--- a/src/libcore/dvec.rs
+++ b/src/libcore/dvec.rs
@@ -92,17 +92,6 @@ priv impl DVec {
}
}
- #[inline(always)]
- fn check_out(f: &fn(v: ~[A]) -> B) -> B {
- unsafe {
- let mut data = cast::reinterpret_cast(&null::<()>());
- data <-> self.data;
- let data_ptr: *() = cast::reinterpret_cast(&data);
- if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
- return f(data);
- }
- }
-
#[inline(always)]
fn give_back(data: ~[A]) {
unsafe {
@@ -117,7 +106,19 @@ priv impl DVec {
// In theory, most everything should work with any A, but in practice
// almost nothing works without the copy bound due to limitations
// around closures.
-impl DVec {
+pub impl DVec {
+ // FIXME (#3758): This should not need to be public.
+ #[inline(always)]
+ fn check_out(f: &fn(v: ~[A]) -> B) -> B {
+ unsafe {
+ let mut data = cast::reinterpret_cast(&null::<()>());
+ data <-> self.data;
+ let data_ptr: *() = cast::reinterpret_cast(&data);
+ if data_ptr.is_null() { fail!(~"Recursive use of dvec"); }
+ return f(data);
+ }
+ }
+
/// Reserves space for N elements
fn reserve(count: uint) {
vec::reserve(&mut self.data, count)
@@ -215,7 +216,7 @@ impl DVec {
}
}
-impl DVec {
+pub impl DVec {
/**
* Append all elements of a vector to the end of the list
*
diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs
index 07c7780898f..c2a39cfdcc3 100644
--- a/src/libcore/hashmap.rs
+++ b/src/libcore/hashmap.rs
@@ -10,14 +10,12 @@
//! Sendable hash maps.
-use container::{Container, Mutable, Map, Set};
-use cmp::Eq;
-use hash::Hash;
-use to_bytes::IterBytes;
-
/// Open addressing with linear probing.
pub mod linear {
- use super::*;
+ use container::{Container, Mutable, Map, Set};
+ use cmp::Eq;
+ use hash::Hash;
+ use to_bytes::IterBytes;
use iter::BaseIter;
use hash::Hash;
use iter;
@@ -752,7 +750,8 @@ mod test_map {
#[test]
mod test_set {
- use super::*;
+ use hashmap::linear;
+ use container::{Container, Mutable, Map, Set};
use vec;
#[test]
diff --git a/src/libcore/io.rs b/src/libcore/io.rs
index 45d89b29a2e..fdb622f6539 100644
--- a/src/libcore/io.rs
+++ b/src/libcore/io.rs
@@ -504,7 +504,7 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader {
pub fn stdin() -> @Reader {
unsafe {
- rustrt::rust_get_stdin() as @Reader
+ @rustrt::rust_get_stdin() as @Reader
}
}
@@ -642,11 +642,11 @@ impl Writer for *libc::FILE {
}
}
-pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer {
+pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> @Writer {
if cleanup {
- Wrapper { base: f, cleanup: FILERes(f) } as Writer
+ @Wrapper { base: f, cleanup: FILERes(f) } as @Writer
} else {
- f as Writer
+ @f as @Writer
}
}
@@ -702,11 +702,11 @@ pub fn FdRes(fd: fd_t) -> FdRes {
}
}
-pub fn fd_writer(fd: fd_t, cleanup: bool) -> Writer {
+pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
if cleanup {
- Wrapper { base: fd, cleanup: FdRes(fd) } as Writer
+ @Wrapper { base: fd, cleanup: FdRes(fd) } as @Writer
} else {
- fd as Writer
+ @fd as @Writer
}
}
diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs
index 1fb855520ba..f888fbdb40c 100644
--- a/src/libcore/mutable.rs
+++ b/src/libcore/mutable.rs
@@ -43,7 +43,7 @@ pub fn unwrap(m: Mut) -> T {
value
}
-impl Data {
+pub impl Data {
fn borrow_mut(op: &fn(t: &mut T) -> R) -> R {
match self.mode {
Immutable => fail!(fmt!("%? currently immutable",
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index 12ed0df0076..53944c4c2c8 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -281,7 +281,7 @@ pub pure fn expect(opt: Option, reason: &str) -> T {
}
}
-impl Option {
+pub impl Option {
/// Returns true if the option equals `none`
#[inline(always)]
pure fn is_none(&self) -> bool { is_none(self) }
@@ -393,7 +393,7 @@ impl Option {
pure fn expect(self, reason: &str) -> T { expect(self, reason) }
}
-impl Option {
+pub impl Option {
/**
Gets the value out of an option
@@ -421,7 +421,7 @@ impl Option {
}
}
-impl Option {
+pub impl Option {
#[inline(always)]
pure fn get_or_zero(self) -> T { get_or_zero(self) }
}
diff --git a/src/libcore/os.rs b/src/libcore/os.rs
index 2522e9c2cda..8b6d27496d9 100644
--- a/src/libcore/os.rs
+++ b/src/libcore/os.rs
@@ -1021,10 +1021,10 @@ extern {
pub mod consts {
#[cfg(unix)]
- use os::consts::unix::*;
+ pub use os::consts::unix::*;
#[cfg(windows)]
- use os::consts::windows::*;
+ pub use os::consts::windows::*;
pub mod unix {
pub const FAMILY: &str = "unix";
@@ -1035,19 +1035,19 @@ pub mod consts {
}
#[cfg(target_os = "macos")]
- use os::consts::macos::*;
+ pub use os::consts::macos::*;
#[cfg(target_os = "freebsd")]
- use os::consts::freebsd::*;
+ pub use os::consts::freebsd::*;
#[cfg(target_os = "linux")]
- use os::consts::linux::*;
+ pub use os::consts::linux::*;
#[cfg(target_os = "android")]
- use os::consts::android::*;
+ pub use os::consts::android::*;
#[cfg(target_os = "win32")]
- use os::consts::win32::*;
+ pub use os::consts::win32::*;
pub mod macos {
pub const SYSNAME: &str = "macos";
@@ -1086,13 +1086,13 @@ pub mod consts {
#[cfg(target_arch = "x86")]
- use os::consts::x86::*;
+ pub use os::consts::x86::*;
#[cfg(target_arch = "x86_64")]
- use os::consts::x86_64::*;
+ pub use os::consts::x86_64::*;
#[cfg(target_arch = "arm")]
- use os::consts::arm::*;
+ pub use os::consts::arm::*;
pub mod x86 {
pub const ARCH: &str = "x86";
diff --git a/src/libcore/path.rs b/src/libcore/path.rs
index 1753862649f..4e0e4e93cf5 100644
--- a/src/libcore/path.rs
+++ b/src/libcore/path.rs
@@ -241,7 +241,7 @@ mod stat {
}
-impl Path {
+pub impl Path {
fn stat(&self) -> Option {
unsafe {
do str::as_c_str(self.to_str()) |buf| {
@@ -290,7 +290,7 @@ impl Path {
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
-impl Path {
+pub impl Path {
fn get_atime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
@@ -324,7 +324,7 @@ impl Path {
#[cfg(target_os = "freebsd")]
#[cfg(target_os = "macos")]
-impl Path {
+pub impl Path {
fn get_birthtime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
@@ -337,7 +337,7 @@ impl Path {
}
#[cfg(target_os = "win32")]
-impl Path {
+pub impl Path {
fn get_atime(&self) -> Option<(i64, int)> {
match self.stat() {
None => None,
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index a0a29c6b516..77554656913 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -82,8 +82,6 @@ bounded and unbounded protocols allows for less code duplication.
*/
-#[allow(structural_records)]; // Macros -- needs another snapshot
-
use cmp::Eq;
use cast::{forget, reinterpret_cast, transmute};
use cell::Cell;
@@ -800,7 +798,7 @@ pub fn SendPacketBuffered(p: *Packet)
}
}
-impl SendPacketBuffered {
+pub impl SendPacketBuffered {
fn unwrap() -> *Packet {
let mut p = None;
p <-> self.p;
@@ -857,7 +855,7 @@ impl ::ops::Drop for RecvPacketBuffered {
}
}
-impl RecvPacketBuffered {
+pub impl RecvPacketBuffered {
fn unwrap() -> *Packet {
let mut p = None;
p <-> self.p;
diff --git a/src/libcore/private.rs b/src/libcore/private.rs
index e4fab18966c..d19951e76db 100644
--- a/src/libcore/private.rs
+++ b/src/libcore/private.rs
@@ -107,20 +107,9 @@ fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool {
* Shared state & exclusive ARC
****************************************************************************/
-struct UnwrapProtoInner {
- contents: Option<(comm::ChanOne<()>, comm::PortOne)>,
-}
-
-// An unwrapper uses this protocol to communicate with the "other" task that
-// drops the last refcount on an arc. Unfortunately this can't be a proper
-// pipe protocol because the unwrapper has to access both stages at once.
-type UnwrapProto = ~UnwrapProtoInner;
-
struct ArcData {
mut count: libc::intptr_t,
- mut unwrapper: int, // either a UnwrapProto or 0
- // FIXME(#3224) should be able to make this non-option to save memory, and
- // in unwrap() use "let ~ArcData { data: result, _ } = thing" to unwrap it
+ // FIXME(#3224) should be able to make this non-option to save memory
mut data: Option,
}
@@ -131,37 +120,13 @@ struct ArcDestruct {
impl Drop for ArcDestruct{
fn finalize(&self) {
unsafe {
- if self.data.is_null() {
- return; // Happens when destructing an unwrapper's handle.
- }
do task::unkillable {
let data: ~ArcData = cast::reinterpret_cast(&self.data);
let new_count =
intrinsics::atomic_xsub(&mut data.count, 1) - 1;
assert new_count >= 0;
if new_count == 0 {
- // Were we really last, or should we hand off to an
- // unwrapper? It's safe to not xchg because the unwrapper
- // will set the unwrap lock *before* dropping his/her
- // reference. In effect, being here means we're the only
- // *awake* task with the data.
- if data.unwrapper != 0 {
- let mut p: UnwrapProto =
- cast::reinterpret_cast(&data.unwrapper);
- let (message, response) =
- option::swap_unwrap(&mut p.contents);
- // Send 'ready' and wait for a response.
- comm::send_one(message, ());
- // Unkillable wait. Message guaranteed to come.
- if comm::recv_one(response) {
- // Other task got the data.
- cast::forget(data);
- } else {
- // Other task was killed. drop glue takes over.
- }
- } else {
- // drop glue takes over.
- }
+ // drop glue takes over.
} else {
cast::forget(data);
}
@@ -176,79 +141,6 @@ fn ArcDestruct(data: *libc::c_void) -> ArcDestruct {
}
}
-pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState)
- -> T {
- struct DeathThroes {
- mut ptr: Option<~ArcData>,
- mut response: Option>,
- }
-
- impl Drop for DeathThroes{
- fn finalize(&self) {
- unsafe {
- let response = option::swap_unwrap(&mut self.response);
- // In case we get killed early, we need to tell the person who
- // tried to wake us whether they should hand-off the data to
- // us.
- if task::failing() {
- comm::send_one(response, false);
- // Either this swap_unwrap or the one below (at "Got
- // here") ought to run.
- cast::forget(option::swap_unwrap(&mut self.ptr));
- } else {
- assert self.ptr.is_none();
- comm::send_one(response, true);
- }
- }
- }
- }
-
- do task::unkillable {
- let ptr: ~ArcData = cast::reinterpret_cast(&rc.data);
- let (p1,c1) = comm::oneshot(); // ()
- let (p2,c2) = comm::oneshot(); // bool
- let mut server: UnwrapProto = ~UnwrapProtoInner {
- contents: Some((c1,p2))
- };
- let serverp: int = cast::transmute(server);
- // Try to put our server end in the unwrapper slot.
- if compare_and_swap(&mut ptr.unwrapper, 0, serverp) {
- // Got in. Step 0: Tell destructor not to run. We are now it.
- rc.data = ptr::null();
- // Step 1 - drop our own reference.
- let new_count = intrinsics::atomic_xsub(&mut ptr.count, 1) - 1;
- //assert new_count >= 0;
- if new_count == 0 {
- // We were the last owner. Can unwrap immediately.
- // Also we have to free the server endpoints.
- let _server: UnwrapProto = cast::transmute(serverp);
- option::swap_unwrap(&mut ptr.data)
- // drop glue takes over.
- } else {
- // The *next* person who sees the refcount hit 0 will wake us.
- let end_result =
- DeathThroes { ptr: Some(ptr),
- response: Some(c2) };
- let mut p1 = Some(p1); // argh
- do task::rekillable {
- comm::recv_one(option::swap_unwrap(&mut p1));
- }
- // Got here. Back in the 'unkillable' without getting killed.
- // Recover ownership of ptr, then take the data out.
- let ptr = option::swap_unwrap(&mut end_result.ptr);
- option::swap_unwrap(&mut ptr.data)
- // drop glue takes over.
- }
- } else {
- // Somebody else was trying to unwrap. Avoid guaranteed deadlock.
- cast::forget(ptr);
- // Also we have to free the (rejected) server endpoints.
- let _server: UnwrapProto = cast::transmute(serverp);
- fail!(~"Another task is already unwrapping this ARC!");
- }
- }
-}
-
/**
* COMPLETELY UNSAFE. Used as a primitive for the safe versions in std::arc.
*
@@ -259,7 +151,7 @@ pub type SharedMutableState = ArcDestruct;
pub unsafe fn shared_mutable_state(data: T) ->
SharedMutableState {
- let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) };
+ let data = ~ArcData { count: 1, data: Some(data) };
unsafe {
let ptr = cast::transmute(data);
ArcDestruct(ptr)
@@ -335,7 +227,7 @@ fn LittleLock() -> LittleLock {
}
}
-impl LittleLock {
+pub impl LittleLock {
#[inline(always)]
unsafe fn lock(f: fn() -> T) -> T {
struct Unlock {
@@ -381,7 +273,7 @@ impl Clone for Exclusive {
}
}
-impl Exclusive {
+pub impl Exclusive {
// Exactly like std::arc::mutex_arc,access(), but with the little_lock
// instead of a proper mutex. Same reason for being unsafe.
//
@@ -413,14 +305,6 @@ impl Exclusive {
}
}
-// FIXME(#3724) make this a by-move method on the exclusive
-pub fn unwrap_exclusive(arc: Exclusive) -> T {
- let Exclusive { x: x } = arc;
- let inner = unsafe { unwrap_shared_mutable_state(x) };
- let ExData { data: data, _ } = inner;
- data
-}
-
#[cfg(test)]
pub mod tests {
use core::option::{None, Some};
@@ -428,7 +312,7 @@ pub mod tests {
use cell::Cell;
use comm;
use option;
- use private::{exclusive, unwrap_exclusive};
+ use private::exclusive;
use result;
use task;
use uint;
@@ -479,70 +363,4 @@ pub mod tests {
assert *one == 1;
}
}
-
- #[test]
- pub fn exclusive_unwrap_basic() {
- let x = exclusive(~~"hello");
- assert unwrap_exclusive(x) == ~~"hello";
- }
-
- #[test]
- pub fn exclusive_unwrap_contended() {
- let x = exclusive(~~"hello");
- let x2 = Cell(x.clone());
- do task::spawn {
- let x2 = x2.take();
- do x2.with |_hello| { }
- task::yield();
- }
- assert unwrap_exclusive(x) == ~~"hello";
-
- // Now try the same thing, but with the child task blocking.
- let x = exclusive(~~"hello");
- let x2 = Cell(x.clone());
- let mut res = None;
- do task::task().future_result(|+r| res = Some(r)).spawn {
- let x2 = x2.take();
- assert unwrap_exclusive(x2) == ~~"hello";
- }
- // Have to get rid of our reference before blocking.
- { let _x = x; } // FIXME(#3161) util::ignore doesn't work here
- let res = option::swap_unwrap(&mut res);
- res.recv();
- }
-
- #[test] #[should_fail] #[ignore(cfg(windows))]
- pub fn exclusive_unwrap_conflict() {
- let x = exclusive(~~"hello");
- let x2 = Cell(x.clone());
- let mut res = None;
- do task::task().future_result(|+r| res = Some(r)).spawn {
- let x2 = x2.take();
- assert unwrap_exclusive(x2) == ~~"hello";
- }
- assert unwrap_exclusive(x) == ~~"hello";
- let res = option::swap_unwrap(&mut res);
- // See #4689 for why this can't be just "res.recv()".
- assert res.recv() == task::Success;
- }
-
- #[test] #[ignore(cfg(windows))]
- pub fn exclusive_unwrap_deadlock() {
- // This is not guaranteed to get to the deadlock before being killed,
- // but it will show up sometimes, and if the deadlock were not there,
- // the test would nondeterministically fail.
- let result = do task::try {
- // a task that has two references to the same exclusive will
- // deadlock when it unwraps. nothing to be done about that.
- let x = exclusive(~~"hello");
- let x2 = x.clone();
- do task::spawn {
- for 10.times { task::yield(); } // try to let the unwrapper go
- fail!(); // punt it awake from its deadlock
- }
- let _z = unwrap_exclusive(x);
- do x2.with |_hello| { }
- };
- assert result.is_err();
- }
}
diff --git a/src/libcore/private/extfmt.rs b/src/libcore/private/extfmt.rs
index 36ea67ea695..616d37a133a 100644
--- a/src/libcore/private/extfmt.rs
+++ b/src/libcore/private/extfmt.rs
@@ -142,7 +142,7 @@ pub mod ct {
next: uint
}
- impl Parsed {
+ pub impl Parsed {
static pure fn new(val: T, next: uint) -> Parsed {
Parsed {val: val, next: next}
}
diff --git a/src/libcore/private/finally.rs b/src/libcore/private/finally.rs
index af7197159ca..ff75963511c 100644
--- a/src/libcore/private/finally.rs
+++ b/src/libcore/private/finally.rs
@@ -26,33 +26,10 @@ do || {
use ops::Drop;
use task::{spawn, failing};
-#[cfg(stage0)]
-pub trait Finally {
- fn finally(&self, +dtor: &fn()) -> T;
-}
-
-#[cfg(stage1)]
-#[cfg(stage2)]
-#[cfg(stage3)]
pub trait Finally {
fn finally(&self, dtor: &fn()) -> T;
}
-#[cfg(stage0)]
-impl Finally for &fn() -> T {
- // FIXME #4518: Should not require a mode here
- fn finally(&self, +dtor: &fn()) -> T {
- let _d = Finallyalizer {
- dtor: dtor
- };
-
- (*self)()
- }
-}
-
-#[cfg(stage1)]
-#[cfg(stage2)]
-#[cfg(stage3)]
impl Finally for &fn() -> T {
fn finally(&self, dtor: &fn()) -> T {
let _d = Finallyalizer {
diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs
index 15362f89e3f..d9c2b91fb97 100644
--- a/src/libcore/rand.rs
+++ b/src/libcore/rand.rs
@@ -141,7 +141,7 @@ pub struct Weighted {
}
/// Extension methods for random number generators
-impl Rng {
+pub impl Rng {
/// Return a random value for a Rand type
fn gen() -> T {
Rand::rand(self)
@@ -412,8 +412,8 @@ pub fn Rng() -> Rng {
* all other generators constructed with the same seed. The seed may be any
* length.
*/
-pub fn seeded_rng(seed: &[u8]) -> Rng {
- seeded_randres(seed) as Rng
+pub fn seeded_rng(seed: &[u8]) -> @Rng {
+ @seeded_randres(seed) as @Rng
}
fn seeded_randres(seed: &[u8]) -> @RandRes {
@@ -449,8 +449,8 @@ pub pure fn xorshift() -> Rng {
seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32)
}
-pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
- XorShiftState { x: x, y: y, z: z, w: w } as Rng
+pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng {
+ @XorShiftState { x: x, y: y, z: z, w: w } as @Rng
}
@@ -472,10 +472,10 @@ pub fn task_rng() -> Rng {
unsafe {
let rng = seeded_randres(seed());
task::local_data::local_data_set(tls_rng_state, rng);
- rng as Rng
+ @rng as @Rng
}
}
- Some(rng) => rng as Rng
+ Some(rng) => @rng as @Rng
}
}
diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs
index ed7e485678e..2a688482f61 100644
--- a/src/libcore/reflect.rs
+++ b/src/libcore/reflect.rs
@@ -45,7 +45,7 @@ pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor {
MovePtrAdaptor { inner: v }
}
-impl MovePtrAdaptor {
+pub impl MovePtrAdaptor {
#[inline(always)]
fn bump(sz: uint) {
do self.inner.move_ptr() |p| {
diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs
index 4c3abb09756..af135339b2e 100644
--- a/src/libcore/repr.rs
+++ b/src/libcore/repr.rs
@@ -167,7 +167,7 @@ impl MovePtr for ReprVisitor {
}
}
-impl ReprVisitor {
+pub impl ReprVisitor {
// Various helpers for the TyVisitor impl
@@ -201,7 +201,7 @@ impl ReprVisitor {
unsafe {
let mut u = ReprVisitor(ptr, self.writer);
let v = reflect::MovePtrAdaptor(u);
- visit_tydesc(inner, (v) as @TyVisitor);
+ visit_tydesc(inner, @v as @TyVisitor);
true
}
}
@@ -570,7 +570,7 @@ pub fn write_repr(writer: @Writer, object: &T) {
let tydesc = intrinsic::get_tydesc::();
let mut u = ReprVisitor(ptr, writer);
let v = reflect::MovePtrAdaptor(u);
- visit_tydesc(tydesc, (v) as @TyVisitor)
+ visit_tydesc(tydesc, @v as @TyVisitor)
}
}
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index b03eaeab3e0..ddcd1547841 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -228,7 +228,7 @@ pub pure fn map_err(res: &Result, op: fn(&E) -> F)
}
}
-impl Result {
+pub impl Result {
#[inline(always)]
pure fn get_ref(&self) -> &self/T { get_ref(self) }
@@ -261,7 +261,7 @@ impl Result {
}
}
-impl Result {
+pub impl Result {
#[inline(always)]
pure fn get(&self) -> T { get(self) }
@@ -271,7 +271,7 @@ impl Result {
}
}
-impl Result {
+pub impl Result {
#[inline(always)]
pure fn get_err(&self) -> E { get_err(self) }
diff --git a/src/libcore/run.rs b/src/libcore/run.rs
index aa1e473e3bf..e8cd9caaef6 100644
--- a/src/libcore/run.rs
+++ b/src/libcore/run.rs
@@ -288,7 +288,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
finished: false,
};
- ProgRes(repr) as Program
+ @ProgRes(repr) as @Program
}
fn read_all(rd: io::Reader) -> ~str {
diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs
index 2e24df86c78..8950a1d0c02 100644
--- a/src/libcore/stackwalk.rs
+++ b/src/libcore/stackwalk.rs
@@ -10,9 +10,6 @@
#[doc(hidden)]; // FIXME #3538
-#[legacy_modes]; // tjc: remove after snapshot
-#[allow(deprecated_mode)];
-
use cast::reinterpret_cast;
use ptr::offset;
use sys::size_of;
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 66be5481819..6ee6d282841 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -2375,6 +2375,7 @@ impl OwnedStr for ~str {
#[cfg(test)]
mod tests {
use char;
+ use option::Some;
use debug;
use libc::c_char;
use libc;
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs
index 3ac457b23d1..df5a5af74ca 100644
--- a/src/libcore/task/local_data_priv.rs
+++ b/src/libcore/task/local_data_priv.rs
@@ -155,7 +155,7 @@ pub unsafe fn local_set(
// does not have a reference associated with it, so it may become invalid
// when the box is destroyed.
let data_ptr = cast::reinterpret_cast(&data);
- let data_box = data as LocalData;
+ let data_box = @data as @LocalData;
// Construct new entry to store in the map.
let new_entry = Some((keyval, data_ptr, data_box));
// Find a place to put it.
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs
index 2a640e4bf8c..49507897392 100644
--- a/src/libcore/task/mod.rs
+++ b/src/libcore/task/mod.rs
@@ -232,7 +232,7 @@ priv impl TaskBuilder {
}
}
-impl TaskBuilder {
+pub impl TaskBuilder {
/**
* Decouple the child task's failure from the parent's. If either fails,
* the other will not be killed.
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index 687ad2f7938..4d28c769b18 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -1444,7 +1444,7 @@ pub fn each2(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) {
* The total number of permutations produced is `len(v)!`. If `v` contains
* repeated elements, then some permutations are repeated.
*/
-pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) {
+pub pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) {
let ln = len(v);
if ln <= 1 {
put(v);
@@ -2427,6 +2427,7 @@ impl iter::CopyableNonstrictIter for @[A] {
mod tests {
use option::{None, Option, Some};
use option;
+ use sys;
use vec::*;
fn square(n: uint) -> uint { return n * n; }
diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs
index 877098ed49f..daf369f7279 100644
--- a/src/librustc/metadata/common.rs
+++ b/src/librustc/metadata/common.rs
@@ -132,9 +132,8 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
tag_table_method_map = 0x60,
tag_table_vtable_map = 0x61,
tag_table_adjustments = 0x62,
- tag_table_legacy_boxed_trait = 0x63,
- tag_table_moves_map = 0x64,
- tag_table_capture_map = 0x65
+ tag_table_moves_map = 0x63,
+ tag_table_capture_map = 0x64
}
pub const tag_item_trait_method_sort: uint = 0x70;
@@ -155,6 +154,7 @@ pub const tag_lang_items_item_node_id: uint = 0x75;
pub const tag_item_unnamed_field: uint = 0x76;
pub const tag_items_data_item_struct_ctor: uint = 0x77;
+pub const tag_items_data_item_visibility: uint = 0x78;
pub struct LinkMeta {
name: @str,
diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs
index eda7362b9c1..ae4a223c1ae 100644
--- a/src/librustc/metadata/csearch.rs
+++ b/src/librustc/metadata/csearch.rs
@@ -234,6 +234,14 @@ pub fn struct_dtor(cstore: @mut cstore::CStore, def: ast::def_id)
let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::struct_dtor(cdata, def.node)
}
+
+pub fn get_method_visibility(cstore: @mut cstore::CStore,
+ def_id: ast::def_id)
+ -> ast::visibility {
+ let cdata = cstore::get_crate_data(cstore, def_id.crate);
+ decoder::get_method_visibility(cdata, def_id.node)
+}
+
// Local Variables:
// mode: rust
// fill-column: 78;
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs
index 5d74d03e27b..cbe2217c9fc 100644
--- a/src/librustc/metadata/decoder.rs
+++ b/src/librustc/metadata/decoder.rs
@@ -151,6 +151,16 @@ fn item_family(item: ebml::Doc) -> Family {
}
}
+fn item_visibility(item: ebml::Doc) -> ast::visibility {
+ let visibility = reader::get_doc(item, tag_items_data_item_visibility);
+ match reader::doc_as_u8(visibility) as char {
+ 'y' => ast::public,
+ 'n' => ast::private,
+ 'i' => ast::inherited,
+ _ => fail!(~"unknown visibility character"),
+ }
+}
+
fn item_method_sort(item: ebml::Doc) -> char {
for reader::tagged_docs(item, tag_item_trait_method_sort) |doc| {
return str::from_bytes(reader::doc_data(doc))[0] as char;
@@ -860,7 +870,7 @@ pub fn get_item_attrs(cdata: cmd,
}
}
-pure fn family_to_visibility(family: Family) -> ast::visibility {
+pure fn struct_field_family_to_visibility(family: Family) -> ast::visibility {
match family {
PublicField => ast::public,
PrivateField => ast::private,
@@ -883,7 +893,7 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id)
result.push(ty::field_ty {
ident: name,
id: did, vis:
- family_to_visibility(f),
+ struct_field_family_to_visibility(f),
mutability: mt,
});
}
@@ -900,6 +910,11 @@ pub fn get_struct_fields(intr: @ident_interner, cdata: cmd, id: ast::node_id)
result
}
+pub fn get_method_visibility(cdata: cmd, id: ast::node_id)
+ -> ast::visibility {
+ item_visibility(lookup_item(id, cdata.data))
+}
+
fn family_has_type_params(fam: Family) -> bool {
match fam {
Const | ForeignType | Mod | ForeignMod | PublicField | PrivateField
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index a5932775003..7d2423c7c5d 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -383,7 +383,8 @@ fn encode_info_for_mod(ecx: @EncodeContext, ebml_w: writer::Encoder,
ebml_w.end_tag();
}
-fn encode_visibility(ebml_w: writer::Encoder, visibility: visibility) {
+fn encode_struct_field_family(ebml_w: writer::Encoder,
+ visibility: visibility) {
encode_family(ebml_w, match visibility {
public => 'g',
private => 'j',
@@ -391,6 +392,17 @@ fn encode_visibility(ebml_w: writer::Encoder, visibility: visibility) {
});
}
+fn encode_visibility(ebml_w: writer::Encoder, visibility: visibility) {
+ ebml_w.start_tag(tag_items_data_item_visibility);
+ let ch = match visibility {
+ public => 'y',
+ private => 'n',
+ inherited => 'i',
+ };
+ ebml_w.wr_str(str::from_char(ch));
+ ebml_w.end_tag();
+}
+
fn encode_self_type(ebml_w: writer::Encoder, self_type: ast::self_ty_) {
ebml_w.start_tag(tag_item_trait_method_self_ty);
@@ -456,7 +468,7 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: writer::Encoder,
ebml_w.start_tag(tag_items_data_item);
debug!("encode_info_for_struct: doing %s %d",
*tcx.sess.str_of(nm), id);
- encode_visibility(ebml_w, vis);
+ encode_struct_field_family(ebml_w, vis);
encode_name(ecx, ebml_w, nm);
encode_path(ecx, ebml_w, path, ast_map::path_name(nm));
encode_type(ecx, ebml_w, node_id_to_type(tcx, id));
@@ -525,6 +537,7 @@ fn encode_info_for_method(ecx: @EncodeContext,
should_inline: bool,
parent_id: node_id,
m: @method,
+ parent_visibility: ast::visibility,
owner_generics: &ast::Generics,
method_generics: &ast::Generics) {
debug!("encode_info_for_method: %d %s %u %u", m.id,
@@ -533,6 +546,7 @@ fn encode_info_for_method(ecx: @EncodeContext,
method_generics.ty_params.len());
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(m.id));
+
match m.self_ty.node {
ast::sty_static => {
encode_family(ebml_w, purity_static_method_family(m.purity));
@@ -550,6 +564,14 @@ fn encode_info_for_method(ecx: @EncodeContext,
encode_name(ecx, ebml_w, m.ident);
encode_path(ecx, ebml_w, impl_path, ast_map::path_name(m.ident));
encode_self_type(ebml_w, m.self_ty.node);
+
+ // Combine parent visibility and this visibility.
+ let visibility = match m.vis {
+ ast::inherited => parent_visibility,
+ vis => vis,
+ };
+ encode_visibility(ebml_w, visibility);
+
if len > 0u || should_inline {
(ecx.encode_inlined_item)(
ecx, ebml_w, impl_path,
@@ -568,6 +590,7 @@ fn purity_fn_family(p: purity) -> char {
extern_fn => 'e'
}
}
+
fn purity_static_method_family(p: purity) -> char {
match p {
unsafe_fn => 'U',
@@ -757,7 +780,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
match f.node.kind {
named_field(ident, _, vis) => {
ebml_w.start_tag(tag_item_field);
- encode_visibility(ebml_w, vis);
+ encode_struct_field_family(ebml_w, vis);
encode_name(ecx, ebml_w, ident);
encode_def_id(ebml_w, local_def(f.node.id));
ebml_w.end_tag();
@@ -808,12 +831,28 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
let mut impl_path = vec::append(~[], path);
impl_path += ~[ast_map::path_name(item.ident)];
+ // If there is a trait reference, treat the methods as always public.
+ // This is to work around some incorrect behavior in privacy checking:
+ // when the method belongs to a trait, it should acquire the privacy
+ // from the trait, not the impl. Forcing the visibility to be public
+ // makes things sorta work.
+ let parent_visibility = if opt_trait.is_some() {
+ ast::public
+ } else {
+ item.vis
+ };
+
for methods.each |m| {
index.push(entry {val: m.id, pos: ebml_w.writer.tell()});
- encode_info_for_method(ecx, ebml_w, impl_path,
+ encode_info_for_method(ecx,
+ ebml_w,
+ impl_path,
should_inline(m.attrs),
- item.id, *m,
- generics, &m.generics);
+ item.id,
+ *m,
+ parent_visibility,
+ generics,
+ &m.generics);
}
}
item_trait(ref generics, ref traits, ref ms) => {
@@ -902,9 +941,15 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
// of provided methods. I am not sure why this is. -ndm
let owner_generics = ast_util::empty_generics();
- encode_info_for_method(ecx, ebml_w, /*bad*/copy path,
- true, item.id, *m,
- &owner_generics, &m.generics);
+ encode_info_for_method(ecx,
+ ebml_w,
+ /*bad*/copy path,
+ true,
+ item.id,
+ *m,
+ item.vis,
+ &owner_generics,
+ &m.generics);
}
}
item_mac(*) => fail!(~"item macros unimplemented")
diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs
index 82ea0b6d6f1..1a7c7b0793a 100644
--- a/src/librustc/metadata/filesearch.rs
+++ b/src/librustc/metadata/filesearch.rs
@@ -71,11 +71,11 @@ pub fn mk_filesearch(maybe_sysroot: Option,
let sysroot = get_sysroot(maybe_sysroot);
debug!("using sysroot = %s", sysroot.to_str());
- FileSearchImpl {
+ @FileSearchImpl {
sysroot: sysroot,
addl_lib_search_paths: addl_lib_search_paths,
target_triple: str::from_slice(target_triple)
- } as FileSearch
+ } as @FileSearch
}
pub fn search(filesearch: FileSearch, pick: pick) -> Option {
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index ecc0ce90553..222931d1829 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -167,7 +167,7 @@ fn reserve_id_range(sess: Session,
ast_util::id_range { min: to_id_min, max: to_id_min }
}
-impl ExtendedDecodeContext {
+pub impl ExtendedDecodeContext {
fn tr_id(&self, id: ast::node_id) -> ast::node_id {
/*!
*
@@ -966,12 +966,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
}
}
- do option::iter(&tcx.legacy_boxed_traits.find(&id)) |_x| {
- do ebml_w.tag(c::tag_table_legacy_boxed_trait) {
- ebml_w.id(id);
- }
- }
-
for maps.moves_map.find(&id).each |_| {
do ebml_w.tag(c::tag_table_moves_map) {
ebml_w.id(id);
@@ -1121,8 +1115,6 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
if tag == (c::tag_table_mutbl as uint) {
dcx.maps.mutbl_map.insert(id, ());
- } else if tag == (c::tag_table_legacy_boxed_trait as uint) {
- dcx.tcx.legacy_boxed_traits.insert(id, ());
} else if tag == (c::tag_table_moves_map as uint) {
dcx.maps.moves_map.insert(id, ());
} else {
@@ -1230,7 +1222,7 @@ impl fake_ext_ctxt for fake_session {
#[cfg(test)]
fn mk_ctxt() -> fake_ext_ctxt {
- parse::new_parse_sess(None) as fake_ext_ctxt
+ @parse::new_parse_sess(None) as fake_ext_ctxt
}
#[cfg(test)]
diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs
index 6efcc0b97c0..c3555e54519 100644
--- a/src/librustc/middle/borrowck/check_loans.rs
+++ b/src/librustc/middle/borrowck/check_loans.rs
@@ -89,7 +89,7 @@ enum assignment_type {
at_swap
}
-impl assignment_type {
+pub impl assignment_type {
fn checked_by_liveness(&self) -> bool {
// the liveness pass guarantees that immutable local variables
// are only assigned once; but it doesn't consider &mut
@@ -106,7 +106,7 @@ impl assignment_type {
}
}
-impl CheckLoanCtxt {
+pub impl CheckLoanCtxt {
fn tcx(@mut self) -> ty::ctxt { self.bccx.tcx }
fn purity(@mut self, scope_id: ast::node_id) -> Option {
diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs
index eea11fa0675..c6f4f04fe71 100644
--- a/src/librustc/middle/borrowck/gather_loans.rs
+++ b/src/librustc/middle/borrowck/gather_loans.rs
@@ -289,7 +289,7 @@ fn req_loans_in_expr(ex: @ast::expr,
self.root_ub = old_root_ub;
}
-impl GatherLoanCtxt {
+pub impl GatherLoanCtxt {
fn tcx(@mut self) -> ty::ctxt { self.bccx.tcx }
fn guarantee_adjustments(@mut self,
diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs
index c39f2455c2f..e095c970931 100644
--- a/src/librustc/middle/borrowck/loan.rs
+++ b/src/librustc/middle/borrowck/loan.rs
@@ -87,7 +87,7 @@ struct LoanContext {
loans: ~[Loan]
}
-impl LoanContext {
+pub impl LoanContext {
fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
fn loan(&mut self,
diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs
index eb2a93d86f9..9bdf69f4c88 100644
--- a/src/librustc/middle/borrowck/mod.rs
+++ b/src/librustc/middle/borrowck/mod.rs
@@ -230,6 +230,7 @@ use middle::liveness;
use middle::mem_categorization::*;
use middle::region;
use middle::ty;
+use middle::typeck;
use middle::moves;
use util::common::{indenter, stmt_set};
use util::ppaux::{expr_repr, note_and_explain_region};
@@ -239,6 +240,7 @@ use core::cmp;
use core::dvec::DVec;
use core::io;
use core::result::{Result, Ok, Err};
+use core::to_bytes;
use std::list::{List, Cons, Nil};
use std::list;
use std::oldmap::{HashMap, Set};
@@ -433,7 +435,7 @@ pub fn save_and_restore_managed(save_and_restore_t: @mut T,
u
}
-impl LoanKind {
+pub impl LoanKind {
fn is_freeze(&self) -> bool {
match *self {
TotalFreeze | PartialFreeze => true,
diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs
index a123793e20b..aabcd7a2fe5 100644
--- a/src/librustc/middle/borrowck/preserve.rs
+++ b/src/librustc/middle/borrowck/preserve.rs
@@ -35,7 +35,7 @@ pub enum PreserveCondition {
PcIfPure(bckerr)
}
-impl PreserveCondition {
+pub impl PreserveCondition {
// combines two preservation conditions such that if either of
// them requires purity, the result requires purity
fn combine(&self, pc: PreserveCondition) -> PreserveCondition {
@@ -46,7 +46,7 @@ impl PreserveCondition {
}
}
-impl BorrowckCtxt {
+pub impl BorrowckCtxt {
fn preserve(&self,
cmt: cmt,
scope_region: ty::Region,
@@ -80,7 +80,7 @@ struct PreserveCtxt {
root_managed_data: bool
}
-impl PreserveCtxt {
+pub impl PreserveCtxt {
fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
fn preserve(&self, cmt: cmt) -> bckres {
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index c2c623e36d6..d399f0e6886 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -322,7 +322,7 @@ struct LanguageItemCollector {
item_refs: HashMap<@~str, uint>,
}
-impl LanguageItemCollector {
+pub impl LanguageItemCollector {
fn match_and_collect_meta_item(&self, item_def_id: def_id,
meta_item: @meta_item) {
match meta_item.node {
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index 1df59b64fe6..8bcc573ac36 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -331,7 +331,7 @@ struct Context {
sess: Session
}
-impl Context {
+pub impl Context {
fn get_level(&self, lint: lint) -> level {
get_lint_level(self.curr, lint)
}
diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs
index 86398dac6d8..5286fa1025a 100644
--- a/src/librustc/middle/liveness.rs
+++ b/src/librustc/middle/liveness.rs
@@ -254,7 +254,7 @@ impl to_str::ToStr for Variable {
// variable must not be assigned if there is some successor
// assignment. And so forth.
-impl LiveNode {
+pub impl LiveNode {
pure fn is_valid(&self) -> bool { **self != uint::max_value }
}
@@ -334,7 +334,7 @@ fn IrMaps(tcx: ty::ctxt,
}
}
-impl IrMaps {
+pub impl IrMaps {
fn add_live_node(&mut self, lnk: LiveNodeKind) -> LiveNode {
let ln = LiveNode(self.num_live_nodes);
self.lnks.push(lnk);
@@ -693,7 +693,7 @@ fn Liveness(ir: @mut IrMaps, specials: Specials) -> Liveness {
}
}
-impl Liveness {
+pub impl Liveness {
fn live_node(&self, node_id: node_id, span: span) -> LiveNode {
match self.ir.live_node_map.find(&node_id) {
Some(ln) => ln,
@@ -1649,7 +1649,7 @@ enum ReadKind {
PartiallyMovedValue
}
-impl @Liveness {
+pub impl @Liveness {
fn check_ret(&self, id: node_id, sp: span, _fk: &visit::fn_kind,
entry_ln: LiveNode) {
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 3f8ee61e841..227d262a79e 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -312,7 +312,7 @@ impl ToStr for MutabilityCategory {
}
}
-impl MutabilityCategory {
+pub impl MutabilityCategory {
static fn from_mutbl(&self, m: ast::mutability) -> MutabilityCategory {
match m {
m_imm => McImmutable,
diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs
index b23066c1d96..d5adfee65af 100644
--- a/src/librustc/middle/moves.rs
+++ b/src/librustc/middle/moves.rs
@@ -301,7 +301,7 @@ fn compute_modes_for_expr(expr: @expr,
cx.consume_expr(expr, v);
}
-impl UseMode {
+pub impl UseMode {
fn component_mode(&self, expr: @expr) -> UseMode {
/*!
*
@@ -316,7 +316,7 @@ impl UseMode {
}
}
-impl VisitContext {
+pub impl VisitContext {
fn consume_exprs(&self,
exprs: &[@expr],
visitor: vt)
diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs
index 3ec1cf3a705..e60069e05da 100644
--- a/src/librustc/middle/privacy.rs
+++ b/src/librustc/middle/privacy.rs
@@ -14,10 +14,11 @@
use core::prelude::*;
+use metadata::csearch;
use middle::ty::{ty_struct, ty_enum};
use middle::ty;
-use middle::typeck::{method_map, method_origin, method_param, method_self,
- method_super};
+use middle::typeck::{method_map, method_origin, method_param, method_self};
+use middle::typeck::{method_super};
use middle::typeck::{method_static, method_trait};
use core::dvec::DVec;
@@ -25,7 +26,7 @@ use core::util::ignore;
use syntax::ast::{def_variant, expr_field, expr_method_call, expr_struct};
use syntax::ast::{expr_unary, ident, item_struct, item_enum, item_impl};
use syntax::ast::{item_trait, local_crate, node_id, pat_struct, private};
-use syntax::ast::{provided, required};
+use syntax::ast::{provided, public, required};
use syntax::ast;
use syntax::ast_map::{node_item, node_method};
use syntax::ast_map;
@@ -100,14 +101,52 @@ pub fn check_crate(tcx: ty::ctxt,
};
// Checks that a private method is in scope.
- let check_method: @fn(span: span, origin: &method_origin) =
- |span, origin| {
+ let check_method: @fn(span: span,
+ origin: &method_origin,
+ ident: ast::ident) =
+ |span, origin, ident| {
match *origin {
method_static(method_id) => {
if method_id.crate == local_crate {
match tcx.items.find(&method_id.node) {
Some(node_method(method, impl_id, _)) => {
- if method.vis == private &&
+ let mut is_private = false;
+ if method.vis == private {
+ is_private = true;
+ } else if method.vis == public {
+ is_private = false;
+ } else {
+ // Look up the enclosing impl.
+ if impl_id.crate != local_crate {
+ tcx.sess.span_bug(span,
+ ~"local method isn't \
+ in local impl?!");
+ }
+
+ match tcx.items.find(&impl_id.node) {
+ Some(node_item(item, _)) => {
+ match item.node {
+ item_impl(_, None, _, _)
+ if item.vis != public => {
+ is_private = true;
+ }
+ _ => {}
+ }
+ }
+ Some(_) => {
+ tcx.sess.span_bug(span,
+ ~"impl wasn't an \
+ item?!");
+ }
+ None => {
+ tcx.sess.span_bug(span,
+ ~"impl wasn't in \
+ AST map?!");
+ }
+ }
+ }
+
+ if is_private &&
(impl_id.crate != local_crate ||
!privileged_items
.contains(&(impl_id.node))) {
@@ -131,7 +170,15 @@ pub fn check_crate(tcx: ty::ctxt,
}
}
} else {
- // FIXME #4732: External crates.
+ let visibility =
+ csearch::get_method_visibility(tcx.sess.cstore,
+ method_id);
+ if visibility != public {
+ tcx.sess.span_err(span,
+ fmt!("method `%s` is private",
+ *tcx.sess.parse_sess.interner
+ .get(ident)));
+ }
}
}
method_param(method_param {
@@ -230,14 +277,16 @@ pub fn check_crate(tcx: ty::ctxt,
Some(ref entry) => {
debug!("(privacy checking) checking \
impl method");
- check_method(expr.span, &(*entry).origin);
+ check_method(expr.span,
+ &entry.origin,
+ ident);
}
}
}
_ => {}
}
}
- expr_method_call(base, _, _, _, _) => {
+ expr_method_call(base, ident, _, _, _) => {
// Ditto
match ty::get(ty::type_autoderef(tcx, ty::expr_ty(tcx,
base))).sty {
@@ -253,7 +302,9 @@ pub fn check_crate(tcx: ty::ctxt,
Some(ref entry) => {
debug!("(privacy checking) checking \
impl method");
- check_method(expr.span, &(*entry).origin);
+ check_method(expr.span,
+ &entry.origin,
+ ident);
}
}
}
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index 6b7d4669621..1c4928fd374 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -622,6 +622,19 @@ pub impl NameBindings {
}
}
+ fn defined_in_public_namespace(namespace: Namespace) -> bool {
+ match namespace {
+ TypeNS => match self.type_def {
+ Some(def) => def.privacy != Private,
+ None => false
+ },
+ ValueNS => match self.value_def {
+ Some(def) => def.privacy != Private,
+ None => false
+ }
+ }
+ }
+
fn def_for_namespace(namespace: Namespace) -> Option {
match namespace {
TypeNS => {
@@ -2480,7 +2493,7 @@ pub impl Resolver {
// Here we merge two import resolutions.
match module_.import_resolutions.find(&ident) {
- None => {
+ None if target_import_resolution.privacy == Public => {
// Simple: just copy the old import resolution.
let new_import_resolution =
@mut ImportResolution(privacy,
@@ -2494,6 +2507,7 @@ pub impl Resolver {
module_.import_resolutions.insert
(ident, new_import_resolution);
}
+ None => { /* continue ... */ }
Some(dest_import_resolution) => {
// Merge the two import resolutions at a finer-grained
// level.
@@ -2537,7 +2551,6 @@ pub impl Resolver {
}
}
-
debug!("(resolving glob import) writing resolution `%s` in `%s` \
to `%s`, privacy=%?",
*self.session.str_of(ident),
@@ -2546,12 +2559,12 @@ pub impl Resolver {
dest_import_resolution.privacy);
// Merge the child item into the import resolution.
- if (*name_bindings).defined_in_namespace(ValueNS) {
+ if (*name_bindings).defined_in_public_namespace(ValueNS) {
debug!("(resolving glob import) ... for value target");
dest_import_resolution.value_target =
Some(Target(containing_module, name_bindings));
}
- if (*name_bindings).defined_in_namespace(TypeNS) {
+ if (*name_bindings).defined_in_public_namespace(TypeNS) {
debug!("(resolving glob import) ... for type target");
dest_import_resolution.type_target =
Some(Target(containing_module, name_bindings));
@@ -2756,6 +2769,8 @@ pub impl Resolver {
namespace);
}
Some(target) => {
+ debug!("(resolving item in lexical scope) using \
+ import resolution");
import_resolution.state.used = true;
return Success(copy target);
}
diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs
index 8ed85b8f421..2f920378087 100644
--- a/src/librustc/middle/trans/_match.rs
+++ b/src/librustc/middle/trans/_match.rs
@@ -145,9 +145,10 @@
use core::prelude::*;
use back::abi;
-use lib::llvm::llvm;
-use lib::llvm::{ValueRef, BasicBlockRef};
+use lib;
+use lib::llvm::{llvm, ValueRef, BasicBlockRef};
use middle::const_eval;
+use middle::borrowck::root_map_key;
use middle::pat_util::*;
use middle::resolve::DefMap;
use middle::trans::base::*;
@@ -156,20 +157,26 @@ use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::controlflow;
+use middle::trans::datum;
use middle::trans::datum::*;
use middle::trans::expr::Dest;
use middle::trans::expr;
use middle::trans::glue;
+use middle::trans::tvec;
+use middle::trans::type_of;
+use middle::ty;
use util::common::indenter;
use core::dvec::DVec;
use core::dvec;
+use core::libc::c_ulonglong;
use std::oldmap::HashMap;
use syntax::ast::def_id;
use syntax::ast;
-use syntax::ast_util::{dummy_sp, path_to_ident};
+use syntax::ast::ident;
+use syntax::ast_util::path_to_ident;
use syntax::ast_util;
-use syntax::codemap::span;
+use syntax::codemap::{span, dummy_sp};
use syntax::print::pprust::pat_to_str;
// An option identifying a literal: either a unit-like struct or an
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 54d2af5ccce..d1472f63ae7 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -44,6 +44,7 @@ use middle::borrowck::RootInfo;
use middle::pat_util::*;
use middle::resolve;
use middle::trans::_match;
+use middle::trans::base;
use middle::trans::build::*;
use middle::trans::callee;
use middle::trans::common::*;
@@ -56,12 +57,15 @@ use middle::trans::foreign;
use middle::trans::glue;
use middle::trans::inline;
use middle::trans::machine;
+use middle::trans::machine::llsize_of;
use middle::trans::meth;
use middle::trans::monomorphize;
use middle::trans::reachable;
use middle::trans::shape::*;
use middle::trans::tvec;
+use middle::trans::type_of;
use middle::trans::type_of::*;
+use middle::ty;
use middle::ty::arg;
use util::common::indenter;
use util::ppaux::{ty_to_str, ty_to_short_str};
@@ -77,6 +81,7 @@ use core::option;
use core::uint;
use std::oldmap::HashMap;
use std::{oldmap, time, list};
+use syntax::ast::ident;
use syntax::ast_map::{path, path_elt_to_str, path_mod, path_name};
use syntax::ast_util::{def_id_of_def, local_def, path_to_ident};
use syntax::attr;
diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs
index 85e8be09878..7ac54518d37 100644
--- a/src/librustc/middle/trans/build.rs
+++ b/src/librustc/middle/trans/build.rs
@@ -10,6 +10,7 @@
use codemap::span;
+use lib;
use lib::llvm::llvm;
use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering};
use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False};
@@ -18,9 +19,12 @@ use libc::{c_uint, c_int, c_ulonglong};
use middle::trans::common::*;
use middle::trans::machine::llsize_of_real;
+use core::prelude::*;
use core::cast::transmute;
use core::cast;
use core::libc;
+use core::option::Some;
+use core::ptr;
use core::str;
use core::vec;
use std::oldmap::HashMap;
diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs
index bc48519ffda..bbc19cf86ea 100644
--- a/src/librustc/middle/trans/cabi.rs
+++ b/src/librustc/middle/trans/cabi.rs
@@ -13,6 +13,10 @@ use middle::trans::base::*;
use middle::trans::build::*;
use middle::trans::common::*;
+use core::libc::c_uint;
+use core::option;
+use core::vec;
+
pub trait ABIInfo {
fn compute_info(&self,
atys: &[TypeRef],
@@ -28,7 +32,7 @@ pub struct LLVMType {
pub struct FnType {
arg_tys: ~[LLVMType],
ret_ty: LLVMType,
- attrs: ~[Option],
+ attrs: ~[option::Option],
sret: bool
}
@@ -93,7 +97,7 @@ pub impl FnType {
llargbundle: ValueRef, llretval: ValueRef) {
for vec::eachi(self.attrs) |i, a| {
match *a {
- Some(attr) => {
+ option::Some(attr) => {
unsafe {
llvm::LLVMAddInstrAttribute(
llretval, (i + 1u) as c_uint,
@@ -205,8 +209,8 @@ impl ABIInfo for LLVM_ABIInfo {
}
}
-pub fn llvm_abi_info() -> ABIInfo {
- return LLVM_ABIInfo as ABIInfo;
+pub fn llvm_abi_info() -> @ABIInfo {
+ return @LLVM_ABIInfo as @ABIInfo;
}
diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs
index 259392bef40..a16b3672b7a 100644
--- a/src/librustc/middle/trans/cabi_arm.rs
+++ b/src/librustc/middle/trans/cabi_arm.rs
@@ -159,6 +159,6 @@ impl ABIInfo for ARM_ABIInfo {
}
}
-pub fn abi_info() -> ABIInfo {
- return ARM_ABIInfo as ABIInfo;
+pub fn abi_info() -> @ABIInfo {
+ return @ARM_ABIInfo as @ABIInfo;
}
diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs
index df0f11eedae..562009dc2ca 100644
--- a/src/librustc/middle/trans/cabi_x86_64.rs
+++ b/src/librustc/middle/trans/cabi_x86_64.rs
@@ -18,6 +18,14 @@ use lib::llvm::struct_tys;
use middle::trans::common::*;
use middle::trans::cabi::*;
+use core::cmp;
+use core::libc::c_uint;
+use core::option;
+use core::option::Option;
+use core::ptr;
+use core::uint;
+use core::vec;
+
enum x86_64_reg_class {
no_class,
integer_class,
@@ -400,5 +408,5 @@ impl ABIInfo for X86_64_ABIInfo {
}
pub fn x86_64_abi_info() -> ABIInfo {
- return X86_64_ABIInfo as ABIInfo;
+ return @X86_64_ABIInfo as @ABIInfo;
}
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index f72390f7271..3a68e8e94c6 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -18,21 +18,33 @@
use core::prelude::*;
-use lib::llvm::ValueRef;
-use middle::trans::base::{get_item_val, trans_external_path};
+use back::abi;
+use driver::session;
+use lib;
+use lib::llvm::{ValueRef, TypeRef};
+use lib::llvm::llvm;
+use metadata::csearch;
+use middle::trans::base;
+use middle::trans::base::*;
use middle::trans::build::*;
use middle::trans::callee;
use middle::trans::closure;
-use middle::trans::common::{block, node_id_type_params};
+use middle::trans::common;
+use middle::trans::common::*;
use middle::trans::datum::*;
use middle::trans::datum::Datum;
+use middle::trans::expr;
+use middle::trans::glue;
use middle::trans::inline;
use middle::trans::meth;
use middle::trans::monomorphize;
+use middle::trans::type_of;
+use middle::ty;
use middle::typeck;
use util::common::indenter;
use syntax::ast;
+use syntax::ast_map;
use syntax::print::pprust::{expr_to_str, stmt_to_str, path_to_str};
use syntax::visit;
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index 40407fbf52b..949318d1723 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -13,8 +13,7 @@ use core::prelude::*;
use back::abi;
use back::link::{mangle_internal_name_by_path_and_seq};
use back::link::{mangle_internal_name_by_path};
-use lib::llvm::llvm;
-use lib::llvm::{ValueRef, TypeRef};
+use lib::llvm::{llvm, ValueRef, TypeRef};
use middle::moves;
use middle::trans::base::*;
use middle::trans::build::*;
@@ -25,6 +24,7 @@ use middle::trans::expr;
use middle::trans::glue;
use middle::trans::machine;
use middle::trans::type_of::*;
+use middle::ty;
use util::ppaux::ty_to_str;
use core::libc::c_uint;
@@ -33,6 +33,7 @@ use syntax::ast;
use syntax::ast_map::{path, path_mod, path_name};
use syntax::ast_util;
use syntax::codemap::span;
+use syntax::parse::token::special_idents;
use syntax::print::pprust::expr_to_str;
// ___Good to know (tm)__________________________________________________
@@ -185,7 +186,7 @@ pub fn allocate_cbox(bcx: block, sigil: ast::Sigil, cdata_ty: ty::t)
}
ast::BorrowedSigil => {
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
- let llbox = base::alloc_ty(bcx, cbox_ty);
+ let llbox = alloc_ty(bcx, cbox_ty);
nuke_ref_count(bcx, llbox);
rslt(bcx, llbox)
}
@@ -342,7 +343,7 @@ pub fn load_environment(fcx: fn_ctxt,
let bcx = raw_block(fcx, false, llloadenv);
// Load a pointer to the closure data, skipping over the box header:
- let llcdata = base::opaque_box_body(bcx, cdata_ty, fcx.llenv);
+ let llcdata = opaque_box_body(bcx, cdata_ty, fcx.llenv);
// Populate the upvars from the environment.
let mut i = 0u;
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index 566b2689f2e..97f8ec84a1d 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -157,7 +157,7 @@ pub fn BuilderRef_res(B: BuilderRef) -> BuilderRef_res {
}
}
-type ExternMap = HashMap<@str, ValueRef>;
+pub type ExternMap = HashMap<@str, ValueRef>;
// Crate context. Every crate we compile has one of these.
pub struct CrateContext {
@@ -553,10 +553,7 @@ impl get_node_info for ast::blk {
}
}
-// XXX: Work around a trait parsing bug. remove after snapshot
-pub type optional_boxed_ast_expr = Option<@ast::expr>;
-
-impl get_node_info for optional_boxed_ast_expr {
+impl get_node_info for Option<@ast::expr> {
fn info(&self) -> Option {
self.chain_ref(|s| s.info())
}
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index ab85da304cb..36cda3dfbe9 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -10,14 +10,18 @@
use core::prelude::*;
+use lib::llvm::{llvm, ValueRef, True, TypeRef, False};
use middle::const_eval;
+use middle::trans::base;
use middle::trans::base::get_insn_ctxt;
use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::expr;
use middle::trans::machine;
+use middle::trans::type_of;
use middle::ty;
+use core::libc::c_uint;
use syntax::{ast, ast_util, codemap, ast_map};
pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit)
diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs
index 70321d50f3f..9b282e71b3e 100644
--- a/src/librustc/middle/trans/controlflow.rs
+++ b/src/librustc/middle/trans/controlflow.rs
@@ -10,13 +10,28 @@
use core::prelude::*;
-use lib::llvm::ValueRef;
+use back::link;
+use lib;
+use lib::llvm::*;
use middle::trans::base::*;
+use middle::trans::build::*;
use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::datum::*;
+use middle::trans::debuginfo;
+use middle::trans::expr;
+use middle::trans::type_of::*;
+use middle::ty;
+use util::common::indenter;
+use util::ppaux;
use core::str;
+use syntax::ast;
+use syntax::ast::ident;
+use syntax::ast_map::path_mod;
+use syntax::ast_util;
+use syntax::codemap::span;
+use syntax::print::pprust::expr_to_str;
pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
let _icx = bcx.insn_ctxt("trans_block");
diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs
index c93ab056de0..94c90aaad6d 100644
--- a/src/librustc/middle/trans/datum.rs
+++ b/src/librustc/middle/trans/datum.rs
@@ -87,21 +87,29 @@
use core::prelude::*;
+use lib;
use lib::llvm::ValueRef;
use middle::borrowck::{RootInfo, root_map_key};
use middle::trans::base::*;
use middle::trans::build::*;
+use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::common;
+use middle::trans::expr;
+use middle::trans::glue;
use middle::trans::tvec;
+use middle::trans::type_of;
+use middle::ty;
use middle::typeck;
use util::common::indenter;
use util::ppaux::ty_to_str;
use core::cmp;
use core::option;
+use core::to_bytes;
use core::uint;
use core::vec;
+use syntax::ast;
use syntax::parse::token::special_idents;
#[deriving_eq]
@@ -326,7 +334,7 @@ pub impl Datum {
Store(bcx, self.val, dst);
}
ByRef => {
- base::memcpy_ty(bcx, dst, self.val, self.ty);
+ memcpy_ty(bcx, dst, self.val, self.ty);
}
}
@@ -354,7 +362,7 @@ pub impl Datum {
match self.mode {
ByRef => {
- base::memcpy_ty(bcx, dst, self.val, self.ty);
+ memcpy_ty(bcx, dst, self.val, self.ty);
}
ByValue => {
Store(bcx, self.val, dst);
@@ -540,7 +548,7 @@ pub impl Datum {
let scratch = scratch_datum(bcx, self.ty, true);
self.copy_to_datum(bcx, INIT, scratch);
- base::add_root_cleanup(bcx, root_info, scratch.val, scratch.ty);
+ add_root_cleanup(bcx, root_info, scratch.val, scratch.ty);
// If we need to freeze the box, do that now.
if root_info.freezes {
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs
index 6226e83d046..c6ed190c7c3 100644
--- a/src/librustc/middle/trans/expr.rs
+++ b/src/librustc/middle/trans/expr.rs
@@ -121,10 +121,15 @@ lvalues are *never* stored by value.
use core::prelude::*;
-use lib::llvm::ValueRef;
+use back::abi;
+use lib;
+use lib::llvm::{ValueRef, TypeRef, llvm, True};
use middle::borrowck::root_map_key;
use middle::resolve;
+use middle::trans::_match;
+use middle::trans::base;
use middle::trans::base::*;
+use middle::trans::build::*;
use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
use middle::trans::callee;
use middle::trans::closure;
@@ -132,16 +137,21 @@ use middle::trans::common::*;
use middle::trans::consts;
use middle::trans::controlflow;
use middle::trans::datum::*;
+use middle::trans::debuginfo;
use middle::trans::machine;
use middle::trans::meth;
use middle::trans::tvec;
+use middle::trans::type_of;
+use middle::ty;
use middle::ty::struct_mutable_fields;
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn};
use util::common::indenter;
use util::ppaux::ty_to_str;
+use std::oldmap::HashMap;
use syntax::print::pprust::{expr_to_str};
use syntax::ast;
+use syntax::codemap;
use syntax::codemap::spanned;
// Destinations
@@ -154,7 +164,7 @@ pub enum Dest {
Ignore,
}
-impl Dest {
+pub impl Dest {
fn to_str(&self, ccx: @CrateContext) -> ~str {
match *self {
SaveIn(v) => fmt!("SaveIn(%s)", val_str(ccx.tn, v)),
@@ -1128,7 +1138,7 @@ fn trans_rec_or_struct(bcx: block,
let fields = ty::struct_mutable_fields(
tcx, variant_id, substs);
let field_lltys = do fields.map |field| {
- type_of(bcx.ccx(),
+ type_of::type_of(bcx.ccx(),
ty::subst_tps(
tcx, substs.tps, None, field.mt.ty))
};
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index ef0d61d49de..6c0c73dd016 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -11,6 +11,7 @@
use core::prelude::*;
use back::{link, abi};
+use driver::session;
use driver::session::arch_x86_64;
use driver::session::arch_arm;
use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg};
@@ -27,11 +28,13 @@ use middle::trans::callee::*;
use middle::trans::common::*;
use middle::trans::datum::*;
use middle::trans::expr::{Dest, Ignore};
+use middle::trans::machine::llsize_of;
use middle::trans::glue;
use middle::trans::machine;
use middle::trans::shape;
use middle::trans::type_of::*;
use middle::trans::type_of;
+use middle::ty;
use middle::ty::{FnSig, arg};
use util::ppaux::ty_to_str;
diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs
index bcb22022d46..96deb2906eb 100644
--- a/src/librustc/middle/trans/glue.rs
+++ b/src/librustc/middle/trans/glue.rs
@@ -14,19 +14,32 @@
use core::prelude::*;
-use lib::llvm::{ValueRef, TypeRef};
+use back::abi;
+use back::link::*;
+use driver::session;
+use lib;
+use lib::llvm::{llvm, ValueRef, TypeRef, True};
use middle::trans::base::*;
use middle::trans::callee;
use middle::trans::closure;
use middle::trans::common::*;
use middle::trans::build::*;
+use middle::trans::expr;
+use middle::trans::machine::*;
use middle::trans::reflect;
use middle::trans::tvec;
-use middle::trans::type_of::type_of;
+use middle::trans::type_of::{type_of, type_of_glue_fn};
use middle::trans::uniq;
+use middle::ty;
+use util::ppaux;
+use util::ppaux::ty_to_short_str;
use core::io;
+use core::libc::c_uint;
use core::str;
+use std::time;
+use syntax::ast;
+use syntax::parse::token::special_idents;
pub fn trans_free(cx: block, v: ValueRef) -> block {
let _icx = cx.insn_ctxt("trans_free");
@@ -218,7 +231,7 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext,
let _icx = ccx.insn_ctxt("lazily_emit_simplified_tydesc_glue");
let simpl = simplified_glue_type(ccx.tcx, field, ti.ty);
if simpl != ti.ty {
- let simpl_ti = base::get_tydesc(ccx, simpl);
+ let simpl_ti = get_tydesc(ccx, simpl);
lazily_emit_tydesc_glue(ccx, field, simpl_ti);
if field == abi::tydesc_field_take_glue {
ti.take_glue =
@@ -661,7 +674,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
if ccx.sess.count_type_sizes() {
io::println(fmt!("%u\t%s",
llsize_of_real(ccx, llty),
- ty_to_str(ccx.tcx, t)));
+ ppaux::ty_to_str(ccx.tcx, t)));
}
let llsize = llsize_of(ccx, llty);
@@ -675,7 +688,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
};
// XXX: Bad copy.
note_unique_llvm_symbol(ccx, copy name);
- log(debug, fmt!("+++ declare_tydesc %s %s", ty_to_str(ccx.tcx, t), name));
+ debug!("+++ declare_tydesc %s %s", ppaux::ty_to_str(ccx.tcx, t), name);
let gvar = str::as_c_str(name, |buf| {
unsafe {
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
@@ -709,7 +722,7 @@ pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
} else {
fn_nm = mangle_internal_name_by_seq(ccx, (~"glue_" + name));
}
- debug!("%s is for type %s", fn_nm, ty_to_str(ccx.tcx, t));
+ debug!("%s is for type %s", fn_nm, ppaux::ty_to_str(ccx.tcx, t));
// XXX: Bad copy.
note_unique_llvm_symbol(ccx, copy fn_nm);
let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty);
diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs
index b352b078a47..7ce36c2b1e2 100644
--- a/src/librustc/middle/trans/inline.rs
+++ b/src/librustc/middle/trans/inline.rs
@@ -10,6 +10,7 @@
use core::prelude::*;
+use metadata::csearch;
use middle::astencode;
use middle::trans::base::{get_insn_ctxt};
use middle::trans::base::{impl_owned_self, impl_self, no_self};
@@ -18,6 +19,8 @@ use middle::trans::common::*;
use middle::trans::common;
use middle::trans::inline;
use middle::trans::monomorphize;
+use middle::ty;
+use util::ppaux::ty_to_str;
use core::vec;
use syntax::ast;
diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs
index bfada859bc2..8d447f54c20 100644
--- a/src/librustc/middle/trans/machine.rs
+++ b/src/librustc/middle/trans/machine.rs
@@ -11,6 +11,9 @@
// Information concerning the machine representation of various types.
+use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef, BuilderRef};
+use lib::llvm::{True, False, Bool};
+use lib::llvm::llvm;
use middle::trans::common::*;
use middle::trans::type_of;
use middle::ty;
@@ -122,7 +125,7 @@ pub fn llalign_of_min(cx: @CrateContext, t: TypeRef) -> uint {
pub fn llalign_of(cx: @CrateContext, t: TypeRef) -> ValueRef {
unsafe {
return llvm::LLVMConstIntCast(
- lib::llvm::llvm::LLVMAlignOf(t), cx.int_type, False);
+ llvm::LLVMAlignOf(t), cx.int_type, False);
}
}
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index d836bcb9df9..d2bf034165d 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -28,14 +28,16 @@ use middle::trans::glue;
use middle::trans::inline;
use middle::trans::monomorphize;
use middle::trans::type_of::*;
+use middle::ty;
use middle::ty::arg;
use middle::typeck;
+use util::common::indenter;
use util::ppaux::{ty_to_str, tys_to_str};
use core::libc::c_uint;
use std::oldmap::HashMap;
use syntax::ast_map::{path, path_mod, path_name, node_id_to_str};
-use syntax::ast_util::local_def;
+use syntax::ast_util;
use syntax::print::pprust::expr_to_str;
use syntax::{ast, ast_map};
@@ -351,7 +353,7 @@ pub fn trans_static_method_callee(bcx: block,
pub fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
-> Option {
- ms.find(|m| m.ident == name).map(|m| local_def(m.id))
+ ms.find(|m| m.ident == name).map(|m| ast_util::local_def(m.id))
}
pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
@@ -725,7 +727,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
// Load the function from the vtable and cast it to the expected type.
debug!("(translating trait callee) loading method");
- let llcallee_ty = type_of::type_of_fn_from_ty(ccx, callee_ty);
+ let llcallee_ty = type_of_fn_from_ty(ccx, callee_ty);
let mptr = Load(bcx, GEPi(bcx, llvtable, [0u, n_method]));
let mptr = PointerCast(bcx, mptr, T_ptr(llcallee_ty));
@@ -868,27 +870,11 @@ pub fn trans_trait_cast(bcx: block,
match vstore {
ty::vstore_slice(*) | ty::vstore_box => {
let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]);
- if bcx.tcx().legacy_boxed_traits.contains_key(&id) {
- // Allocate an @ box and store the value into it
- let MallocResult {bcx: new_bcx, box: llbox, body: body} =
- malloc_boxed(bcx, v_ty);
- bcx = new_bcx;
- add_clean_free(bcx, llbox, heap_managed);
- bcx = expr::trans_into(bcx, val, SaveIn(body));
- revoke_clean(bcx, llbox);
-
- // Store the @ box into the pair
- Store(bcx, llbox, PointerCast(bcx,
- llboxdest,
- T_ptr(val_ty(llbox))));
- } else {
- // Just store the pointer into the pair.
- llboxdest = PointerCast(bcx,
- llboxdest,
- T_ptr(type_of::type_of(bcx.ccx(),
- v_ty)));
- bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
- }
+ // Just store the pointer into the pair.
+ llboxdest = PointerCast(bcx,
+ llboxdest,
+ T_ptr(type_of(bcx.ccx(), v_ty)));
+ bcx = expr::trans_into(bcx, val, SaveIn(llboxdest));
}
ty::vstore_uniq => {
// Translate the uniquely-owned value into the second element of
@@ -896,7 +882,7 @@ pub fn trans_trait_cast(bcx: block,
let mut llvaldest = GEPi(bcx, lldest, [0, 1]);
llvaldest = PointerCast(bcx,
llvaldest,
- T_ptr(type_of::type_of(bcx.ccx(), v_ty)));
+ T_ptr(type_of(bcx.ccx(), v_ty)));
bcx = expr::trans_into(bcx, val, SaveIn(llvaldest));
// Get the type descriptor of the wrapped value and store it into
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 9be316b3022..30a42210a13 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -11,6 +11,8 @@
use core::prelude::*;
use back::link::mangle_exported_name;
+use driver::session;
+use lib::llvm::ValueRef;
use middle::trans::base::{get_insn_ctxt};
use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint};
use middle::trans::base::{trans_enum_variant, trans_struct_dtor};
@@ -26,12 +28,15 @@ use middle::trans::shape;
use middle::trans::type_of::type_of_fn_from_ty;
use middle::trans::type_of;
use middle::trans::type_use;
+use middle::ty;
use middle::ty::{FnSig};
use middle::typeck;
+use util::ppaux::ty_to_str;
use core::option;
use core::vec;
use syntax::ast;
+use syntax::ast_map;
use syntax::ast_map::{path, path_mod, path_name};
use syntax::ast_util::local_def;
use syntax::parse::token::special_idents;
diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs
index d93886dbb3e..17abebad600 100644
--- a/src/librustc/middle/trans/reachable.rs
+++ b/src/librustc/middle/trans/reachable.rs
@@ -21,11 +21,13 @@ use middle::resolve;
use middle::ty;
use middle::typeck;
-use core::vec;
+use core::prelude::*;
use std::oldmap::HashMap;
+use syntax::ast;
use syntax::ast::*;
use syntax::ast_util::def_id_of_def;
use syntax::attr;
+use syntax::codemap;
use syntax::print::pprust::expr_to_str;
use syntax::{visit, ast_util, ast_map};
diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs
index 1fa97325313..dcfa897ab60 100644
--- a/src/librustc/middle/trans/reflect.rs
+++ b/src/librustc/middle/trans/reflect.rs
@@ -22,8 +22,11 @@ use middle::trans::glue;
use middle::trans::machine;
use middle::trans::meth;
use middle::trans::type_of::*;
+use middle::ty;
use util::ppaux::ty_to_str;
+use core::option::None;
+use core::vec;
use std::oldmap::HashMap;
use syntax::ast::def_id;
use syntax::ast;
@@ -60,7 +63,7 @@ pub impl Reflector {
}
fn c_size_and_align(&mut self, t: ty::t) -> ~[ValueRef] {
- let tr = type_of::type_of(self.bcx.ccx(), t);
+ let tr = type_of(self.bcx.ccx(), t);
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
let a = machine::llalign_of_min(self.bcx.ccx(), tr);
return ~[self.c_uint(s),
@@ -351,7 +354,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block,
let final = sub_block(bcx, ~"final");
assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc);
let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc);
- let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty);
+ let tydesc_ty = type_of(bcx.ccx(), tydesc_ty);
let mut r = Reflector {
visitor_val: visitor_val,
visitor_methods: ty::trait_methods(bcx.tcx(), visitor_trait_id),
diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs
index 72e2369111d..72e4fa2f4eb 100644
--- a/src/librustc/middle/trans/shape.rs
+++ b/src/librustc/middle/trans/shape.rs
@@ -25,6 +25,7 @@ use util::ppaux::ty_to_str;
use core::dvec::DVec;
use core::option::is_some;
+use core::str;
use core::vec;
use std::oldmap::HashMap;
use syntax::ast;
diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs
index dc004c81b11..4ce60daf60f 100644
--- a/src/librustc/middle/trans/tvec.rs
+++ b/src/librustc/middle/trans/tvec.rs
@@ -10,20 +10,27 @@
use back::abi;
-use lib::llvm::{ValueRef, TypeRef};
+use lib;
+use lib::llvm::{llvm, ValueRef, TypeRef};
+use middle::trans::base;
+use middle::trans::base::*;
use middle::trans::build::*;
+use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::datum::*;
use middle::trans::expr::{Dest, Ignore, SaveIn};
use middle::trans::expr;
use middle::trans::glue;
-use middle::trans::shape::{llsize_of, nonzero_llsize_of};
+use middle::trans::machine::{llsize_of, nonzero_llsize_of};
use middle::trans::type_of;
use middle::ty;
use util::common::indenter;
use util::ppaux::ty_to_str;
+use core::uint;
+use core::vec;
use syntax::ast;
+use syntax::codemap;
use syntax::codemap::span;
use syntax::print::pprust::{expr_to_str};
@@ -81,7 +88,7 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t,
let vecbodyty = ty::mk_mut_unboxed_vec(bcx.tcx(), unit_ty);
let vecsize = Add(bcx, alloc, llsize_of(ccx, ccx.opaque_vec_type));
- let MallocResult {bcx, box: bx, body} =
+ let base::MallocResult {bcx, box: bx, body} =
base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize);
Store(bcx, fill, GEPi(bcx, body, [0u, abi::vec_elt_fill]));
Store(bcx, alloc, GEPi(bcx, body, [0u, abi::vec_elt_alloc]));
@@ -91,7 +98,7 @@ pub fn alloc_raw(bcx: block, unit_ty: ty::t,
pub fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef) -> Result {
- alloc_raw(bcx, unit_ty, fill, alloc, heap_for_unique(bcx, unit_ty))
+ alloc_raw(bcx, unit_ty, fill, alloc, base::heap_for_unique(bcx, unit_ty))
}
pub fn alloc_vec(bcx: block,
@@ -305,13 +312,13 @@ pub fn trans_uniq_or_managed_vstore(bcx: block,
let llptrval = PointerCast(bcx, llptrval, T_ptr(T_i8()));
let llsizeval = C_uint(bcx.ccx(), s.len());
let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq);
- let lldestval = datum::scratch_datum(bcx, typ, false);
+ let lldestval = scratch_datum(bcx, typ, false);
let bcx = callee::trans_lang_call(
bcx,
bcx.tcx().lang_items.strdup_uniq_fn(),
~[ llptrval, llsizeval ],
expr::SaveIn(lldestval.to_ref_llval(bcx)));
- return datum::DatumBlock {
+ return DatumBlock {
bcx: bcx,
datum: lldestval
};
@@ -508,8 +515,8 @@ pub fn get_base_and_len(bcx: block,
(base, len)
}
ty::vstore_uniq | ty::vstore_box => {
- let body = tvec::get_bodyptr(bcx, llval);
- (tvec::get_dataptr(bcx, body), tvec::get_fill(bcx, body))
+ let body = get_bodyptr(bcx, llval);
+ (get_dataptr(bcx, body), get_fill(bcx, body))
}
}
}
diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs
index 8275db8cdb2..7d3aa4c24f4 100644
--- a/src/librustc/middle/trans/type_of.rs
+++ b/src/librustc/middle/trans/type_of.rs
@@ -11,12 +11,16 @@
use lib::llvm::llvm;
use lib::llvm::{TypeRef};
+use middle::trans::base;
use middle::trans::common::*;
use middle::trans::common;
use middle::trans::expr;
use middle::trans::machine;
+use middle::ty;
use util::ppaux;
+use core::option::None;
+use core::vec;
use std::oldmap::HashMap;
use syntax::ast;
@@ -387,7 +391,7 @@ pub fn type_of_dtor(ccx: @CrateContext, self_ty: ty::t) -> TypeRef {
pub fn type_of_rooted(ccx: @CrateContext, t: ty::t) -> TypeRef {
let addrspace = base::get_tydesc(ccx, t).addrspace;
debug!("type_of_rooted %s in addrspace %u",
- ty_to_str(ccx.tcx, t), addrspace as uint);
+ ppaux::ty_to_str(ccx.tcx, t), addrspace as uint);
return T_root(type_of(ccx, t), addrspace);
}
diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs
index 627042a6516..ff92f265cc0 100644
--- a/src/librustc/middle/trans/type_use.rs
+++ b/src/librustc/middle/trans/type_use.rs
@@ -32,13 +32,17 @@ use metadata::csearch;
use middle::freevars;
use middle::trans::common::*;
use middle::trans::inline;
+use middle::ty;
+use middle::typeck;
use core::option;
+use core::option::{Some, None, Option};
use core::uint;
use core::vec;
use std::list::{List, Cons, Nil};
use std::list;
use std::oldmap::HashMap;
+use syntax::ast;
use syntax::ast::*;
use syntax::ast_map;
use syntax::ast_util;
diff --git a/src/librustc/middle/trans/uniq.rs b/src/librustc/middle/trans/uniq.rs
index aa02cc4bf5d..7db76258404 100644
--- a/src/librustc/middle/trans/uniq.rs
+++ b/src/librustc/middle/trans/uniq.rs
@@ -17,6 +17,7 @@ use middle::trans::common::*;
use middle::trans::datum::immediate_rvalue;
use middle::trans::datum;
use middle::trans::glue;
+use middle::ty;
use syntax::ast;
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index c34e8dae21f..90f97a939ad 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -269,7 +269,6 @@ struct ctxt_ {
adjustments: HashMap,
normalized_cache: HashMap,
lang_items: middle::lang_items::LanguageItems,
- legacy_boxed_traits: HashMap,
// A mapping from an implementation ID to the method info and trait
// method ID of the provided (a.k.a. default) methods in the traits that
// that implementation implements.
@@ -831,7 +830,6 @@ pub fn mk_ctxt(s: session::Session,
adjustments: HashMap(),
normalized_cache: new_ty_hash(),
lang_items: lang_items,
- legacy_boxed_traits: HashMap(),
provided_methods: HashMap(),
provided_method_sources: HashMap(),
supertraits: HashMap(),
@@ -3714,7 +3712,7 @@ pub enum DtorKind {
TraitDtor(def_id)
}
-impl DtorKind {
+pub impl DtorKind {
pure fn is_not_present(&const self) -> bool {
match *self {
NoDtor => true,
diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs
index c8cd7c05fe8..2dbf74e1666 100644
--- a/src/librustc/middle/typeck/check/vtable.rs
+++ b/src/librustc/middle/typeck/check/vtable.rs
@@ -97,8 +97,8 @@ pub fn lookup_vtables(vcx: &VtableContext,
let mut result = ~[], i = 0u;
for substs.tps.each |ty| {
for ty::iter_bound_traits_and_supertraits(
- tcx, bounds[i]) |trait_ty| {
-
+ tcx, bounds[i]) |trait_ty|
+ {
debug!("about to subst: %?, %?",
ppaux::ty_to_str(tcx, trait_ty),
ty::substs_to_str(tcx, substs));
@@ -585,138 +585,102 @@ pub fn early_resolve_expr(ex: @ast::expr,
}
}
ast::expr_cast(src, _) => {
- let target_ty = fcx.expr_ty(ex);
- match ty::get(target_ty).sty {
- ty::ty_trait(_, _, vstore) => {
- // Look up vtables for the type we're casting to, passing in the
- // source and target type.
- //
- // XXX: This is invariant and shouldn't be. --pcw
+ let target_ty = fcx.expr_ty(ex);
+ match ty::get(target_ty).sty {
+ ty::ty_trait(_, _, vstore) => {
+ // Look up vtables for the type we're casting to,
+ // passing in the source and target type. The source
+ // must be a pointer type suitable to the object sigil,
+ // e.g.: `@x as @Trait`, `&x as &Trait` or `~x as ~Trait`
+ let ty = structurally_resolved_type(fcx, ex.span,
+ fcx.expr_ty(src));
+ match (&ty::get(ty).sty, vstore) {
+ (&ty::ty_box(mt), ty::vstore_box) |
+ (&ty::ty_uniq(mt), ty::vstore_uniq) |
+ (&ty::ty_rptr(_, mt), ty::vstore_slice(*)) => {
+ let location_info =
+ &location_info_for_expr(ex);
+ let vcx = VtableContext {
+ ccx: fcx.ccx,
+ infcx: fcx.infcx()
+ };
+ let vtable_opt =
+ lookup_vtable(&vcx,
+ location_info,
+ mt.ty,
+ target_ty,
+ true,
+ is_early);
+ match vtable_opt {
+ Some(vtable) => {
+ // Map this expression to that
+ // vtable (that is: "ex has vtable
+ // ")
+ if !is_early {
+ let vtable_map =
+ cx.vtable_map;
+ vtable_map.insert(ex.id,
+ @~[vtable]);
+ }
+ }
+ None => {
+ fcx.tcx().sess.span_err(
+ ex.span,
+ fmt!("failed to find an implementation \
+ of trait %s for %s",
+ fcx.infcx().ty_to_str(target_ty),
+ fcx.infcx().ty_to_str(mt.ty)));
+ }
+ }
- let ty = fcx.expr_ty(src);
- let vcx = VtableContext { ccx: fcx.ccx, infcx: fcx.infcx() };
- let vtable_opt =
- lookup_vtable(&vcx,
- &location_info_for_expr(ex),
- ty,
- target_ty,
- true,
- is_early);
- match vtable_opt {
- None => {
- // Try the new-style boxed trait; "@int as @Trait".
- // Or the new-style region trait; "&int as &Trait".
- // Or the new-style uniquely-owned trait; "~int as
- // ~Trait".
- let mut err = false;
- let ty = structurally_resolved_type(fcx, ex.span, ty);
- match ty::get(ty).sty {
- ty::ty_box(mt) | ty::ty_rptr(_, mt) |
- ty::ty_uniq(mt) => {
- // Ensure that the trait vstore and the pointer
- // type match.
- match (&ty::get(ty).sty, vstore) {
- (&ty::ty_box(_), ty::vstore_box) |
- (&ty::ty_uniq(_), ty::vstore_uniq) |
- (&ty::ty_rptr(*), ty::vstore_slice(*)) => {
- let location_info =
- &location_info_for_expr(ex);
- let vtable_opt =
- lookup_vtable(&vcx,
- location_info,
- mt.ty,
- target_ty,
- true,
- is_early);
- match vtable_opt {
- Some(vtable) => {
- // Map this expression to that
- // vtable (that is: "ex has vtable
- // ")
- if !is_early {
- let vtable_map =
- cx.vtable_map;
- vtable_map.insert(ex.id,
- @~[vtable]);
- }
- }
- None => err = true
- }
+ // Now, if this is &trait, we need to link the
+ // regions.
+ match (&ty::get(ty).sty, vstore) {
+ (&ty::ty_rptr(ra, _),
+ ty::vstore_slice(rb)) => {
+ infer::mk_subr(fcx.infcx(),
+ false,
+ ex.span,
+ rb,
+ ra);
+ }
+ _ => {}
+ }
+ }
- // Now, if this is &trait, we need to link
- // the regions.
- match (&ty::get(ty).sty, vstore) {
- (&ty::ty_rptr(ra, _),
- ty::vstore_slice(rb)) => {
- infer::mk_subr(fcx.infcx(),
- false,
- ex.span,
- rb,
- ra);
- }
- _ => {}
- }
- }
- (&ty::ty_box(_), _) => {
- fcx.ccx.tcx.sess.span_err(ex.span,
- ~"must cast \
- a boxed \
- pointer to \
- a boxed
- trait");
- err = true;
- }
- (&ty::ty_rptr(*), _) => {
- fcx.ccx.tcx.sess.span_err(ex.span,
- ~"must cast \
- a borrowed \
- pointer to \
- a borrowed \
- trait");
- }
- (&ty::ty_uniq(*), _) => {
- fcx.ccx.tcx.sess.span_err(ex.span,
- ~"must cast \
- a unique \
- pointer to \
- a uniquely-\
- owned trait");
- }
- _ => {
- fcx.ccx.tcx.sess.impossible_case(
- ex.span,
- ~"impossible combination of type and \
- trait vstore");
- }
- }
- }
- _ => err = true
- }
+ (_, ty::vstore_box(*)) => {
+ fcx.ccx.tcx.sess.span_err(
+ ex.span,
+ fmt!("can only cast an @-pointer \
+ to an @-object, not a %s",
+ ty::ty_sort_str(fcx.tcx(), ty)));
+ }
- if err {
- fcx.tcx().sess.span_fatal(
- ex.span,
- fmt!("failed to find an implementation of trait \
- %s for %s",
- fcx.infcx().ty_to_str(target_ty),
- fcx.infcx().ty_to_str(ty)));
- }
- }
- Some(vtable) => {
- /*
- Map this expression to that vtable (that is: "ex has
- vtable ")
- */
- if !is_early {
- let vtable_map = cx.vtable_map;
- vtable_map.insert(ex.id, @~[vtable]);
- }
- fcx.tcx().legacy_boxed_traits.insert(ex.id, ());
- }
- }
+ (_, ty::vstore_uniq(*)) => {
+ fcx.ccx.tcx.sess.span_err(
+ ex.span,
+ fmt!("can only cast an ~-pointer \
+ to a ~-object, not a %s",
+ ty::ty_sort_str(fcx.tcx(), ty)));
+ }
+
+ (_, ty::vstore_slice(*)) => {
+ fcx.ccx.tcx.sess.span_err(
+ ex.span,
+ fmt!("can only cast an &-pointer \
+ to an &-object, not a %s",
+ ty::ty_sort_str(fcx.tcx(), ty)));
+ }
+
+ (_, ty::vstore_fixed(*)) => {
+ fcx.tcx().sess.span_bug(
+ ex.span,
+ fmt!("trait with fixed vstore"));
+ }
+ }
+ }
+ _ => { /* not a cast to a trait; ignore */ }
}
- _ => ()
- }
}
_ => ()
}
diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs
index 5d291fdde77..6ad58bc5d4f 100644
--- a/src/librustc/middle/typeck/infer/coercion.rs
+++ b/src/librustc/middle/typeck/infer/coercion.rs
@@ -87,7 +87,7 @@ use syntax::ast;
// function.
pub enum Coerce = CombineFields;
-impl Coerce {
+pub impl Coerce {
fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
debug!("Coerce.tys(%s => %s)",
a.inf_str(self.infcx),
diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs
index f63dac4c5ae..e140bcad11c 100644
--- a/src/librustc/middle/typeck/infer/combine.rs
+++ b/src/librustc/middle/typeck/infer/combine.rs
@@ -316,7 +316,7 @@ pub fn super_modes(
ty::unify_mode(tcx, expected_found(self, a, b))
}
-fn super_args(
+pub fn super_args(
self: &C, a: ty::arg, b: ty::arg)
-> cres {
diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs
index 936ca1e8297..981d7be3d5f 100644
--- a/src/librustc/middle/typeck/infer/glb.rs
+++ b/src/librustc/middle/typeck/infer/glb.rs
@@ -18,9 +18,14 @@ use middle::typeck::infer::lattice::*;
use middle::typeck::infer::lub::Lub;
use middle::typeck::infer::sub::Sub;
use middle::typeck::infer::to_str::InferStr;
+use middle::typeck::infer::{cres, InferCtxt};
use middle::typeck::isr_alist;
+use syntax::ast;
use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl};
use syntax::ast::{noreturn, pure_fn, ret_style, return_val, unsafe_fn};
+use syntax::ast::{Onceness, purity};
+use syntax::codemap::span;
+use util::common::{indent, indenter};
use util::ppaux::mt_to_str;
use std::list;
diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs
index 8fa887fca0b..fe12af52d26 100644
--- a/src/librustc/middle/typeck/infer/lattice.rs
+++ b/src/librustc/middle/typeck/infer/lattice.rs
@@ -34,7 +34,7 @@
use core::prelude::*;
-use middle::ty::{RegionVid, TyVar};
+use middle::ty::{RegionVid, TyVar, Vid};
use middle::ty;
use middle::typeck::isr_alist;
use middle::typeck::infer::*;
@@ -46,6 +46,7 @@ use middle::typeck::infer::sub::Sub;
use middle::typeck::infer::lub::Lub;
use middle::typeck::infer::glb::Glb;
use middle::typeck::infer::to_str::InferStr;
+use util::common::indenter;
use std::list;
diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs
index 2c4fd9f01ee..83cbd4c745c 100644
--- a/src/librustc/middle/typeck/infer/lub.rs
+++ b/src/librustc/middle/typeck/infer/lub.rs
@@ -17,12 +17,17 @@ use middle::typeck::infer::glb::Glb;
use middle::typeck::infer::lattice::*;
use middle::typeck::infer::sub::Sub;
use middle::typeck::infer::to_str::InferStr;
+use middle::typeck::infer::{cres, InferCtxt};
use middle::typeck::isr_alist;
+use util::common::indent;
use util::ppaux::mt_to_str;
use std::list;
+use syntax::ast;
use syntax::ast::{Many, Once, extern_fn, m_const, impure_fn, noreturn};
use syntax::ast::{pure_fn, ret_style, return_val, unsafe_fn};
+use syntax::ast::{Onceness, purity};
+use syntax::codemap::span;
pub enum Lub = CombineFields; // least-upper-bound: common supertype
diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs
index 8bb1f2f47e5..aff2d599a0e 100644
--- a/src/librustc/middle/typeck/infer/mod.rs
+++ b/src/librustc/middle/typeck/infer/mod.rs
@@ -551,7 +551,7 @@ struct Snapshot {
region_vars_snapshot: uint,
}
-impl @mut InferCtxt {
+pub impl @mut InferCtxt {
fn combine_fields(&self, a_is_expected: bool,
span: span) -> CombineFields {
CombineFields {infcx: *self,
@@ -643,7 +643,7 @@ fn next_simple_var(
return id;
}
-impl @mut InferCtxt {
+pub impl @mut InferCtxt {
fn next_ty_var_id(&self) -> TyVid {
let id = self.ty_var_counter;
self.ty_var_counter += 1;
diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs
index ee598686652..d016a6f790a 100644
--- a/src/librustc/middle/typeck/infer/region_inference.rs
+++ b/src/librustc/middle/typeck/infer/region_inference.rs
@@ -1218,7 +1218,7 @@ fn TwoRegionsMap() -> TwoRegionsMap {
return HashMap();
}
-impl RegionVarBindings {
+pub impl RegionVarBindings {
fn infer_variable_values(&mut self) -> ~[GraphNodeValue] {
let mut graph = self.construct_graph();
self.expansion(&mut graph);
diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs
index 5552b71d0d7..aaaf3b425c2 100644
--- a/src/librustc/middle/typeck/infer/sub.rs
+++ b/src/librustc/middle/typeck/infer/sub.rs
@@ -11,6 +11,7 @@
use core::prelude::*;
use middle::ty;
+use middle::ty::TyVar;
use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig;
use middle::typeck::infer::combine::*;
use middle::typeck::infer::cres;
@@ -19,11 +20,14 @@ use middle::typeck::infer::InferCtxt;
use middle::typeck::infer::lub::Lub;
use middle::typeck::infer::to_str::InferStr;
use middle::typeck::infer::unify::*;
+use util::common::{indent, indenter};
use util::ppaux::bound_region_to_str;
use std::list::Nil;
use std::list;
-use syntax::ast::{m_const, purity, ret_style};
+use syntax::ast;
+use syntax::ast::{Onceness, m_const, purity, ret_style};
+use syntax::codemap::span;
pub enum Sub = CombineFields; // "subtype", "subregion" etc
diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs
index 27355da4b9a..9701e370ca8 100644
--- a/src/librustc/middle/typeck/infer/test.rs
+++ b/src/librustc/middle/typeck/infer/test.rs
@@ -79,7 +79,7 @@ fn setup_env(test_name: &str, source_string: &str) -> Env {
err_messages: messages};
}
-impl Env {
+pub impl Env {
fn create_region_hierarchy(&self, rh: &RH) {
for rh.sub.each |child_rh| {
self.create_region_hierarchy(child_rh);
diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs
index 628cccfa9a2..d82667285ff 100644
--- a/src/librustc/middle/typeck/rscope.rs
+++ b/src/librustc/middle/typeck/rscope.rs
@@ -70,11 +70,11 @@ pub fn bound_self_region(rp: Option)
}
}
-pub struct anon_rscope { anon: ty::Region, base: region_scope }
+pub struct anon_rscope { anon: ty::Region, base: @region_scope }
pub fn in_anon_rscope(self: RS,
r: ty::Region)
-> @anon_rscope {
- @anon_rscope {anon: r, base: self as region_scope}
+ @anon_rscope {anon: r, base: @self as @region_scope}
}
impl region_scope for @anon_rscope {
@@ -97,7 +97,7 @@ pub struct binding_rscope {
pub fn in_binding_rscope(self: RS)
-> @mut binding_rscope {
- let base = self as region_scope;
+ let base = @self as @region_scope;
@mut binding_rscope { base: base, anon_bindings: 0 }
}
diff --git a/src/librustdoc/doc.rs b/src/librustdoc/doc.rs
index 40617e13b8d..f7de1997d53 100644
--- a/src/librustdoc/doc.rs
+++ b/src/librustdoc/doc.rs
@@ -174,7 +174,7 @@ pub struct IndexEntry {
link: ~str
}
-impl Doc {
+pub impl Doc {
fn CrateDoc(&self) -> CrateDoc {
option::get(vec::foldl(None, self.pages, |_m, page| {
match copy *page {
@@ -190,7 +190,7 @@ impl Doc {
}
/// Some helper methods on ModDoc, mostly for testing
-impl ModDoc {
+pub impl ModDoc {
fn mods(&self) -> ~[ModDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs
index 646dc12d336..1a370947d69 100644
--- a/src/librustdoc/sort_item_type_pass.rs
+++ b/src/librustdoc/sort_item_type_pass.rs
@@ -51,7 +51,7 @@ fn test() {
fn ifn() { } \
enum ienum { ivar } \
trait itrait { fn a(); } \
- impl int { fn a() { } } \
+ pub impl int { fn a() { } } \
type itype = int; \
struct istruct { f: () }";
do astsrv::from_str(source) |srv| {
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs
index f258e649122..69c5026cbd1 100644
--- a/src/libstd/arc.rs
+++ b/src/libstd/arc.rs
@@ -21,7 +21,7 @@ use core::cell::Cell;
use core::pipes;
use core::prelude::*;
use core::private::{SharedMutableState, shared_mutable_state};
-use core::private::{clone_shared_mutable_state, unwrap_shared_mutable_state};
+use core::private::{clone_shared_mutable_state};
use core::private::{get_shared_mutable_state, get_shared_immutable_state};
use core::ptr;
use core::task;
@@ -30,7 +30,7 @@ use core::util;
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
pub struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar }
-impl &Condvar {
+pub impl &Condvar {
/// Atomically exit the associated ARC and block until a signal is sent.
#[inline(always)]
fn wait() { self.wait_on(0) }
@@ -104,20 +104,6 @@ pub fn clone(rc: &ARC) -> ARC {
ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } }
}
-/**
- * Retrieve the data back out of the ARC. This function blocks until the
- * reference given to it is the last existing one, and then unwrap the data
- * instead of destroying it.
- *
- * If multiple tasks call unwrap, all but the first will fail. Do not call
- * unwrap from a task that holds another reference to the same ARC; it is
- * guaranteed to deadlock.
- */
-pub fn unwrap(rc: ARC) -> T {
- let ARC { x: x } = rc;
- unsafe { unwrap_shared_mutable_state(x) }
-}
-
impl Clone for ARC {
fn clone(&self) -> ARC {
clone(self)
@@ -158,7 +144,7 @@ impl Clone for MutexARC {
}
}
-impl &MutexARC {
+pub impl &MutexARC {
/**
* Access the underlying mutable data with mutual exclusion from other
@@ -213,23 +199,6 @@ impl &MutexARC {
}
}
-/**
- * Retrieves the data, blocking until all other references are dropped,
- * exactly as arc::unwrap.
- *
- * Will additionally fail if another task has failed while accessing the arc.
- */
-// FIXME(#3724) make this a by-move method on the arc
-pub fn unwrap_mutex_arc(arc: MutexARC) -> T {
- let MutexARC { x: x } = arc;
- let inner = unsafe { unwrap_shared_mutable_state(x) };
- let MutexARCInner { failed: failed, data: data, _ } = inner;
- if failed {
- fail!(~"Can't unwrap poisoned MutexARC - another task failed inside!")
- }
- data
-}
-
// Common code for {mutex.access,rwlock.write}{,_cond}.
#[inline(always)]
#[doc(hidden)]
@@ -301,7 +270,7 @@ pub fn rw_arc_with_condvars(
RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () }
}
-impl RWARC {
+pub impl RWARC {
/// Duplicate a rwlock-protected ARC, as arc::clone.
fn clone(&self) -> RWARC {
RWARC { x: unsafe { clone_shared_mutable_state(&self.x) },
@@ -310,7 +279,7 @@ impl RWARC {
}
-impl &RWARC {
+pub impl &RWARC {
/**
* Access the underlying data mutably. Locks the rwlock in write mode;
* other readers and writers will block.
@@ -411,24 +380,6 @@ impl &RWARC {
}
}
-/**
- * Retrieves the data, blocking until all other references are dropped,
- * exactly as arc::unwrap.
- *
- * Will additionally fail if another task has failed while accessing the arc
- * in write mode.
- */
-// FIXME(#3724) make this a by-move method on the arc
-pub fn unwrap_rw_arc(arc: RWARC) -> T {
- let RWARC { x: x, _ } = arc;
- let inner = unsafe { unwrap_shared_mutable_state(x) };
- let RWARCInner { failed: failed, data: data, _ } = inner;
- if failed {
- fail!(~"Can't unwrap poisoned RWARC - another task failed inside!")
- }
- data
-}
-
// Borrowck rightly complains about immutably aliasing the rwlock in order to
// lock it. This wraps the unsafety, with the justification that the 'lock'
// field is never overwritten; only 'failed' and 'data'.
@@ -445,7 +396,7 @@ pub enum RWWriteMode =
/// The "read permission" token used for RWARC.write_downgrade().
pub enum RWReadMode = (&T, sync::RWlockReadMode);
-impl &RWWriteMode {
+pub impl &RWWriteMode {
/// Access the pre-downgrade RWARC in write mode.
fn write(blk: fn(x: &mut T) -> U) -> U {
match *self {
@@ -475,7 +426,7 @@ impl &RWWriteMode