diff --git a/src/driver/driver.rs b/src/driver/driver.rs index e96ff9662ebf0..e5d96165b16ca 100644 --- a/src/driver/driver.rs +++ b/src/driver/driver.rs @@ -12,18 +12,18 @@ extern mod core(vers = "0.5"); #[cfg(cargo)] -extern mod self(name = "cargo", vers = "0.5"); +extern mod this(name = "cargo", vers = "0.5"); #[cfg(fuzzer)] -extern mod self(name = "fuzzer", vers = "0.5"); +extern mod this(name = "fuzzer", vers = "0.5"); #[cfg(rustdoc)] -extern mod self(name = "rustdoc", vers = "0.5"); +extern mod this(name = "rustdoc", vers = "0.5"); #[cfg(rusti)] -extern mod self(name = "rusti", vers = "0.5"); +extern mod this(name = "rusti", vers = "0.5"); #[cfg(rustc)] -extern mod self(name = "rustc", vers = "0.5"); +extern mod this(name = "rustc", vers = "0.5"); -fn main() { self::main() } \ No newline at end of file +fn main() { this::main() } diff --git a/src/libcargo/pgp.rs b/src/libcargo/pgp.rs index 8fd4994ba145e..74f2cd922de2d 100644 --- a/src/libcargo/pgp.rs +++ b/src/libcargo/pgp.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::os; +use core::run; + fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } { return run::program_output(~"gpgv", args); } diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index dc5faf49ea4c7..0aa4fd68d57db 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -15,13 +15,18 @@ #[forbid(deprecated_pattern)]; use cast::transmute; +use iter; +use libc; use ptr::addr_of; +use sys; +use uint; +use vec; /// Code for dealing with @-vectors. This is pretty incomplete, and /// contains a bunch of duplication from the code for ~-vectors. #[abi = "cdecl"] -extern mod rustrt { +pub extern mod rustrt { #[legacy_exports]; fn vec_reserve_shared_actual(++t: *sys::TypeDesc, ++v: **vec::raw::VecRepr, @@ -29,7 +34,7 @@ extern mod rustrt { } #[abi = "rust-intrinsic"] -extern mod rusti { +pub extern mod rusti { #[legacy_exports]; fn move_val_init(dst: &mut T, -src: T); } @@ -157,6 +162,13 @@ pub mod traits { pub mod traits {} pub mod raw { + use at_vec::{rusti, rustrt}; + use libc; + use ptr; + use sys; + use uint; + use vec; + pub type VecRepr = vec::raw::VecRepr; pub type SliceRepr = vec::raw::SliceRepr; diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 6d2ed9b423e64..370c9bb44041b 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -16,6 +16,7 @@ //! Boolean logic +use cmp; use cmp::Eq; /// Negation / inverse diff --git a/src/libcore/char.rs b/src/libcore/char.rs index f16268c34583f..79ce8d3585871 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -15,6 +15,10 @@ #[forbid(deprecated_pattern)]; use cmp::Eq; +use str; +use u32; +use uint; +use unicode; /* Lu Uppercase_Letter an uppercase letter diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index 9ba095cf1bca1..6bddc2f16cd0b 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use task; + // helper for transmutation, shown below. type RustClosure = (int,int); struct Handler { diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 70d6e0898c73e..bb82ac3f47d0b 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -235,7 +235,7 @@ mod stackwalk; // 'core' so that macro-expanded references to core::error and such // can be resolved within libcore. #[doc(hidden)] // FIXME #3538 -mod core { +pub mod core { pub const error : u32 = 1_u32; pub const warn : u32 = 2_u32; pub const info : u32 = 3_u32; diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 35ff98ac17dae..e4b18646b327f 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -22,6 +22,10 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use managed; +use option; +use vec; + type DListLink = Option>; enum DListNode = @{ diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 874a36eb9f0cb..2f5e90d9e9409 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -23,8 +23,10 @@ Note that recursive use is not permitted. #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use cast; use cast::reinterpret_cast; use ptr::null; +use vec; /** * A growable, modifiable vector type that accumulates elements into a diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 74b29f3a5f1ca..5183ddf674001 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -14,8 +14,11 @@ //! A type that represents one of two alternatives +use cmp; use cmp::Eq; +use result; use result::Result; +use vec; /// The either type #[deriving_eq] diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 1c9ad6ba81a2a..5d7e0306b064b 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -82,7 +82,7 @@ debug!("hello, %s!", "world"); use cmp::Eq; use option::{Some, None}; - +use str; /* * We have a 'ct' (compile-time) module that parses format strings into a @@ -98,6 +98,10 @@ use option::{Some, None}; // Functions used by the fmt extension at compile time #[doc(hidden)] pub mod ct { + use char; + use str; + use vec; + pub enum Signedness { Signed, Unsigned, } pub enum Caseness { CaseUpper, CaseLower, } pub enum Ty { @@ -332,6 +336,12 @@ pub mod ct { // implement it 0this way, I think. #[doc(hidden)] pub mod rt { + use float; + use str; + use sys; + use uint; + use vec; + pub const flag_none : u32 = 0u32; pub const flag_left_justify : u32 = 0b00000000000001u32; pub const flag_left_zero_pad : u32 = 0b00000000000010u32; diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs index 9fbf902170aef..10ce0031c07b5 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/f32.rs @@ -14,6 +14,9 @@ //! Operations and constants for `f32` +use cmp; +use num; + pub use cmath::c_float_utils::*; pub use cmath::c_float_targ_consts::*; diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs index 86565f9e2528a..8211107ec1fb9 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/f64.rs @@ -14,6 +14,11 @@ //! Operations and constants for `f64` +use cmath; +use cmp; +use libc; +use num; + pub use cmath::c_double_utils::*; pub use cmath::c_double_targ_consts::*; diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index 506937f053fd0..a6d568c5892fc 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -18,7 +18,10 @@ Simple compression #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use libc; use libc::{c_void, size_t, c_int}; +use ptr; +use vec; extern mod rustrt { fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void, diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 2ea9c5925ef71..17e30f6a613ca 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -26,6 +26,13 @@ use m_float = f64; +use cmp::{Eq, Ord}; +use f64; +use num; +use num::Num::from_int; +use str; +use uint; + pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt}; pub use f64::logarithm; pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor}; @@ -35,8 +42,6 @@ pub use f64::{lgamma, ln, log_radix, ln1p, log10, log2, ilog_radix}; pub use f64::{modf, pow, round, sinh, tanh, tgamma, trunc}; pub use f64::signbit; pub use f64::{j0, j1, jn, y0, y1, yn}; -use cmp::{Eq, Ord}; -use num::Num::from_int; pub const NaN: float = 0.0/0.0; diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index 81936d1777498..89f5a4eb8f066 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -39,10 +39,15 @@ with destructors. #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; -pub use stackwalk::Word; -use libc::size_t; -use libc::uintptr_t; +use cast; +use io; +use libc::{size_t, uintptr_t}; +use ptr; use send_map::linear::LinearMap; +use stackwalk; +use sys; + +pub use stackwalk::Word; // Mirrors rust_stack.h stk_seg struct StackSegment { diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 26f4f0840cdde..c338b60c038ed 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -23,9 +23,12 @@ * CPRNG like rand::rng. */ -use io::Writer; -use io::WriterUtil; +use io; +use io::{Writer, WriterUtil}; +use os; use to_bytes::IterBytes; +use uint; +use vec; /** * Types that can meaningfully be hashed should implement this. diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index c61e212637418..65233782632f3 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -18,9 +18,15 @@ use T = inst::T; #[cfg(stage2)] use T = self::inst::T; +use char; use cmp::{Eq, Ord}; use from_str::FromStr; +use iter; +use num; use num::Num::from_int; +use str; +use uint; +use vec; pub const bits : uint = inst::bits; pub const bytes : uint = (inst::bits / 8); diff --git a/src/libcore/int-template/i16.rs b/src/libcore/int-template/i16.rs index 3effa40bd1607..da60b567f665a 100644 --- a/src/libcore/int-template/i16.rs +++ b/src/libcore/int-template/i16.rs @@ -12,5 +12,5 @@ mod inst { pub type T = i16; - pub const bits: uint = u16::bits; -} \ No newline at end of file + pub const bits: uint = ::u16::bits; +} diff --git a/src/libcore/int-template/i32.rs b/src/libcore/int-template/i32.rs index 710868fcb8da0..1bc45bb71af7e 100644 --- a/src/libcore/int-template/i32.rs +++ b/src/libcore/int-template/i32.rs @@ -12,5 +12,5 @@ mod inst { pub type T = i32; - pub const bits: uint = u32::bits; + pub const bits: uint = ::u32::bits; } diff --git a/src/libcore/int-template/i64.rs b/src/libcore/int-template/i64.rs index 0612322dab6b0..83d15aa857d95 100644 --- a/src/libcore/int-template/i64.rs +++ b/src/libcore/int-template/i64.rs @@ -12,5 +12,5 @@ mod inst { pub type T = i64; - pub const bits: uint = u64::bits; -} \ No newline at end of file + pub const bits: uint = ::u64::bits; +} diff --git a/src/libcore/int-template/i8.rs b/src/libcore/int-template/i8.rs index 37d7e610566a1..740442ed725be 100644 --- a/src/libcore/int-template/i8.rs +++ b/src/libcore/int-template/i8.rs @@ -12,5 +12,5 @@ mod inst { pub type T = i8; - pub const bits: uint = u8::bits; -} \ No newline at end of file + pub const bits: uint = ::u8::bits; +} diff --git a/src/libcore/int-template/int.rs b/src/libcore/int-template/int.rs index 98d833adea98a..9df61cf6cd67e 100644 --- a/src/libcore/int-template/int.rs +++ b/src/libcore/int-template/int.rs @@ -18,7 +18,7 @@ pub use self::inst::pow; mod inst { pub type T = int; - pub const bits: uint = uint::bits; + pub const bits: uint = ::uint::bits; /// Returns `base` raised to the power of `exponent` pub fn pow(base: int, exponent: uint) -> int { diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 098e24e03dd1f..a79574b372748 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -21,9 +21,18 @@ use result::Result; use cmp::Eq; use dvec::DVec; +use int; +use libc; use libc::{c_int, c_long, c_uint, c_void, size_t, ssize_t}; use libc::consts::os::posix88::*; use libc::consts::os::extra::*; +use option; +use os; +use ptr; +use result; +use str; +use uint; +use vec; #[allow(non_camel_case_types)] // not sure what to do about this type fd_t = c_int; @@ -1025,6 +1034,9 @@ pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> { // fsync related pub mod fsync { + use libc; + use option; + use os; pub enum Level { // whatever fsync does on that platform diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index dfb91c49b7d57..390daebbe8774 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -16,6 +16,7 @@ #[forbid(deprecated_pattern)]; use cmp::{Eq, Ord}; +use iter; #[cfg(stage0)] use inst::{IMPL_T, EACH, SIZE_HINT}; diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index ce5f775878cf3..42ed4b5f73cc0 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -9,6 +9,10 @@ // except according to those terms. mod inst { + use dlist; + use managed; + use option; + #[allow(non_camel_case_types)] pub type IMPL_T = dlist::DList; @@ -45,4 +49,4 @@ mod inst { pub pure fn SIZE_HINT(self: &IMPL_T) -> Option { Some(self.len()) } -} \ No newline at end of file +} diff --git a/src/libcore/iter-trait/dvec.rs b/src/libcore/iter-trait/dvec.rs index 9b7016c17d5c1..f338578d1432a 100644 --- a/src/libcore/iter-trait/dvec.rs +++ b/src/libcore/iter-trait/dvec.rs @@ -9,6 +9,8 @@ // except according to those terms. mod inst { + use dvec; + #[allow(non_camel_case_types)] pub type IMPL_T = dvec::DVec; @@ -29,4 +31,4 @@ mod inst { pub pure fn SIZE_HINT(self: &IMPL_T) -> Option { Some(self.len()) } -} \ No newline at end of file +} diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 7685fe06ad944..a2997a67bbea7 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -18,6 +18,7 @@ The iteration traits and common implementation #[forbid(deprecated_pattern)]; use cmp::{Eq, Ord}; +use vec; /// A function used to initialize the elements of a sequence pub type InitOp = &fn(uint) -> T; diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs index d8bcab62b8fa4..cb8f2b7088657 100644 --- a/src/libcore/logging.rs +++ b/src/libcore/logging.rs @@ -15,6 +15,10 @@ #[forbid(deprecated_pattern)]; use cast::transmute; +use io; +use libc; +use repr; +use vec; #[nolink] extern mod rustrt { diff --git a/src/libcore/managed.rs b/src/libcore/managed.rs index bc6a56868a5c4..5bbb5f6bec20d 100644 --- a/src/libcore/managed.rs +++ b/src/libcore/managed.rs @@ -16,6 +16,7 @@ use cmp::{Eq, Ord}; use intrinsic::TyDesc; +use ptr; pub mod raw { pub struct BoxHeaderRepr { diff --git a/src/libcore/oldcomm.rs b/src/libcore/oldcomm.rs index a5b0336ab60d9..9206f78b91524 100644 --- a/src/libcore/oldcomm.rs +++ b/src/libcore/oldcomm.rs @@ -46,8 +46,15 @@ will once again be the preferred module for intertask communication. #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use cast; +use either; use either::Either; +use libc; use libc::size_t; +use ptr; +use sys; +use task; +use vec; // After snapshot, change p2::addr_of => addr_of /** diff --git a/src/libcore/option.rs b/src/libcore/option.rs index f7de25bf021a5..304fbbfd5b465 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -45,6 +45,8 @@ let unwrapped_msg = match move msg { #[forbid(deprecated_pattern)]; use cmp::Eq; +use option; +use util; /// The option type #[deriving_eq] diff --git a/src/libcore/os.rs b/src/libcore/os.rs index b5e0983a420d1..4fe2050574df9 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -30,14 +30,24 @@ * to write OS-ignorant code by default. */ -use libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t, - mode_t, pid_t, FILE}; -pub use libc::{close, fclose}; - +use cast; +use either; +use io; +use libc; +use libc::{c_char, c_void, c_int, c_uint, size_t, ssize_t}; +use libc::{mode_t, pid_t, FILE}; +use option; use option::{Some, None}; +use private; +use ptr; +use str; +use task; +use task::TaskBuilder; +use uint; +use vec; +pub use libc::{close, fclose}; pub use os::consts::*; -use task::TaskBuilder; // FIXME: move these to str perhaps? #2620 @@ -127,6 +137,12 @@ pub fn env() -> ~[(~str,~str)] { mod global_env { //! Internal module for serializing access to getenv/setenv + use either; + use libc; + use oldcomm; + use private; + use str; + use task; extern mod rustrt { fn rust_global_env_chan_ptr() -> *libc::uintptr_t; @@ -142,7 +158,7 @@ mod global_env { let env_ch = get_global_env_chan(); let po = oldcomm::Port(); oldcomm::send(env_ch, MsgGetEnv(str::from_slice(n), - oldcomm::Chan(&po))); + oldcomm::Chan(&po))); oldcomm::recv(po) } @@ -150,8 +166,8 @@ mod global_env { let env_ch = get_global_env_chan(); let po = oldcomm::Port(); oldcomm::send(env_ch, MsgSetEnv(str::from_slice(n), - str::from_slice(v), - oldcomm::Chan(&po))); + str::from_slice(v), + oldcomm::Chan(&po))); oldcomm::recv(po) } @@ -195,6 +211,13 @@ mod global_env { } mod impl_ { + use cast; + use libc; + use option; + use ptr; + use str; + use vec; + extern mod rustrt { fn rust_env_pairs() -> ~[~str]; } diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 65ed35159314b..7b745c477b1ef 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -19,6 +19,9 @@ Cross-platform file path handling #[forbid(deprecated_pattern)]; use cmp::Eq; +use libc; +use ptr; +use str; #[deriving_eq] pub struct WindowsPath { @@ -87,6 +90,8 @@ pub pure fn Path(s: &str) -> Path { mod stat { #[cfg(target_arch = "x86")] pub mod arch { + use libc; + pub fn default_stat() -> libc::stat { libc::stat { st_dev: 0, @@ -115,6 +120,8 @@ mod stat { #[cfg(target_arch = "x86_64")] pub mod arch { + use libc; + pub fn default_stat() -> libc::stat { libc::stat { st_dev: 0, @@ -144,6 +151,8 @@ mod stat { mod stat { #[cfg(target_arch = "x86_64")] pub mod arch { + use libc; + pub fn default_stat() -> libc::stat { libc::stat { st_dev: 0, @@ -176,6 +185,8 @@ mod stat { #[cfg(target_os = "macos")] mod stat { pub mod arch { + use libc; + pub fn default_stat() -> libc::stat { libc::stat { st_dev: 0, @@ -738,6 +749,8 @@ pub pure fn normalize(components: &[~str]) -> ~[~str] { // Various windows helpers, and tests for the impl. mod windows { + use libc; + #[inline(always)] pub pure fn is_sep(u: u8) -> bool { u == '/' as u8 || u == '\\' as u8 diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 914530c065309..fa3c5148535a4 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -90,7 +90,14 @@ bounded and unbounded protocols allows for less code duplication. use cmp::Eq; use cast::{forget, reinterpret_cast, transmute}; use either::{Either, Left, Right}; +use libc; +use option; use option::unwrap; +use pipes; +use ptr; +use private; +use task; +use vec; #[doc(hidden)] const SPIN_COUNT: uint = 0; diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 2d597bfb1b5f3..c9fda4b69ecc3 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -15,8 +15,14 @@ #[doc(hidden)]; -use task::TaskBuilder; -use task::atomically; +use cast; +use libc; +use oldcomm; +use option; +use pipes; +use ptr; +use task; +use task::{TaskBuilder, atomically}; extern mod rustrt { #[legacy_exports]; diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0e83157c82d66..c1f307a9aebd7 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -13,8 +13,11 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use cast; use cmp::{Eq, Ord}; +use libc; use libc::{c_void, size_t}; +use sys; #[nolink] #[abi = "cdecl"] diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 96caf062d27a3..5b92ad6508c3b 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -14,6 +14,14 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use int; +use str; +use task; +use u32; +use uint; +use util; +use vec; + #[allow(non_camel_case_types)] // runtime type enum rctx {} diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 12b02b1b8d219..24a2ca7197451 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -19,6 +19,8 @@ Runtime type reflection use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; use libc::c_void; +use sys; +use vec; /** * Trait for visitor that wishes to reflect on data. To use this, create a diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 46bef4dd68aea..f88f26c37c8cd 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -17,18 +17,31 @@ More runtime type reflection #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use cast; +use cast::transmute; +use char; use dvec::DVec; +use intrinsic; +use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; +use io; use io::{Writer, WriterUtil}; use libc::c_void; +use managed; +use managed::raw::BoxHeaderRepr; +use ptr; +use reflect; +use reflect::{MovePtr, MovePtrAdaptor}; +use repr; +use str; +use sys; use sys::TypeDesc; use to_str::ToStr; -use cast::transmute; -use intrinsic::{TyDesc, TyVisitor, visit_tydesc}; -use reflect::{MovePtr, MovePtrAdaptor}; +use uint; +use vec; use vec::UnboxedVecRepr; use vec::raw::{VecRepr, SliceRepr}; + pub use managed::raw::BoxRepr; -use managed::raw::BoxHeaderRepr; /// Helpers diff --git a/src/libcore/result.rs b/src/libcore/result.rs index a1e7df28872a8..648f15fd7652a 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -15,8 +15,11 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use cmp; use cmp::Eq; +use either; use either::Either; +use vec; /// The result type #[deriving_eq] diff --git a/src/libcore/rt.rs b/src/libcore/rt.rs index 120103bd65683..5ad2da4824130 100644 --- a/src/libcore/rt.rs +++ b/src/libcore/rt.rs @@ -15,10 +15,9 @@ #[forbid(deprecated_pattern)]; //! Runtime calls emitted by the compiler. -use libc::c_char; -use libc::c_void; -use libc::size_t; -use libc::uintptr_t; +use libc::{c_char, c_void, size_t, uintptr_t}; +use str; +use sys; use gc::{cleanup_stack_for_failure, gc, Word}; diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 3af854236e1fa..faa0151903252 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -13,9 +13,18 @@ #[forbid(deprecated_pattern)]; //! Process spawning -use option::{Some, None}; -use libc::{pid_t, c_void, c_int}; +use io; use io::ReaderUtil; +use libc; +use libc::{pid_t, c_void, c_int}; +use oldcomm; +use option::{Some, None}; +use os; +use ptr; +use run; +use str; +use task; +use vec; #[abi = "cdecl"] extern mod rustrt { diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index af6b2c163779b..9159fee30d1ef 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -45,6 +45,12 @@ pub trait SendMap { /// Open addressing with linear probing. pub mod linear { + use cmp; + use option; + use rand; + use uint; + use vec; + const INITIAL_CAPACITY: uint = 32u; // 2^5 struct Bucket { diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 1154a86f96ca8..8d8095f9b4299 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -20,10 +20,19 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use at_vec; +use cast; +use char; use cmp::{Eq, Ord}; +use libc; use libc::size_t; use io::WriterUtil; +use ptr; +use str; use to_str::ToStr; +use u8; +use uint; +use vec; /* Section: Creating a string @@ -1938,6 +1947,11 @@ pub pure fn escape_unicode(s: &str) -> ~str { /// Unsafe operations pub mod raw { + use cast; + use libc; + use ptr; + use str::raw; + use vec; /// Create a Rust string from a null-terminated *u8 buffer pub unsafe fn from_buf(buf: *u8) -> ~str { diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 62ced6019517f..1d1a3778ef70e 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -14,8 +14,16 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use cast; use cmp::{Eq, Ord}; +use gc; +use io; +use libc; use libc::{c_void, c_char, size_t}; +use ptr; +use repr; +use str; +use vec; pub type FreeGlue = fn(*TypeDesc, *c_void); diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index d321966ac5ea1..b1bf296591955 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -26,12 +26,8 @@ magic. */ -use task::local_data_priv::{ - local_pop, - local_get, - local_set, - local_modify -}; +use rt; +use task::local_data_priv::{local_get, local_pop, local_modify, local_set}; /** * Indexes a task-local data slot. The function's code pointer is used for diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 634101ea717bf..c6b3cfa6626bb 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -10,6 +10,11 @@ #[doc(hidden)]; // FIXME #3538 +use cast; +use dvec; +use libc; +use option; +use task::rt; use task::local_data::LocalDataKey; #[cfg(notest)] diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 3cd12a5ba66ed..2b7da541b1ca1 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -38,11 +38,16 @@ * ~~~ */ +use cmp; use cmp::Eq; +use oldcomm; +use option; use result::Result; use pipes::{stream, Chan, Port}; +use result; use task::local_data_priv::{local_get, local_set}; use task::rt::{task_id, rust_task}; +use util; use util::replace; mod local_data_priv; diff --git a/src/libcore/task/rt.rs b/src/libcore/task/rt.rs index be66e9e26b835..e95c6d90eee1b 100644 --- a/src/libcore/task/rt.rs +++ b/src/libcore/task/rt.rs @@ -16,6 +16,8 @@ The task interface to the runtime #[doc(hidden)]; // FIXME #3538 +use libc; + #[allow(non_camel_case_types)] // runtime type pub type sched_id = int; #[allow(non_camel_case_types)] // runtime type diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 77acf3967e8e0..3ae3eb2e8d480 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -73,8 +73,16 @@ #[doc(hidden)]; // FIXME #3538 #[warn(deprecated_mode)]; +use cast; +use option; +use private; +use ptr; +use send_map; +use task::rt; use task::rt::rust_task; use task::rt::rust_closure; +use uint; +use util; macro_rules! move_it ( { $x:expr } => ( unsafe { let y = move *ptr::addr_of(&($x)); move y } ) diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index 900cc97066c5c..edd69219c3fcd 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -18,7 +18,9 @@ The `ToBytes` and `IterBytes` traits #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use io; use io::Writer; +use str; pub type Cb = fn(buf: &[const u8]) -> bool; diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 55055470f10f1..963901c2c75d8 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -18,49 +18,52 @@ The `ToStr` trait for converting to strings #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; +use str; +use vec; + pub trait ToStr { pub pure fn to_str() -> ~str; } impl int: ToStr { - pure fn to_str() -> ~str { int::str(self) } + pure fn to_str() -> ~str { ::int::str(self) } } impl i8: ToStr { - pure fn to_str() -> ~str { i8::str(self) } + pure fn to_str() -> ~str { ::i8::str(self) } } impl i16: ToStr { - pure fn to_str() -> ~str { i16::str(self) } + pure fn to_str() -> ~str { ::i16::str(self) } } impl i32: ToStr { - pure fn to_str() -> ~str { i32::str(self) } + pure fn to_str() -> ~str { ::i32::str(self) } } impl i64: ToStr { - pure fn to_str() -> ~str { i64::str(self) } + pure fn to_str() -> ~str { ::i64::str(self) } } impl uint: ToStr { - pure fn to_str() -> ~str { uint::str(self) } + pure fn to_str() -> ~str { ::uint::str(self) } } impl u8: ToStr { - pure fn to_str() -> ~str { u8::str(self) } + pure fn to_str() -> ~str { ::u8::str(self) } } impl u16: ToStr { - pure fn to_str() -> ~str { u16::str(self) } + pure fn to_str() -> ~str { ::u16::str(self) } } impl u32: ToStr { - pure fn to_str() -> ~str { u32::str(self) } + pure fn to_str() -> ~str { ::u32::str(self) } } impl u64: ToStr { - pure fn to_str() -> ~str { u64::str(self) } + pure fn to_str() -> ~str { ::u64::str(self) } } impl float: ToStr { - pure fn to_str() -> ~str { float::to_str(self, 4u) } + pure fn to_str() -> ~str { ::float::to_str(self, 4u) } } impl f32: ToStr { - pure fn to_str() -> ~str { float::to_str(self as float, 4u) } + pure fn to_str() -> ~str { ::float::to_str(self as float, 4u) } } impl f64: ToStr { - pure fn to_str() -> ~str { float::to_str(self as float, 4u) } + pure fn to_str() -> ~str { ::float::to_str(self as float, 4u) } } impl bool: ToStr { - pure fn to_str() -> ~str { bool::to_str(self) } + pure fn to_str() -> ~str { ::bool::to_str(self) } } impl (): ToStr { pure fn to_str() -> ~str { ~"()" } @@ -69,10 +72,10 @@ impl ~str: ToStr { pure fn to_str() -> ~str { copy self } } impl &str: ToStr { - pure fn to_str() -> ~str { str::from_slice(self) } + pure fn to_str() -> ~str { ::str::from_slice(self) } } impl @str: ToStr { - pure fn to_str() -> ~str { str::from_slice(self) } + pure fn to_str() -> ~str { ::str::from_slice(self) } } impl (A, B): ToStr { diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 5ab013223c667..c602c19317021 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -15,6 +15,7 @@ //! Operations on tuples use cmp::{Eq, Ord}; +use vec; pub trait CopyableTuple { pure fn first() -> T; diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 17a2b02647e45..8b3b12593070e 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -18,8 +18,13 @@ use T = inst::T; #[cfg(stage2)] use T = self::inst::T; +use char; use cmp::{Eq, Ord}; use from_str::FromStr; +use iter; +use num; +use str; +use vec; pub const bits : uint = inst::bits; pub const bytes : uint = (inst::bits / 8); diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/uint-template/uint.rs index 8451d78d8e0dc..dc1840ea51364 100644 --- a/src/libcore/uint-template/uint.rs +++ b/src/libcore/uint-template/uint.rs @@ -23,6 +23,8 @@ pub use self::inst::{ }; mod inst { + use sys; + pub type T = uint; #[cfg(target_arch = "x86")] diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index c568faccf8931..a449def4e9284 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -14,20 +14,27 @@ #[forbid(deprecated_pattern)]; #[warn(non_camel_case_types)]; +use cast; use cmp::{Eq, Ord}; +use iter; +use libc; +use libc::size_t; use option::{Some, None}; +use ptr; use ptr::addr_of; -use libc::size_t; +use sys; +use uint; +use vec; #[abi = "cdecl"] -extern mod rustrt { +pub extern mod rustrt { fn vec_reserve_shared(++t: *sys::TypeDesc, ++v: **raw::VecRepr, ++n: libc::size_t); } #[abi = "rust-intrinsic"] -extern mod rusti { +pub extern mod rusti { fn move_val_init(dst: &mut T, -src: T); fn init() -> T; } @@ -1799,6 +1806,11 @@ pub struct UnboxedVecRepr { /// Unsafe operations pub mod raw { + use managed; + use option; + use ptr; + use sys; + use vec::rusti; /// The internal representation of a (boxed) vector pub struct VecRepr { @@ -1939,6 +1951,10 @@ pub mod raw { /// Operations on `[u8]` pub mod bytes { + use libc; + use uint; + use vec; + use vec::raw; /// Bytewise string comparison pub pure fn cmp(a: &~[u8], b: &~[u8]) -> int { diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 52b94b76fe614..73e891ea1d4f8 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -8,24 +8,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use libc::{c_int, c_uint, c_char}; +use back::rpath; use driver::session; -use session::Session; use lib::llvm::llvm; -use syntax::attr; -use middle::ty; +use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False}; +use lib::llvm::{PassManagerRef, FileType}; +use lib; +use metadata::common::link_meta; +use metadata::filesearch; use metadata::{encoder, cstore}; use middle::trans::common::crate_ctxt; -use metadata::common::link_meta; +use middle::ty; +use session::Session; +use session; +use util::ppaux; + +use core::io::{Writer, WriterUtil}; +use core::libc::{c_int, c_uint, c_char}; use std::map::HashMap; use std::sha1::sha1; use syntax::ast; -use syntax::print::pprust; -use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False, - PassManagerRef, FileType}; -use metadata::filesearch; use syntax::ast_map::{path, path_mod, path_name}; -use io::{Writer, WriterUtil}; +use syntax::attr; +use syntax::print::pprust; enum output_type { output_type_none, @@ -65,8 +70,15 @@ fn WriteOutputFile(sess: Session, } } -mod jit { +pub mod jit { #[legacy_exports]; + + use lib::llvm::llvm; + use metadata::cstore; + + use core::cast; + use core::ptr; + #[nolink] #[abi = "rust-intrinsic"] extern mod rusti { @@ -133,6 +145,12 @@ mod jit { mod write { #[legacy_exports]; + + use back::link::jit; + use driver::session; + use lib::llvm::llvm; + use lib; + fn is_object_or_assembly_or_exe(ot: output_type) -> bool { if ot == output_type_assembly || ot == output_type_object || ot == output_type_exe { @@ -609,7 +627,7 @@ fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str { fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: ~str) -> ~str { - let s = util::ppaux::ty_to_short_str(ccx.tcx, t); + let s = ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); return mangle(ccx.sess, ~[path_name(ccx.sess.ident_of(name)), diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index c12458c3f2805..80f8f142be047 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::map; -use std::map::HashMap; -use metadata::cstore; use driver::session; +use metadata::cstore; use metadata::filesearch; +use core::util; +use std::map::HashMap; +use std::map; + export get_rpath_flags; pure fn not_win32(os: session::os) -> bool { @@ -116,7 +118,7 @@ fn get_rpath_relative_to_output(os: session::os, let prefix = match os { session::os_linux | session::os_freebsd => "$ORIGIN", session::os_macos => "@executable_path", - session::os_win32 => core::util::unreachable() + session::os_win32 => util::unreachable() }; Path(prefix).push_rel(&get_relative_to(&os::make_absolute(output), diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs index 5d8109b9c08db..43f134702cbaa 100644 --- a/src/librustc/back/x86.rs +++ b/src/librustc/back/x86.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use back::target_strs; use driver::session; -use session::sess_os_to_meta_os; use metadata::loader::meta_section_name; +use session::sess_os_to_meta_os; fn get_target_strs(target_os: session::os) -> target_strs::t { return { diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs index ffc598c3a0753..1d459aaa6f3f8 100644 --- a/src/librustc/back/x86_64.rs +++ b/src/librustc/back/x86_64.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use back::target_strs; use driver::session; -use session::sess_os_to_meta_os; use metadata::loader::meta_section_name; +use session::sess_os_to_meta_os; fn get_target_strs(target_os: session::os) -> target_strs::t { return { diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 91c0d03657724..4f1ede07bd21b 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -9,27 +9,43 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use back::link; +use back::{x86, x86_64}; +use front; +use lib::llvm::llvm; use metadata::{creader, cstore, filesearch}; -use session::{Session, Session_, OptLevel, No, Less, Default, Aggressive}; -use syntax::parse; -use syntax::{ast, codemap}; -use syntax::attr; +use metadata; use middle::{trans, freevars, kind, ty, typeck, lint}; -use syntax::print::{pp, pprust}; +use middle; +use session::{Session, Session_, OptLevel, No, Less, Default, Aggressive}; +use session; use util::ppaux; -use back::link; -use result::{Ok, Err}; -use std::getopts; -use std::getopts::{opt_present}; -use std::getopts::groups; + +use core::io::WriterUtil; +use core::option; +use core::result::{Ok, Err}; use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; -use io::WriterUtil; -use back::{x86, x86_64}; +use std::getopts::groups; +use std::getopts::{opt_present}; +use std::getopts; use std::map::HashMap; -use lib::llvm::llvm; - -enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified, - ppm_expanded_identified } +use std; +use syntax::ast; +use syntax::ast_map; +use syntax::attr; +use syntax::codemap; +use syntax::diagnostic; +use syntax::parse; +use syntax::print::{pp, pprust}; +use syntax; + +enum pp_mode { + ppm_normal, + ppm_expanded, + ppm_typed, + ppm_identified, + ppm_expanded_identified +} /** * The name used for source code that doesn't originate in a file diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index b2cb6da78ddc2..344ac53237a41 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -11,15 +11,21 @@ use back::link; use back::target_strs; +use back; +use driver; +use driver::session; use metadata::filesearch; +use metadata; use middle::lint; +use core::cmp; use syntax::ast::node_id; use syntax::ast::{int_ty, uint_ty, float_ty}; use syntax::codemap::span; +use syntax::diagnostic; use syntax::parse::parse_sess; use syntax::{ast, codemap}; - +use syntax; enum os { os_win32, os_macos, os_linux, os_freebsd, } diff --git a/src/librustc/front/core_inject.rs b/src/librustc/front/core_inject.rs index 0d01bdbd33654..5d80f9e40491a 100644 --- a/src/librustc/front/core_inject.rs +++ b/src/librustc/front/core_inject.rs @@ -13,9 +13,12 @@ use syntax::codemap; use syntax::ast; use syntax::ast_util::*; use syntax::attr; +use syntax::fold; export maybe_inject_libcore_ref; +const CORE_VERSION: &static/str = "0.5"; + fn maybe_inject_libcore_ref(sess: Session, crate: @ast::crate) -> @ast::crate { if use_core(crate) { @@ -31,29 +34,56 @@ fn use_core(crate: @ast::crate) -> bool { fn inject_libcore_ref(sess: Session, crate: @ast::crate) -> @ast::crate { - - fn spanned(x: T) -> @ast::spanned { - return @{node: x, - span: dummy_sp()}; + fn spanned(x: T) -> ast::spanned { + return {node: x, span: dummy_sp()}; } - let n1 = sess.next_node_id(); - let n2 = sess.next_node_id(); - - let vi1 = @{node: ast::view_item_use(sess.ident_of(~"core"), ~[], n1), - attrs: ~[], - vis: ast::private, - span: dummy_sp()}; - let vp = spanned(ast::view_path_glob( - ident_to_path(dummy_sp(), sess.ident_of(~"core")), - n2)); - let vi2 = @{node: ast::view_item_import(~[vp]), - attrs: ~[], - vis: ast::private, - span: dummy_sp()}; - - let vis = vec::append(~[vi1, vi2], crate.node.module.view_items); - - return @{node: {module: { view_items: vis,.. crate.node.module }, - .. crate.node},.. *crate } + let precursor = @{ + fold_crate: |crate, span, fld| { + let n1 = sess.next_node_id(); + let vi1 = @{node: ast::view_item_use(sess.ident_of(~"core"), + ~[], + n1), + attrs: ~[ + spanned({ + style: ast::attr_inner, + value: spanned(ast::meta_name_value( + ~"vers", + spanned(ast::lit_str( + @CORE_VERSION.to_str())) + )), + is_sugared_doc: false + }) + ], + vis: ast::private, + span: dummy_sp()}; + + let vis = vec::append(~[vi1], crate.module.view_items); + let mut new_module = { view_items: vis, ..crate.module }; + new_module = fld.fold_mod(new_module); + + let new_crate = { module: new_module, ..crate }; + (new_crate, span) + }, + fold_mod: |module, fld| { + let n2 = sess.next_node_id(); + + let vp = @spanned( + ast::view_path_glob(ident_to_path(dummy_sp(), + sess.ident_of(~"core")), + n2)); + let vi2 = @{node: ast::view_item_import(~[vp]), + attrs: ~[], + vis: ast::private, + span: dummy_sp()}; + + let vis = vec::append(~[vi2], module.view_items); + let new_module = { view_items: vis, ..module }; + fold::noop_fold_mod(new_module, fld) + }, + ..*fold::default_ast_fold() + }; + + let fold = fold::make_fold(precursor); + @fold.fold_crate(*crate) } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 27e9e35b7ec47..ba8b571645115 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -10,16 +10,17 @@ // Code that generates a test runner to run all the tests in a crate -use syntax::{ast, ast_util}; -use syntax::ast_util::*; -//import syntax::ast_util::dummy_sp; -use syntax::fold; -use syntax::print::pprust; -use syntax::codemap::span; use driver::session; +use front::config; use session::Session; + +use core::dvec::DVec; +use syntax::ast_util::*; use syntax::attr; -use dvec::DVec; +use syntax::codemap::span; +use syntax::fold; +use syntax::print::pprust; +use syntax::{ast, ast_util}; export modify_for_testing; diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 3f24d28043799..70a79d48d8cc5 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::libc::{c_char, c_int, c_uint, c_longlong, c_ulonglong}; use std::map::HashMap; -use libc::{c_char, c_int, c_uint, c_longlong, c_ulonglong}; - type Opcode = u32; type Bool = c_uint; + const True: Bool = 1 as Bool; const False: Bool = 0 as Bool; @@ -1058,8 +1058,8 @@ fn SetLinkage(Global: ValueRef, Link: Linkage) { /* Memory-managed object interface to type handles. */ -type type_names = @{type_names: std::map::HashMap, - named_types: std::map::HashMap<~str, TypeRef>}; +type type_names = @{type_names: HashMap, + named_types: HashMap<~str, TypeRef>}; fn associate_type(tn: type_names, s: ~str, t: TypeRef) { assert tn.type_names.insert(t, s); @@ -1075,8 +1075,8 @@ fn name_has_type(tn: type_names, s: ~str) -> Option { } fn mk_type_names() -> type_names { - @{type_names: std::map::HashMap(), - named_types: std::map::HashMap()} + @{type_names: HashMap(), + named_types: HashMap()} } fn type_to_str(names: type_names, ty: TypeRef) -> ~str { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index bebddec94d34d..7d0baa4044e73 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -10,17 +10,21 @@ //! Validates all used crates and extern libraries and loads their metadata -use syntax::diagnostic::span_handler; -use syntax::{ast, ast_util}; +use metadata::cstore; +use metadata::common::*; +use metadata::decoder; +use metadata::filesearch::FileSearch; +use metadata::loader; + +use core::dvec::DVec; use syntax::attr; -use syntax::visit; use syntax::codemap::span; -use std::map::HashMap; -use syntax::print::pprust; -use metadata::filesearch::FileSearch; -use metadata::common::*; -use dvec::DVec; +use syntax::diagnostic::span_handler; use syntax::parse::token::ident_interner; +use syntax::print::pprust; +use syntax::visit; +use syntax::{ast, ast_util}; +use std::map::HashMap; export read_crates; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index ae56cf45dbcf2..fe3e77946aed2 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -11,10 +11,12 @@ // Searching for information from the cstore use metadata::common::*; +use metadata::cstore; +use metadata::decoder; +use metadata; use middle::ty; use core::dvec::DVec; -use core::option::{Some, None}; use reader = std::ebml::reader; use std::ebml; use std::map::HashMap; diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 4f5046e40083c..ea3d3908bc07d 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -11,8 +11,13 @@ // The crate store - a central repo for information collected about external // crates and libraries -use std::map; +use metadata::creader; +use metadata::cstore; +use metadata::decoder; + use std::map::HashMap; +use std::map; +use std; use syntax::{ast, attr}; use syntax::parse::token::ident_interner; diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 1e86eb78cfe3f..4239510475179 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -16,6 +16,9 @@ use hash::{Hash, HashUtil}; use io::WriterUtil; use metadata::common::*; use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo}; +use metadata::csearch; +use metadata::cstore; +use metadata::decoder; use metadata::tydecode::{parse_ty_data, parse_def_id, parse_bounds_data}; use metadata::tydecode::{parse_ident}; use middle::ty; diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 01755a79f2e85..b63ce0b984d1d 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -10,28 +10,34 @@ // Metadata encoding +use metadata::common::*; +use metadata::csearch; +use metadata::cstore; +use metadata::decoder; +use metadata::tyencode; +use middle::resolve; +use middle::ty::node_id_to_type; +use middle::ty; +use middle; use util::ppaux::ty_to_str; -use std::{ebml, map}; +use core::hash::{Hash, HashUtil}; +use core::io::WriterUtil; +use core::str::to_bytes; +use core::to_bytes::IterBytes; use std::map::HashMap; -use io::WriterUtil; -use writer = std::ebml::writer; +use std::{ebml, map}; +use std; use syntax::ast::*; -use syntax::print::pprust; -use syntax::{ast_util, visit}; -use syntax::ast_util::*; -use metadata::common::*; -use middle::ty; -use middle::ty::node_id_to_type; -use middle::resolve; +use syntax::ast; use syntax::ast_map; +use syntax::ast_util::*; use syntax::attr; -use str::to_bytes; -use syntax::ast; use syntax::diagnostic::span_handler; - -use hash::{Hash, HashUtil}; -use to_bytes::IterBytes; +use syntax::print::pprust; +use syntax::{ast_util, visit}; +use syntax; +use writer = std::ebml::writer; export encode_parms; export encode_metadata; @@ -458,7 +464,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: writer::Serializer, let its_ty = node_id_to_type(ecx.tcx, id); debug!("fn name = %s ty = %s its node id = %d", ecx.tcx.sess.str_of(ident), - util::ppaux::ty_to_str(ecx.tcx, its_ty), id); + ty_to_str(ecx.tcx, its_ty), id); encode_type(ecx, ebml_w, its_ty); encode_path(ecx, ebml_w, path, ast_map::path_name(ident)); match item { diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 5901e58aeb190..eb74692b24539 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -10,14 +10,18 @@ //! Finds crate binaries and loads their metadata -use syntax::diagnostic::span_handler; -use syntax::{ast, attr}; -use syntax::print::pprust; -use syntax::codemap::span; use lib::llvm::{False, llvm, mk_object_file, mk_section_iter}; +use metadata::decoder; +use metadata::encoder; use metadata::filesearch::FileSearch; -use io::WriterUtil; +use metadata::filesearch; +use syntax::codemap::span; +use syntax::diagnostic::span_handler; use syntax::parse::token::ident_interner; +use syntax::print::pprust; +use syntax::{ast, attr}; + +use core::io::WriterUtil; export os; export os_macos, os_win32, os_linux, os_freebsd; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 8acba42f9a8e8..5627441fda2a0 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -20,6 +20,7 @@ use middle::freevars::freevar_entry; use middle::typeck::{method_origin, method_map_entry, vtable_res}; use middle::typeck::{vtable_origin}; use middle::{ty, typeck}; +use middle; use util::ppaux::ty_to_str; use reader = std::ebml::reader; @@ -41,6 +42,7 @@ use syntax::fold; use syntax::parse; use syntax::print::pprust; use syntax::visit; +use syntax; use writer = std::ebml::writer; export maps; diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 858cfb06d5120..249ec5190440f 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -18,8 +18,14 @@ // 4. moves to dnot affect things loaned out in any way use middle::ty::{CopyValue, MoveValue, ReadValue}; - -use dvec::DVec; +use middle::ty; + +use core::cmp; +use core::dvec::DVec; +use syntax::ast; +use syntax::ast_util; +use syntax::print::pprust; +use syntax::visit; export check_loans; diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index d5809a7389e81..8d7283b5e0215 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -16,11 +16,16 @@ // their associated scopes. In phase two, checking loans, we will then make // sure that all of these loans are honored. -use middle::mem_categorization::{mem_categorization_ctxt, opt_deref_kind}; use middle::borrowck::preserve::{preserve_condition, pc_ok, pc_if_pure}; +use middle::mem_categorization::{mem_categorization_ctxt, opt_deref_kind}; +use middle::pat_util; use middle::ty::{ty_region}; +use middle::ty; use core::send_map::linear::LinearMap; +use syntax::ast; +use syntax::print::pprust; +use syntax::visit; export gather_loans; diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index 7dc68fa0b4b13..c79a733e92d46 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -12,8 +12,12 @@ // Loan(Ex, M, S) = Ls holds if ToAddr(Ex) will remain valid for the entirety // of the scope S, presuming that the returned set of loans `Ls` are honored. +use middle::ty; + +use core::result::{Result, Ok, Err}; +use syntax::ast; + export public_methods; -use result::{Result, Ok, Err}; impl borrowck_ctxt { fn loan(cmt: cmt, diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 90de32814470e..73822d67bc480 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -226,8 +226,11 @@ Borrowck results in two maps. #[legacy_exports]; +use middle::liveness; use middle::mem_categorization::*; +use middle::region; use middle::ty::to_str; +use middle::ty; use util::common::indenter; use util::ppaux::{expr_repr, note_and_explain_region}; use util::ppaux::{ty_to_str, region_to_str, explain_region}; @@ -333,7 +336,7 @@ type root_map_key = {id: ast::node_id, derefs: uint}; // set of ids of local vars / formal arguments that are modified / moved. // this is used in trans for optimization purposes. -type mutbl_map = std::map::HashMap; +type mutbl_map = HashMap; // Errors that can occur"] enum bckerr_code { diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index b1a34bbe2569b..af2832cf11ee1 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -13,6 +13,10 @@ // the scope S. // +use middle::ty; + +use syntax::ast; + export public_methods, preserve_condition, pc_ok, pc_if_pure; enum preserve_condition { diff --git a/src/librustc/middle/capture.rs b/src/librustc/middle/capture.rs index f9a7459c67176..076cd9e63d444 100644 --- a/src/librustc/middle/capture.rs +++ b/src/librustc/middle/capture.rs @@ -8,10 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::{ast, ast_util}; -use syntax::codemap::span; -use std::map; +use middle::freevars; +use middle::ty; + use std::map::HashMap; +use std::map; +use syntax::codemap::span; +use syntax::{ast, ast_util}; export capture_mode; export capture_var; diff --git a/src/librustc/middle/check_alt.rs b/src/librustc/middle/check_alt.rs index 197a88d9ddee2..c63555689a8ce 100644 --- a/src/librustc/middle/check_alt.rs +++ b/src/librustc/middle/check_alt.rs @@ -19,6 +19,7 @@ use util::ppaux::ty_to_str; use std::map::HashMap; use syntax::ast::*; use syntax::ast_util::{variant_def_ids, dummy_sp, unguarded_pat, walk_pat}; +use syntax::ast_util; use syntax::codemap::span; use syntax::print::pprust::pat_to_str; use syntax::visit; @@ -383,7 +384,7 @@ fn ctor_arity(cx: @AltCheckCtxt, ctor: ctor, ty: ty::t) -> uint { } fn wild() -> @pat { - @{id: 0, node: pat_wild, span: syntax::ast_util::dummy_sp()} + @{id: 0, node: pat_wild, span: ast_util::dummy_sp()} } fn specialize(cx: @AltCheckCtxt, r: ~[@pat], ctor_id: ctor, arity: uint, diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 06dd18b3bf3f4..9e3b048ee2ac3 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -8,11 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::ast::*; -use syntax::{visit, ast_util, ast_map}; use driver::session::Session; +use middle::resolve; +use middle::ty; +use middle::typeck; +use util::ppaux; + +use core::dvec::DVec; use std::map::HashMap; -use dvec::DVec; +use syntax::ast::*; +use syntax::{visit, ast_util, ast_map}; fn check_crate(sess: Session, crate: @crate, ast_map: ast_map::map, def_map: resolve::DefMap, @@ -88,7 +93,7 @@ fn check_expr(sess: Session, def_map: resolve::DefMap, let ety = ty::expr_ty(tcx, e); if !ty::type_is_numeric(ety) { sess.span_err(e.span, ~"can not cast to `" + - util::ppaux::ty_to_str(tcx, ety) + + ppaux::ty_to_str(tcx, ety) + ~"` in a constant expression"); } } diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index 5ff186126fb0c..d96d29f683596 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; + use syntax::ast::*; use syntax::visit; diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index a51885b1fc7eb..2705a2844dd05 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::resolve; +use middle::ty; +use middle; + use syntax::{ast, ast_map, ast_util, visit}; use syntax::ast::*; diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index cfebe7c06e9b1..310a5626b42f9 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -11,11 +11,14 @@ // A pass that annotates for each loops and functions with the free // variables that they contain. -use syntax::print::pprust::path_to_str; +use middle::resolve; +use middle::ty; + +use core::option::*; use std::map::*; -use option::*; -use syntax::{ast, ast_util, visit}; use syntax::codemap::span; +use syntax::print::pprust::path_to_str; +use syntax::{ast, ast_util, visit}; export annotate_freevars; export freevar_map; diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index e35377c5cdd93..ebf5364be7bfe 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -9,11 +9,18 @@ // except according to those terms. use middle::freevars::freevar_entry; +use middle::freevars; use middle::lint::{non_implicitly_copyable_typarams, implicit_copies}; +use middle::liveness; +use middle::pat_util; use middle::ty::{CopyValue, MoveValue, ReadValue}; use middle::ty::{Kind, kind_copyable, kind_noncopyable, kind_const}; +use middle::ty; +use middle::typeck; +use middle; use util::ppaux::{ty_to_str, tys_to_str}; +use core::vec; use std::map::HashMap; use syntax::ast::*; use syntax::codemap::span; @@ -71,7 +78,7 @@ fn kind_to_str(k: Kind) -> ~str { str::connect(kinds, ~" ") } -type rval_map = std::map::HashMap; +type rval_map = HashMap; type ctx = {tcx: ty::ctxt, method_map: typeck::method_map, diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 40aecfd4298c3..ca6ffd26b138f 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -8,19 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use driver::session; use driver::session::Session; +use driver::session; +use middle::pat_util::{pat_bindings}; use middle::ty; -use syntax::{ast, ast_util, visit}; -use syntax::attr; -use syntax::codemap::span; -use std::map::{Map,HashMap}; -use std::smallintmap::{Map,SmallIntMap}; -use io::WriterUtil; use util::ppaux::{ty_to_str}; -use middle::pat_util::{pat_bindings}; + +use core::io::WriterUtil; +use std::map::{Map, HashMap}; +use std::map; +use std::smallintmap::{Map, SmallIntMap}; +use std::smallintmap; use syntax::ast_util::{path_to_ident}; +use syntax::attr; +use syntax::codemap::span; use syntax::print::pprust::{expr_to_str, mode_to_str, pat_to_str}; +use syntax::{ast, ast_util, visit}; + export lint, ctypes, unused_imports, while_true, path_statement, old_vecs; export unrecognized_lint, non_implicitly_copyable_typarams; export vecs_implicitly_copyable, implicit_copies, legacy_modes; @@ -226,7 +230,7 @@ fn get_lint_dict() -> lint_dict { default: warn}), */ ]; - std::map::hash_from_vec(v) + map::hash_from_vec(v) } // This is a highly not-optimal set of data structure decisions. @@ -242,7 +246,7 @@ type lint_settings = { }; fn mk_lint_settings() -> lint_settings { - {default_settings: std::smallintmap::mk(), + {default_settings: smallintmap::mk(), settings_map: HashMap()} } @@ -266,7 +270,7 @@ fn get_lint_settings_level(settings: lint_settings, // This is kind of unfortunate. It should be somewhere else, or we should use // a persistent data structure... fn clone_lint_modes(modes: lint_modes) -> lint_modes { - std::smallintmap::SmallIntMap_(@{v: copy modes.v}) + smallintmap::SmallIntMap_(@{v: copy modes.v}) } type ctxt_ = {dict: lint_dict, @@ -386,7 +390,7 @@ fn build_settings_item(i: @ast::item, &&cx: ctxt, v: visit::vt) { fn build_settings_crate(sess: session::Session, crate: @ast::crate) { let cx = ctxt_({dict: get_lint_dict(), - curr: std::smallintmap::mk(), + curr: smallintmap::mk(), is_default: true, sess: sess}); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index c481ef81477bb..3388e1732d914 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -103,7 +103,11 @@ */ use middle::capture::{cap_move, cap_drop, cap_copy, cap_ref}; +use middle::capture; +use middle::pat_util; use middle::ty::MoveValue; +use middle::ty; +use middle::typeck; use core::dvec::DVec; use core::io::WriterUtil; @@ -414,7 +418,7 @@ impl IrMaps { fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, id: node_id, &&self: @IrMaps, v: vt<@IrMaps>) { debug!("visit_fn: id=%d", id); - let _i = util::common::indenter(); + let _i = ::util::common::indenter(); // swap in a new set of IR maps for this function body: let fn_maps = @IrMaps(self.tcx, self.method_map, diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 0e9be0b6e681f..dff9a3d5688be 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -46,12 +46,15 @@ * then an index to jump forward to the relevant item. */ -use syntax::ast; +use middle::ty; +use middle::typeck; +use util::ppaux::{ty_to_str, region_to_str}; +use util::common::indenter; + use syntax::ast::{m_imm, m_const, m_mutbl}; +use syntax::ast; use syntax::codemap::span; use syntax::print::pprust; -use util::ppaux::{ty_to_str, region_to_str}; -use util::common::indenter; enum categorization { cat_rvalue, // result of eval'ing some misc expr diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index b1bd42758f19a..9677c517094ab 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::resolve; use middle::ty::{CopyValue, MoveValue, ReadValue}; +use middle::ty; use syntax::ast::*; use syntax::ast_util; @@ -23,12 +25,12 @@ export pat_is_variant_or_struct, pat_is_binding, pat_is_binding_or_wild; export pat_is_const; export arms_have_by_move_bindings; -type PatIdMap = std::map::HashMap; +type PatIdMap = HashMap; // This is used because same-named variables in alternative patterns need to // use the node_id of their namesake in the first pattern. fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap { - let map = std::map::HashMap(); + let map = HashMap(); do pat_bindings(dm, pat) |_bm, p_id, _s, n| { map.insert(path_to_ident(n), p_id); }; diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 5819db17f58a8..b9f70bd4d3326 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -12,21 +12,22 @@ // outside their scopes. use middle::ty::{ty_struct, ty_enum}; +use middle::ty; use middle::typeck::{method_map, method_origin, method_param, method_self}; use middle::typeck::{method_static, method_trait}; -use /*mod*/ syntax::ast; -use /*mod*/ syntax::visit; -use syntax::ast_map; + +use core::dvec::DVec; +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; use syntax::ast_map::{node_item, node_method}; +use syntax::ast_map; use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local}; use syntax::ast_util::{visibility_to_privacy}; - -use core::util::ignore; -use dvec::DVec; +use syntax::visit; fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { let privileged_items = @DVec(); diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index f746e0236807e..e497475b7ad90 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -19,6 +19,7 @@ region parameterized. use driver::session::Session; use metadata::csearch; +use middle::resolve; use middle::ty::{region_variance, rv_covariant, rv_invariant}; use middle::ty::{rv_contravariant}; use middle::ty; @@ -564,7 +565,7 @@ impl determine_rp_ctxt { self.item_id = item_id; self.anon_implies_rp = anon_implies_rp; debug!("with_item_id(%d, %b)", item_id, anon_implies_rp); - let _i = util::common::indenter(); + let _i = ::util::common::indenter(); f(); self.item_id = old_item_id; self.anon_implies_rp = old_anon_implies_rp; diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 93fe8817120cd..131d898ce616a 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -35,16 +35,16 @@ use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge}; use syntax::ast::{gt, ident, impure_fn, inherited, item, item_struct}; use syntax::ast::{item_const, item_enum, item_fn, item_foreign_mod}; use syntax::ast::{item_impl, item_mac, item_mod, item_trait, item_ty, le}; -use syntax::ast::{local, local_crate, lt, method, mode, module_ns, mul, ne}; -use syntax::ast::{neg, node_id, pat, pat_enum, pat_ident, path, prim_ty}; -use syntax::ast::{pat_box, pat_lit, pat_range, pat_rec, pat_struct}; -use syntax::ast::{pat_tup, pat_uniq, pat_wild, private, provided, public}; -use syntax::ast::{required, rem, self_ty_, shl, shr, stmt_decl, struct_dtor}; -use syntax::ast::{struct_field, struct_variant_kind, sty_by_ref, sty_static}; -use syntax::ast::{subtract, trait_ref, tuple_variant_kind, Ty, ty_bool}; -use syntax::ast::{ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i, ty_i16}; -use syntax::ast::{ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path, ty_str}; -use syntax::ast::{ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint}; +use syntax::ast::{local, local_crate, lt, method, mode, module_ns, mul}; +use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident}; +use syntax::ast::{path, pat_box, pat_lit, pat_range, pat_rec, pat_struct}; +use syntax::ast::{pat_tup, pat_uniq, pat_wild, prim_ty, private, provided}; +use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl}; +use syntax::ast::{struct_dtor, struct_field, struct_variant_kind, sty_by_ref}; +use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty}; +use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i}; +use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path}; +use syntax::ast::{ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint}; use syntax::ast::{type_value_ns, ty_param_bound, unnamed_field}; use syntax::ast::{variant, view_item, view_item_export, view_item_import}; use syntax::ast::{view_item_use, view_path_glob, view_path_list}; @@ -54,6 +54,8 @@ use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method}; use syntax::ast_util::{Privacy, Public, Private, visibility_to_privacy}; use syntax::ast_util::has_legacy_export_attr; use syntax::attr::{attr_metas, contains_name}; +use syntax::parse::token::ident_interner; +use syntax::parse::token::special_idents; use syntax::print::pprust::{pat_to_str, path_to_str}; use syntax::codemap::span; use syntax::visit::{default_visitor, fk_method, mk_vt, visit_block}; @@ -66,7 +68,6 @@ use dvec::DVec; use option::{Some, get, is_some, is_none}; use str::{connect, split_str}; use vec::pop; -use syntax::parse::token::ident_interner; use std::list::{Cons, List, Nil}; use std::map::HashMap; @@ -317,9 +318,14 @@ enum UseLexicalScopeFlag { UseLexicalScope } -struct ModulePrefixResult { - result: ResolveResult<@Module>, - prefix_len: uint +enum SearchThroughModulesFlag { + DontSearchThroughModules, + SearchThroughModules +} + +enum ModulePrefixResult { + NoPrefixFound, + PrefixFound(@Module, uint) } impl XrayFlag : cmp::Eq { @@ -475,10 +481,19 @@ enum ParentLink { BlockParentLink(@Module, node_id) } +/// The type of module this is. +enum ModuleKind { + NormalModuleKind, + ExternModuleKind, + TraitModuleKind, + AnonymousModuleKind, +} + /// One node in the tree of modules. struct Module { parent_link: ParentLink, mut def_id: Option, + kind: ModuleKind, children: HashMap, imports: DVec<@ImportDirective>, @@ -527,10 +542,12 @@ struct Module { fn Module(parent_link: ParentLink, def_id: Option, + kind: ModuleKind, legacy_exports: bool) -> Module { Module { parent_link: parent_link, def_id: def_id, + kind: kind, children: HashMap(), imports: DVec(), anonymous_children: HashMap(), @@ -589,10 +606,11 @@ impl NameBindings { fn define_module(privacy: Privacy, parent_link: ParentLink, def_id: Option, + kind: ModuleKind, legacy_exports: bool, sp: span) { // Merges the module with the existing type def or creates a new one. - let module_ = @Module(parent_link, def_id, legacy_exports); + let module_ = @Module(parent_link, def_id, kind, legacy_exports); match self.type_def { None => { self.type_def = Some(TypeNsDef { @@ -794,6 +812,7 @@ fn Resolver(session: Session, lang_items: LanguageItems, (*graph_root).define_module(Public, NoParentLink, Some({ crate: 0, node: 0 }), + NormalModuleKind, has_legacy_export_attr(crate.node.attrs), crate.span); @@ -824,7 +843,7 @@ fn Resolver(session: Session, lang_items: LanguageItems, xray_context: NoXray, current_trait_refs: None, - self_ident: syntax::parse::token::special_idents::self_, + self_ident: special_idents::self_, primitive_type_table: @PrimitiveTypeTable(session. parse_sess.interner), @@ -1111,8 +1130,12 @@ impl Resolver { let parent_link = self.get_parent_link(new_parent, ident); let def_id = { crate: 0, node: item.id }; - (*name_bindings).define_module(privacy, parent_link, - Some(def_id), legacy, sp); + (*name_bindings).define_module(privacy, + parent_link, + Some(def_id), + NormalModuleKind, + legacy, + sp); let new_parent = ModuleReducedGraphParent((*name_bindings).get_module()); @@ -1134,6 +1157,7 @@ impl Resolver { (*name_bindings).define_module(privacy, parent_link, Some(def_id), + ExternModuleKind, legacy, sp); @@ -1251,8 +1275,12 @@ impl Resolver { let parent_link = self.get_parent_link(new_parent, ident); let def_id = local_def(item.id); - name_bindings.define_module(privacy, parent_link, - Some(def_id), false, sp); + name_bindings.define_module(privacy, + parent_link, + Some(def_id), + TraitModuleKind, + false, + sp); let new_parent = ModuleReducedGraphParent( name_bindings.get_module()); @@ -1313,6 +1341,7 @@ impl Resolver { name_bindings.define_module(privacy, parent_link, Some(local_def(item.id)), + TraitModuleKind, false, sp); module_parent_opt = Some(ModuleReducedGraphParent( @@ -1579,6 +1608,7 @@ impl Resolver { (*child_name_bindings).define_module(privacy, parent_link, Some(def_id), + NormalModuleKind, false, view_item.span); self.build_reduced_graph_for_external_crate @@ -1637,7 +1667,9 @@ impl Resolver { let parent_module = self.get_module_from_parent(parent); let new_module = @Module(BlockParentLink(parent_module, block_id), - None, false); + None, + AnonymousModuleKind, + false); parent_module.anonymous_children.insert(block_id, new_module); new_parent = ModuleReducedGraphParent(new_module); } else { @@ -1671,6 +1703,7 @@ impl Resolver { child_name_bindings.define_module(Public, parent_link, Some(def_id), + NormalModuleKind, false, dummy_sp()); modules.insert(def_id, @@ -1802,6 +1835,7 @@ impl Resolver { (*child_name_bindings).define_module(Public, parent_link, None, + NormalModuleKind, false, dummy_sp()); } @@ -1815,6 +1849,7 @@ impl Resolver { (*child_name_bindings).define_module(Public, parent_link, None, + NormalModuleKind, false, dummy_sp()); } @@ -1885,6 +1920,7 @@ impl Resolver { Public, parent_link, Some(def), + NormalModuleKind, false, dummy_sp()); type_module = @@ -2733,23 +2769,13 @@ impl Resolver { self.idents_to_str((*module_path).get()), self.module_to_str(module_)); - // The first element of the module path must be in the current scope - // chain. - - let resolve_result = match use_lexical_scope { - DontUseLexicalScope => { - self.resolve_module_prefix(module_, module_path) - } - UseLexicalScope => { - let result = self.resolve_module_in_lexical_scope( - module_, - module_path.get_elt(0)); - ModulePrefixResult { result: result, prefix_len: 1 } - } - }; + // Resolve the module prefix, if any. + let module_prefix_result = self.resolve_module_prefix(module_, + module_path); let mut search_module; - match resolve_result.result { + let mut start_index; + match module_prefix_result { Failed => { self.session.span_err(span, ~"unresolved name"); return Failed; @@ -2759,21 +2785,61 @@ impl Resolver { bailing"); return Indeterminate; } - Success(resulting_module) => { - search_module = resulting_module; + Success(NoPrefixFound) => { + // There was no prefix, so we're considering the first element + // of the path. How we handle this depends on whether we were + // instructed to use lexical scope or not. + match use_lexical_scope { + DontUseLexicalScope => { + // This is a crate-relative path. We will start the + // resolution process at index zero. + search_module = self.graph_root.get_module(); + start_index = 0; + } + UseLexicalScope => { + // This is not a crate-relative path. We resolve the + // first component of the path in the current lexical + // scope and then proceed to resolve below that. + let result = self.resolve_module_in_lexical_scope( + module_, + module_path.get_elt(0)); + match result { + Failed => { + self.session.span_err(span, + ~"unresolved name"); + return Failed; + } + Indeterminate => { + debug!("(resolving module path for import) \ + indeterminate; bailing"); + return Indeterminate; + } + Success(containing_module) => { + search_module = containing_module; + start_index = 1; + } + } + } + } + } + Success(PrefixFound(containing_module, index)) => { + search_module = containing_module; + start_index = index; } } return self.resolve_module_path_from_root(search_module, module_path, - resolve_result.prefix_len, + start_index, xray, span); } fn resolve_item_in_lexical_scope(module_: @Module, name: ident, - namespace: Namespace) + namespace: Namespace, + search_through_modules: + SearchThroughModulesFlag) -> ResolveResult { debug!("(resolving item in lexical scope) resolving `%s` in \ @@ -2829,7 +2895,30 @@ impl Resolver { module"); return Failed; } - ModuleParentLink(parent_module_node, _) | + ModuleParentLink(parent_module_node, _) => { + match search_through_modules { + DontSearchThroughModules => { + match search_module.kind { + NormalModuleKind => { + // We stop the search here. + debug!("(resolving item in lexical \ + scope) unresolved module: not \ + searching through module \ + parents"); + return Failed; + } + ExternModuleKind | + TraitModuleKind | + AnonymousModuleKind => { + search_module = parent_module_node; + } + } + } + SearchThroughModules => { + search_module = parent_module_node; + } + } + } BlockParentLink(parent_module_node, _) => { search_module = parent_module_node; } @@ -2865,9 +2954,8 @@ impl Resolver { -> ResolveResult<@Module> { // If this module is an anonymous module, resolve the item in the // lexical scope. Otherwise, resolve the item from the crate root. - let resolve_result = self.resolve_item_in_lexical_scope(module_, - name, - TypeNS); + let resolve_result = self.resolve_item_in_lexical_scope( + module_, name, TypeNS, DontSearchThroughModules); match resolve_result { Success(target) => { match target.bindings.type_def { @@ -2905,46 +2993,102 @@ impl Resolver { } /** - * Resolves a "module prefix". A module prefix is one of (a) the name of a - * module; (b) "self::"; (c) some chain of "super::". + * Returns the nearest normal module parent of the given module. + */ + fn get_nearest_normal_module_parent(module_: @Module) -> Option<@Module> { + let mut module_ = module_; + loop { + match module_.parent_link { + NoParentLink => return None, + ModuleParentLink(new_module, _) | + BlockParentLink(new_module, _) => { + match new_module.kind { + NormalModuleKind => return Some(new_module), + ExternModuleKind | + TraitModuleKind | + AnonymousModuleKind => module_ = new_module, + } + } + } + } + } + + /** + * Returns the nearest normal module parent of the given module, or the + * module itself if it is a normal module. + */ + fn get_nearest_normal_module_parent_or_self(module_: @Module) -> @Module { + match module_.kind { + NormalModuleKind => return module_, + ExternModuleKind | TraitModuleKind | AnonymousModuleKind => { + match self.get_nearest_normal_module_parent(module_) { + None => module_, + Some(new_module) => new_module + } + } + } + } + + /** + * Resolves a "module prefix". A module prefix is one of (a) `self::`; + * (b) some chain of `super::`. */ fn resolve_module_prefix(module_: @Module, module_path: @DVec) - -> ModulePrefixResult { + -> ResolveResult { let interner = self.session.parse_sess.interner; - let mut containing_module = self.graph_root.get_module(); - let mut i = 0; - loop { - if *interner.get(module_path.get_elt(i)) == ~"self" { - containing_module = module_; - i += 1; - break; - } - if *interner.get(module_path.get_elt(i)) == ~"super" { - match containing_module.parent_link { - NoParentLink => { - return ModulePrefixResult { - result: Failed, - prefix_len: i - }; - } - BlockParentLink(new_module, _) | - ModuleParentLink(new_module, _) => { - containing_module = new_module; - } + // Start at the current module if we see `self` or `super`, or at the + // top of the crate otherwise. + let mut containing_module; + let mut i; + if *interner.get(module_path.get_elt(0)) == ~"self" { + containing_module = + self.get_nearest_normal_module_parent_or_self(module_); + i = 1; + } else if *interner.get(module_path.get_elt(0)) == ~"super" { + containing_module = + self.get_nearest_normal_module_parent_or_self(module_); + i = 0; // We'll handle `super` below. + } else { + return Success(NoPrefixFound); + } + + // Now loop through all the `super`s we find. + while i < module_path.len() && + *interner.get(module_path.get_elt(i)) == ~"super" { + debug!("(resolving module prefix) resolving `super` at %s", + self.module_to_str(containing_module)); + match self.get_nearest_normal_module_parent(containing_module) { + None => return Failed, + Some(new_module) => { + containing_module = new_module; + i += 1; } - i += 1; - } else { - break; } } + debug!("(resolving module prefix) finished resolving prefix at %s", + self.module_to_str(containing_module)); + + return Success(PrefixFound(containing_module, i)); + + /* + // If we reached the end, return the containing module. + if i == module_path.len() { + return ModulePrefixResult { + result: Success(containing_module), + prefix_len: i + }; + } + // Is the containing module the current module? If so, we allow // globs to be unresolved. let allow_globs = core::managed::ptr_eq(containing_module, module_); let name = module_path.get_elt(i); + i += 1; + let resolve_result = self.resolve_name_in_module(containing_module, name, TypeNS, @@ -2961,13 +3105,13 @@ impl Resolver { module!"); return ModulePrefixResult { result: Failed, - prefix_len: i + 1 + prefix_len: i }; } Some(module_def) => { return ModulePrefixResult { result: Success(module_def), - prefix_len: i + 1 + prefix_len: i }; } } @@ -2977,7 +3121,7 @@ impl Resolver { wasn't actually a module!"); return ModulePrefixResult { result: Failed, - prefix_len: i + 1 + prefix_len: i }; } } @@ -2987,17 +3131,18 @@ impl Resolver { bailing"); return ModulePrefixResult { result: Indeterminate, - prefix_len: i + 1 + prefix_len: i }; } Failed => { debug!("(resolving crate-relative module) failed to resolve"); return ModulePrefixResult { result: Failed, - prefix_len: i + 1 + prefix_len: i }; } } + */ } fn name_is_exported(module_: @Module, name: ident) -> bool { @@ -3120,7 +3265,8 @@ impl Resolver { debug!("(resolving one-level naming result) searching for module"); match self.resolve_item_in_lexical_scope(module_, source_name, - TypeNS) { + TypeNS, + SearchThroughModules) { Failed => { debug!("(resolving one-level renaming import) didn't find \ module result"); @@ -3146,8 +3292,9 @@ impl Resolver { } else { debug!("(resolving one-level naming result) searching for value"); match self.resolve_item_in_lexical_scope(module_, - source_name, - ValueNS) { + source_name, + ValueNS, + SearchThroughModules) { Failed => { debug!("(resolving one-level renaming import) didn't \ @@ -3168,8 +3315,9 @@ impl Resolver { debug!("(resolving one-level naming result) searching for type"); match self.resolve_item_in_lexical_scope(module_, - source_name, - TypeNS) { + source_name, + TypeNS, + SearchThroughModules) { Failed => { debug!("(resolving one-level renaming import) didn't \ @@ -3842,7 +3990,7 @@ impl Resolver { if !self.session.building_library && is_none(&self.session.main_fn) && - item.ident == syntax::parse::token::special_idents::main { + item.ident == special_idents::main { self.session.main_fn = Some((item.id, item.span)); } @@ -4582,7 +4730,8 @@ impl Resolver { -> BareIdentifierPatternResolution { match self.resolve_item_in_lexical_scope(self.current_module, name, - ValueNS) { + ValueNS, + SearchThroughModules) { Success(target) => { match target.bindings.value_def { None => { @@ -4619,10 +4768,11 @@ impl Resolver { * If `check_ribs` is true, checks the local definitions first; i.e. * doesn't skip straight to the containing module. */ - fn resolve_path(path: @path, namespace: Namespace, check_ribs: bool, + fn resolve_path(path: @path, + namespace: Namespace, + check_ribs: bool, visitor: ResolveVisitor) -> Option { - // First, resolve the types. for path.types.each |ty| { self.resolve_type(*ty, visitor); @@ -4636,8 +4786,8 @@ impl Resolver { if path.idents.len() > 1 { return self.resolve_module_relative_path(path, - self.xray_context, - namespace); + self.xray_context, + namespace); } return self.resolve_identifier(path.idents.last(), @@ -4808,10 +4958,10 @@ impl Resolver { let mut containing_module; match self.resolve_module_path_from_root(root_module, - module_path_idents, - 0, - xray, - path.span) { + module_path_idents, + 0, + xray, + path.span) { Failed => { self.session.span_err(path.span, @@ -4832,9 +4982,9 @@ impl Resolver { let name = path.idents.last(); match self.resolve_definition_of_name_in_module(containing_module, - name, - namespace, - xray) { + name, + namespace, + xray) { NoNameDefinition => { // We failed to resolve the name. Report an error. return None; @@ -4881,8 +5031,9 @@ impl Resolver { -> Option { // Check the items. match self.resolve_item_in_lexical_scope(self.current_module, - ident, - namespace) { + ident, + namespace, + SearchThroughModules) { Success(target) => { match (*target.bindings).def_for_namespace(namespace) { None => { @@ -4920,10 +5071,8 @@ impl Resolver { item_struct(class_def, _) => { for vec::each(class_def.fields) |field| { match field.node.kind { - syntax::ast::unnamed_field - => {}, - syntax::ast::named_field(ident, _, _) - => { + unnamed_field => {}, + named_field(ident, _, _) => { if str::eq_slice(self.session.str_of(ident), name) { return true @@ -5363,7 +5512,7 @@ impl Resolver { current_module = module_; } BlockParentLink(module_, _) => { - idents.push(syntax::parse::token::special_idents::opaque); + idents.push(special_idents::opaque); current_module = module_; } } diff --git a/src/librustc/middle/trans/alt.rs b/src/librustc/middle/trans/alt.rs index 7885a8ea0b601..a59bc5ef76059 100644 --- a/src/librustc/middle/trans/alt.rs +++ b/src/librustc/middle/trans/alt.rs @@ -145,13 +145,19 @@ use back::abi; use lib::llvm::llvm; use lib::llvm::{ValueRef, BasicBlockRef}; +use middle::const_eval; use middle::pat_util::*; use middle::resolve::DefMap; use middle::trans::base::*; use middle::trans::build::*; +use middle::trans::callee; use middle::trans::common::*; +use middle::trans::consts; +use middle::trans::controlflow; use middle::trans::datum::*; use middle::trans::expr::Dest; +use middle::trans::expr; +use middle::trans::glue; use middle::ty::{CopyValue, MoveValue, ReadValue}; use util::common::indenter; @@ -268,7 +274,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt { return var(v.disr_val, {enm: enum_id, var: var_id}); } } - core::util::unreachable(); + ::core::util::unreachable(); } ast::def_struct(_) => { return lit(UnitLikeStructLit(pat_id)); @@ -1407,7 +1413,7 @@ fn trans_alt_inner(scope_cx: block, // to an alloca() that will be the value for that local variable. // Note that we use the names because each binding will have many ids // from the various alternatives. - let bindings_map = std::map::HashMap(); + let bindings_map = HashMap(); do pat_bindings(tcx.def_map, arm.pats[0]) |bm, p_id, s, path| { let ident = path_to_ident(path); let variable_ty = node_id_type(bcx, p_id); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index a65f6668cd358..668edd95f6257 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -34,12 +34,29 @@ use driver::session::Session; use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef}; use lib::llvm::{True, False}; use lib::llvm::{llvm, mk_target_data, mk_type_names}; +use lib; use metadata::common::link_meta; use metadata::{csearch, cstore, decoder, encoder}; +use middle::astencode; use middle::pat_util::*; +use middle::resolve; +use middle::trans::alt; use middle::trans::build::*; +use middle::trans::callee; use middle::trans::common::*; +use middle::trans::consts; +use middle::trans::controlflow; +use middle::trans::datum; +use middle::trans::debuginfo; +use middle::trans::expr; +use middle::trans::foreign; +use middle::trans::glue; +use middle::trans::inline; +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 util::common::indenter; use util::common::is_main_name; diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index eb0d86b6d045b..4c78c60f5b6f0 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -19,9 +19,15 @@ use lib::llvm::ValueRef; use middle::trans::base::{get_item_val, trans_external_path}; use middle::trans::build::*; +use middle::trans::callee; +use middle::trans::closure; use middle::trans::common::{block, node_id_type_params}; use middle::trans::datum::*; use middle::trans::datum::Datum; +use middle::trans::inline; +use middle::trans::meth; +use middle::trans::monomorphize; +use middle::typeck; use util::common::indenter; use syntax::ast; diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 5110bc261f7a9..26ba1869c27e8 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -13,10 +13,14 @@ 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 middle::capture; use middle::trans::base::*; use middle::trans::build::*; +use middle::trans::callee; use middle::trans::common::*; use middle::trans::datum::{Datum, INIT, ByRef, ByValue, FromLvalue}; +use middle::trans::expr; +use middle::trans::glue; use middle::trans::type_of::*; use util::ppaux::ty_to_str; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 25cd169c403f2..c966924ea6ae0 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -13,26 +13,42 @@ */ -use libc::c_uint; -use vec::raw::to_ptr; -use std::map::{HashMap,Set}; -use syntax::{ast, ast_map}; -use driver::session; -use session::Session; -use middle::ty; use back::{link, abi, upcall}; -use syntax::codemap::span; -use lib::llvm::{llvm, target_data, type_names, associate_type, - name_has_type}; +use driver::session; +use driver::session::Session; use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef, BuilderRef}; use lib::llvm::{True, False, Bool}; -use metadata::{csearch}; +use lib::llvm::{llvm, target_data, type_names, associate_type, name_has_type}; +use lib; use metadata::common::link_meta; +use metadata::{csearch}; +use middle::astencode; +use middle::resolve; +use middle::trans::base; +use middle::trans::build; +use middle::trans::callee; +use middle::trans::datum; +use middle::trans::debuginfo; +use middle::trans::glue; +use middle::trans::meth; +use middle::trans::reachable; +use middle::trans::shape; +use middle::trans::type_of; +use middle::trans::type_use; +use middle::ty; +use middle::typeck; +use util::ppaux::{expr_repr, ty_to_str}; + +use core::libc::c_uint; +use core::to_bytes; +use core::vec::raw::to_ptr; +use std::map::{HashMap, Set}; +use syntax::ast::ident; use syntax::ast_map::path; -use util::ppaux::ty_to_str; -use syntax::print::pprust::expr_to_str; +use syntax::codemap::span; use syntax::parse::token::ident_interner; -use syntax::ast::ident; +use syntax::print::pprust::expr_to_str; +use syntax::{ast, ast_map}; type namegen = fn@(~str) -> ident; fn new_namegen(intr: @ident_interner) -> namegen { @@ -633,7 +649,7 @@ impl block { } fn expr_to_str(e: @ast::expr) -> ~str { - util::ppaux::expr_repr(self.tcx(), e) + expr_repr(self.tcx(), e) } fn expr_is_lval(e: @ast::expr) -> bool { @@ -1196,7 +1212,7 @@ impl mono_param_id : to_bytes::IterBytes { } } -impl mono_id_ : core::to_bytes::IterBytes { +impl mono_id_ : to_bytes::IterBytes { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 355e78014805d..94da557d39b2a 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -8,8 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::const_eval; use middle::trans::base::get_insn_ctxt; use middle::trans::common::*; +use middle::trans::consts; +use middle::trans::expr; +use middle::ty; use syntax::{ast, ast_util, codemap, ast_map}; diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 2a9cece231b73..a46dbd60d28cb 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -10,6 +10,7 @@ use lib::llvm::ValueRef; use middle::trans::base::*; +use middle::trans::callee; use middle::trans::common::*; use middle::trans::datum::*; diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index e303b3611c577..c04e16ea0a0b9 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -99,9 +99,14 @@ use lib::llvm::ValueRef; use middle::trans::base::*; use middle::trans::build::*; use middle::trans::common::*; +use middle::trans::common; +use middle::trans::tvec; +use middle::typeck; use util::common::indenter; use util::ppaux::ty_to_str; +use syntax::parse::token::special_idents; + enum CopyAction { INIT, DROP_EXISTING @@ -669,7 +674,7 @@ impl Datum { // Check whether this struct is a newtype struct. let fields = ty::struct_fields(ccx.tcx, did, substs); if fields.len() != 1 || fields[0].ident != - syntax::parse::token::special_idents::unnamed_field { + special_idents::unnamed_field { return None; } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index b255b47bab30b..0769bd8ea1359 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -15,6 +15,9 @@ use middle::pat_util::*; use middle::trans::base; use middle::trans::build::B; use middle::trans::common::*; +use middle::trans::shape; +use middle::trans::type_of; +use middle::trans; use middle::ty; use util::ppaux::ty_to_str; diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 662469655332c..d3a1772a6b0f8 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -112,10 +112,18 @@ lvalues are *never* stored by value. */ use lib::llvm::ValueRef; +use middle::resolve; use middle::trans::base::*; use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg}; +use middle::trans::callee; +use middle::trans::closure; use middle::trans::common::*; +use middle::trans::consts; +use middle::trans::controlflow; use middle::trans::datum::*; +use middle::trans::machine; +use middle::trans::meth; +use middle::trans::tvec; use middle::ty::MoveValue; use middle::ty::struct_mutable_fields; use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn}; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 38c3a4f7cb358..a6883728a1a4a 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -17,21 +17,26 @@ use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg}; use lib::llvm::{Struct, Array, ModuleRef, CallConv, Attribute}; use lib::llvm::{StructRetAttribute, ByValAttribute}; use lib::llvm::{llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double}; +use lib; 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}; +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::{FnTyBase, FnMeta, FnSig}; use util::ppaux::ty_to_str; use core::libc::c_uint; -use std::map::HashMap; use syntax::codemap::span; use syntax::{ast, ast_util}; use syntax::{attr, ast_map}; +use syntax::parse::token::special_idents; export link_name, trans_foreign_mod, register_foreign_fn, trans_foreign_fn, trans_intrinsic; @@ -1216,7 +1221,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let t = ty::node_id_to_type(ccx.tcx, id); let ps = link::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name( - syntax::parse::token::special_idents::clownshoe_abi + special_idents::clownshoe_abi ))); let llty = type_of_fn_from_ty(ccx, t); let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty); @@ -1255,7 +1260,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let shim_name = link::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name( - syntax::parse::token::special_idents::clownshoe_stack_shim + special_idents::clownshoe_stack_shim ))); return build_shim_fn_(ccx, shim_name, llrustfn, tys, lib::llvm::CCallConv, diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index a42dee615e4b5..1b39d16ecd350 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -14,9 +14,14 @@ use lib::llvm::{ValueRef, TypeRef}; use middle::trans::base::*; +use middle::trans::callee; +use middle::trans::closure; use middle::trans::common::*; use middle::trans::build::*; +use middle::trans::reflect; +use middle::trans::tvec; use middle::trans::type_of::type_of; +use middle::trans::uniq; fn trans_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt("trans_free"); diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs index 6f5aa792c4748..25c4b581d2b94 100644 --- a/src/librustc/middle/trans/inline.rs +++ b/src/librustc/middle/trans/inline.rs @@ -8,10 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::astencode; use middle::trans::base::{get_insn_ctxt}; use middle::trans::base::{impl_owned_self, impl_self, no_self}; use middle::trans::base::{trans_item, get_item_val, self_arg, trans_fn}; use middle::trans::common::*; +use middle::trans::common; +use middle::trans::inline; +use middle::trans::monomorphize; use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index 1c6e500d80682..b057378205463 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -11,6 +11,10 @@ // Information concerning the machine representation of various types. use middle::trans::common::*; +use middle::trans::type_of; +use middle::ty; + +use syntax::parse::token::special_idents; // Creates a simpler, size-equivalent type. The resulting type is guaranteed // to have (a) the same size as the type that was passed in; (b) to be non- @@ -39,7 +43,7 @@ pub fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { ty::ty_struct(did, ref substs) => { let simpl_fields = (if ty::ty_dtor(tcx, did).is_present() { // remember the drop flag - ~[{ident: syntax::parse::token::special_idents::dtor, + ~[{ident: special_idents::dtor, mt: {ty: ty::mk_u8(tcx), mutbl: ast::m_mutbl}}] } else { ~[] }) + diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 1dd3ae0ef0e1b..c5f7fc0238473 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -9,16 +9,24 @@ // except according to those terms. use back::{link, abi}; +use driver; use lib::llvm::llvm::LLVMGetParam; use lib::llvm::llvm; use lib::llvm::{ValueRef, TypeRef}; +use lib; use metadata::csearch; use middle::trans::base::*; use middle::trans::build::*; use middle::trans::callee::*; +use middle::trans::callee; use middle::trans::common::*; use middle::trans::expr::{SaveIn, Ignore}; +use middle::trans::expr; +use middle::trans::glue; +use middle::trans::inline; +use middle::trans::monomorphize; use middle::trans::type_of::*; +use middle::typeck; use util::ppaux::{ty_to_str, tys_to_str}; use core::libc::c_uint; diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 9d662f875510c..77256fd5fb7b7 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -14,9 +14,18 @@ use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint}; use middle::trans::base::{trans_enum_variant, trans_struct_dtor}; use middle::trans::base::{trans_fn, impl_self, decl_internal_cdecl_fn}; use middle::trans::base::{trans_item, get_item_val, no_self, self_arg}; +use middle::trans::base; use middle::trans::common::*; +use middle::trans::datum; +use middle::trans::foreign; +use middle::trans::machine; +use middle::trans::meth; +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::{FnTyBase, FnMeta, FnSig}; +use middle::typeck; use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index fbaa038b4cc9a..ad127a72cdf04 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -15,17 +15,21 @@ // makes all other generics or inline functions that it references // reachable as well. +use driver::session::*; +use middle::resolve; +use middle::ty; +use middle::typeck; + +use std::map::HashMap; use syntax::ast::*; -use syntax::{visit, ast_util, ast_map}; use syntax::ast_util::def_id_of_def; use syntax::attr; use syntax::print::pprust::expr_to_str; -use std::map::HashMap; -use driver::session::*; +use syntax::{visit, ast_util, ast_map}; export map, find_reachable; -type map = std::map::HashMap; +type map = HashMap; type ctx = {exp_map2: resolve::ExportMap2, tcx: ty::ctxt, @@ -34,7 +38,7 @@ type ctx = {exp_map2: resolve::ExportMap2, fn find_reachable(crate_mod: _mod, exp_map2: resolve::ExportMap2, tcx: ty::ctxt, method_map: typeck::method_map) -> map { - let rmap = std::map::HashMap(); + let rmap = HashMap(); let cx = {exp_map2: exp_map2, tcx: tcx, method_map: method_map, rmap: rmap}; traverse_public_mod(cx, ast::crate_node_id, crate_mod); diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index d15a9c101b955..7f770899c5085 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -13,9 +13,13 @@ use lib::llvm::{TypeRef, ValueRef}; use middle::trans::base::*; use middle::trans::build::*; use middle::trans::callee::{ArgVals, DontAutorefArg}; +use middle::trans::callee; use middle::trans::common::*; use middle::trans::datum::*; use middle::trans::expr::SaveIn; +use middle::trans::glue; +use middle::trans::meth; +use middle::trans::shape; use middle::trans::type_of::*; use util::ppaux::ty_to_str; diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs index 51c3cb9362f39..c6b8457bb958a 100644 --- a/src/librustc/middle/trans/shape.rs +++ b/src/librustc/middle/trans/shape.rs @@ -17,12 +17,14 @@ use lib::llvm::{True, False, ModuleRef, TypeRef, ValueRef}; use middle::trans::base; use middle::trans::common::*; use middle::trans::machine::*; +use middle::trans; use middle::ty::field; use middle::ty; use util::ppaux::ty_to_str; use core::dvec::DVec; use core::option::is_some; +use core::vec; use std::map::HashMap; use syntax::ast; use syntax::ast_util::dummy_sp; @@ -36,13 +38,13 @@ type ctxt = {mut next_tag_id: u16, pad: u16, pad2: u32}; fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) -> ValueRef { let llglobal = do str::as_c_str(name) |buf| { - lib::llvm::llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf) + llvm::LLVMAddGlobal(ccx.llmod, val_ty(llval), buf) }; - lib::llvm::llvm::LLVMSetInitializer(llglobal, llval); - lib::llvm::llvm::LLVMSetGlobalConstant(llglobal, True); + llvm::LLVMSetInitializer(llglobal, llval); + llvm::LLVMSetGlobalConstant(llglobal, True); if internal { - lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage); + ::lib::llvm::SetLinkage(llglobal, ::lib::llvm::InternalLinkage); } return llglobal; @@ -51,7 +53,7 @@ fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) -> fn mk_ctxt(llmod: ModuleRef) -> ctxt { let llshapetablesty = trans::common::T_named_struct(~"shapes"); let _llshapetables = str::as_c_str(~"shapes", |buf| { - lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf) + llvm::LLVMAddGlobal(llmod, llshapetablesty, buf) }); return {mut next_tag_id: 0u16, pad: 0u16, pad2: 0u32}; diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 2eaf15818d89f..b6df2486af2cf 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -14,7 +14,11 @@ use middle::trans::build::*; 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; +use middle::trans::type_of; +use middle::ty; use util::common::indenter; use util::ppaux::ty_to_str; diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index f146d556a9d9a..85830ca927709 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -11,6 +11,9 @@ use lib::llvm::llvm; use lib::llvm::{TypeRef}; use middle::trans::common::*; +use middle::trans::common; +use middle::trans::expr; +use util::ppaux; use std::map::HashMap; use syntax::ast; @@ -258,7 +261,7 @@ fn llvm_type_name(cx: @crate_ctxt, return fmt!( "%s %s[#%d]", name, - util::ppaux::parameterized( + ppaux::parameterized( cx.tcx, ty::item_path_str(cx.tcx, did), None, diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 08ee59f5d89fa..46d7cd26d8438 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -28,8 +28,11 @@ // invasive.) use metadata::csearch; +use middle::freevars; use middle::trans::common::*; +use middle::trans::inline; +use core::vec; use std::list::{List, Cons, Nil}; use std::list; use std::map::HashMap; diff --git a/src/librustc/middle/trans/uniq.rs b/src/librustc/middle/trans/uniq.rs index 30d47d60e5892..c4490dd86f35a 100644 --- a/src/librustc/middle/trans/uniq.rs +++ b/src/librustc/middle/trans/uniq.rs @@ -8,11 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use back; use lib::llvm::ValueRef; use middle::trans::base::*; use middle::trans::build::*; use middle::trans::common::*; use middle::trans::datum::immediate_rvalue; +use middle::trans::datum; +use middle::trans::glue; use syntax::ast; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 69a86a3e4edb8..f7c8b939fa395 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -10,25 +10,34 @@ #[warn(deprecated_pattern)]; -use core::dvec::DVec; -use std::{map, smallintmap}; -use result::Result; -use std::map::HashMap; use driver::session; -use session::Session; -use syntax::{ast, ast_map}; -use syntax::ast_util; -use syntax::ast_util::{is_local, local_def}; -use syntax::codemap::span; use metadata::csearch; -use util::ppaux::{region_to_str, explain_region, vstore_to_str, - note_and_explain_region, bound_region_to_str}; -use middle::lint; +use metadata; +use middle::const_eval; +use middle::freevars; use middle::lint::{get_lint_level, allow}; +use middle::lint; +use middle::resolve::{Impl, MethodInfo}; +use middle::resolve; +use middle::ty; +use middle::typeck; +use middle; +use session::Session; +use util::ppaux::{note_and_explain_region, bound_region_to_str}; +use util::ppaux::{region_to_str, explain_region, vstore_to_str}; +use util::ppaux::{ty_to_str, proto_ty_to_str, tys_to_str}; + +use core::dvec::DVec; +use core::result::Result; +use std::map::HashMap; +use std::{map, smallintmap}; use syntax::ast::*; +use syntax::ast_util::{is_local, local_def}; +use syntax::ast_util; +use syntax::codemap::span; use syntax::print::pprust::*; -use util::ppaux::{ty_to_str, proto_ty_to_str, tys_to_str}; -use middle::resolve::{Impl, MethodInfo}; +use syntax::{ast, ast_map}; +use syntax; export ProvidedMethodSource; export ProvidedMethodInfo; @@ -1542,7 +1551,8 @@ fn substs_is_noop(substs: &substs) -> bool { fn substs_to_str(cx: ctxt, substs: &substs) -> ~str { fmt!("substs(self_r=%s, self_ty=%s, tps=%?)", substs.self_r.map_default(~"none", |r| region_to_str(cx, *r)), - substs.self_ty.map_default(~"none", |t| ty_to_str(cx, *t)), + substs.self_ty.map_default(~"none", + |t| ::util::ppaux::ty_to_str(cx, *t)), tys_to_str(cx, substs.tps)) } @@ -1552,7 +1562,7 @@ fn param_bound_to_str(cx: ctxt, pb: ¶m_bound) -> ~str { bound_durable => ~"durable", bound_owned => ~"owned", bound_const => ~"const", - bound_trait(t) => ty_to_str(cx, t) + bound_trait(t) => ::util::ppaux::ty_to_str(cx, t) } } @@ -1566,11 +1576,11 @@ fn subst(cx: ctxt, debug!("subst(substs=%s, typ=%s)", substs_to_str(cx, substs), - ty_to_str(cx, typ)); + ::util::ppaux::ty_to_str(cx, typ)); if substs_is_noop(substs) { return typ; } let r = do_subst(cx, substs, typ); - debug!(" r = %s", ty_to_str(cx, r)); + debug!(" r = %s", ::util::ppaux::ty_to_str(cx, r)); return r; fn do_subst(cx: ctxt, @@ -1588,7 +1598,8 @@ fn subst(cx: ctxt, re_bound(br_self) => substs.self_r.expect( fmt!("ty::subst: \ Reference to self region when given substs with no \ - self region, ty = %s", ty_to_str(cx, typ))), + self region, ty = %s", + ::util::ppaux::ty_to_str(cx, typ))), _ => r }, |t| do_subst(cx, substs, t), @@ -2351,8 +2362,8 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { fn type_requires(cx: ctxt, seen: @mut ~[def_id], r_ty: t, ty: t) -> bool { debug!("type_requires(%s, %s)?", - ty_to_str(cx, r_ty), - ty_to_str(cx, ty)); + ::util::ppaux::ty_to_str(cx, r_ty), + ::util::ppaux::ty_to_str(cx, ty)); let r = { get(r_ty).sty == get(ty).sty || @@ -2360,8 +2371,8 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { }; debug!("type_requires(%s, %s)? %b", - ty_to_str(cx, r_ty), - ty_to_str(cx, ty), + ::util::ppaux::ty_to_str(cx, r_ty), + ::util::ppaux::ty_to_str(cx, ty), r); return r; } @@ -2369,8 +2380,8 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { fn subtypes_require(cx: ctxt, seen: @mut ~[def_id], r_ty: t, ty: t) -> bool { debug!("subtypes_require(%s, %s)?", - ty_to_str(cx, r_ty), - ty_to_str(cx, ty)); + ::util::ppaux::ty_to_str(cx, r_ty), + ::util::ppaux::ty_to_str(cx, ty)); let r = match get(ty).sty { ty_nil | @@ -2447,8 +2458,8 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { }; debug!("subtypes_require(%s, %s)? %b", - ty_to_str(cx, r_ty), - ty_to_str(cx, ty), + ::util::ppaux::ty_to_str(cx, r_ty), + ::util::ppaux::ty_to_str(cx, ty), r); return r; @@ -2461,7 +2472,8 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { fn type_structurally_contains(cx: ctxt, ty: t, test: fn(x: &sty) -> bool) -> bool { let sty = &get(ty).sty; - debug!("type_structurally_contains: %s", ty_to_str(cx, ty)); + debug!("type_structurally_contains: %s", + ::util::ppaux::ty_to_str(cx, ty)); if test(sty) { return true; } match *sty { ty_enum(did, ref substs) => { @@ -3260,8 +3272,8 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) { tcx.sess.span_fatal (sp, ~"type inference failed because I \ could not find a type\n that's both of the form " - + ty_to_str(tcx, mk_var(tcx, vid)) + - ~" and of the form " + ty_to_str(tcx, rt) + + + ::util::ppaux::ty_to_str(tcx, mk_var(tcx, vid)) + + ~" and of the form " + ::util::ppaux::ty_to_str(tcx, rt) + ~" - such a type would have to be infinitely large."); } } @@ -3343,7 +3355,7 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_opaque_closure_ptr(_) => { - ty_to_str(cx, t) + ::util::ppaux::ty_to_str(cx, t) } ty_enum(id, _) => fmt!("enum %s", item_path_str(cx, id)), diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 4c44642b325a1..9adfa8a17c799 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -53,11 +53,15 @@ */ use middle::ty::{FnTyBase, FnMeta, FnSig}; +use middle::ty; use middle::typeck::check::fn_ctxt; +use middle::typeck::collect; use middle::typeck::rscope::{anon_rscope, binding_rscope, empty_rscope}; use middle::typeck::rscope::{in_anon_rscope, in_binding_rscope}; use middle::typeck::rscope::{region_scope, type_rscope}; +use syntax::ast; + pub trait ast_conv { fn tcx() -> ty::ctxt; fn ccx() -> @crate_ctxt; diff --git a/src/librustc/middle/typeck/check/alt.rs b/src/librustc/middle/typeck/check/alt.rs index 9432ca186f94e..c8d0bfb697ca2 100644 --- a/src/librustc/middle/typeck/check/alt.rs +++ b/src/librustc/middle/typeck/check/alt.rs @@ -10,8 +10,13 @@ use middle::pat_util::{pat_is_binding, pat_is_const}; use middle::pat_util::{pat_is_variant_or_struct}; +use middle::ty; +use middle::typeck::check::demand; +use std::map::HashMap; +use syntax::ast; use syntax::ast_util::walk_pat; +use syntax::ast_util; use syntax::print::pprust; fn check_alt(fcx: @fn_ctxt, @@ -195,13 +200,13 @@ fn check_struct_pat_fields(pcx: pat_ctxt, let tcx = pcx.fcx.ccx.tcx; // Index the class fields. - let field_map = std::map::HashMap(); + let field_map = HashMap(); for class_fields.eachi |i, class_field| { field_map.insert(class_field.ident, i); } // Typecheck each field. - let found_fields = std::map::HashMap(); + let found_fields = HashMap(); for fields.each |field| { match field_map.find(field.ident) { Some(index) => { diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index 89726e22283d9..6b5e998d14689 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -8,7 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::check::fn_ctxt; +use middle::typeck::infer; + +use syntax::ast; // Requires that the two types unify, and prints an error message if they // don't. diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index c61ad39e33302..9a3fd5a754976 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -80,14 +80,19 @@ obtained the type `Foo`, we would never match this method. */ use middle::resolve::{Impl, MethodInfo}; +use middle::resolve; use middle::ty::*; +use middle::ty; use middle::typeck::check; +use middle::typeck::check::vtable; use middle::typeck::coherence::get_base_type_def_id; +use middle::typeck::infer; use core::dvec::DVec; use syntax::ast::{def_id, sty_by_ref, sty_value, sty_region, sty_box}; use syntax::ast::{sty_uniq, sty_static, node_id, by_copy, by_ref}; use syntax::ast::{m_const, m_mutbl, m_imm}; +use syntax::ast; use syntax::ast_map; use syntax::ast_map::node_id_to_str; use syntax::ast_util::dummy_sp; diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 8af091fdb9ad0..0b192c77bf1bb 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -76,24 +76,38 @@ type parameter). */ +use middle::capture; +use middle::const_eval; +use middle::pat_util; use middle::ty::{TyVid, vid, FnTyBase, FnMeta, FnSig, VariantInfo_}; +use middle::ty; use middle::typeck::astconv::{ast_conv, ast_path_to_ty}; use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty}; +use middle::typeck::astconv; use middle::typeck::check::method::TransformTypeNormally; use middle::typeck::check::regionmanip::replace_bound_regions_in_fn_ty; use middle::typeck::check::vtable::{LocationInfo, VtableContext}; use middle::typeck::infer::{resolve_type, force_tvar}; +use middle::typeck::infer; use middle::typeck::rscope::{anon_rscope, binding_rscope, bound_self_region}; use middle::typeck::rscope::{empty_rscope, in_anon_rscope}; use middle::typeck::rscope::{in_binding_rscope, region_scope, type_rscope}; +use middle::typeck::rscope; use util::ppaux; use core::result::{Result, Ok, Err}; use std::map::HashMap; +use std::map; use syntax::ast::ty_i; +use syntax::ast; +use syntax::ast_map; use syntax::ast_util::{is_local, visibility_to_privacy, Private, Public}; +use syntax::ast_util; +use syntax::codemap; use syntax::parse::token::special_idents; use syntax::print::pprust; +use syntax::visit; +use syntax; export alt; export vtable; @@ -1688,7 +1702,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn check_struct_constructor(fcx: @fn_ctxt, id: ast::node_id, - span: syntax::codemap::span, + span: codemap::span, class_id: ast::def_id, fields: ~[ast::field], base_expr: Option<@ast::expr>) -> bool { @@ -1769,7 +1783,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn check_struct_enum_variant(fcx: @fn_ctxt, id: ast::node_id, - span: syntax::codemap::span, + span: codemap::span, enum_id: ast::def_id, variant_id: ast::def_id, fields: ~[ast::field]) -> bool { @@ -2997,7 +3011,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { (1u, ~[], ty::mk_nil_ptr(tcx)) } ~"visit_tydesc" => { - let tydesc_name = syntax::parse::token::special_idents::tydesc; + let tydesc_name = special_idents::tydesc; let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor"); assert tcx.intrinsic_defs.contains_key(tydesc_name); assert ccx.tcx.intrinsic_defs.contains_key(ty_visitor_name); diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 5467eae82662e..b59772d75d2cb 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -32,12 +32,15 @@ use middle::pat_util::pat_bindings; use middle::ty::{encl_region, re_scope}; use middle::ty::{ty_fn_proto, vstore_box, vstore_fixed, vstore_slice}; use middle::ty::{vstore_uniq}; +use middle::ty; use middle::typeck::infer::{resolve_and_force_all_but_regions, fres}; use util::ppaux::{note_and_explain_region, ty_to_str}; use syntax::ast::{ProtoBare, ProtoBox, ProtoUniq, ProtoBorrowed}; use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar}; +use syntax::ast; use syntax::print::pprust; +use syntax::visit; enum rcx { rcx_({fcx: @fn_ctxt, mut errors_reported: uint}) } type rvt = visit::vt<@rcx>; diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index 0bcb032d8259c..dfba93f947f37 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -11,8 +11,10 @@ // #[warn(deprecated_mode)]; // #[warn(deprecated_pattern)]; +use middle::ty; use util::ppaux; +use syntax::ast; use syntax::print::pprust::{expr_to_str}; // Helper functions related to manipulating region types. diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 5751a46276064..85bd5a306caa3 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -8,15 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::resolve; +use middle::ty; use middle::typeck::check::{fn_ctxt, impl_self_ty}; use middle::typeck::infer::{fixup_err_to_str, infer_ctxt}; use middle::typeck::infer::{resolve_and_force_all_but_regions, resolve_type}; +use middle::typeck::infer; use util::common::indenter; use util::ppaux; use result::{Result, Ok, Err}; +use syntax::ast; +use syntax::ast_util; use syntax::codemap::span; use syntax::print::pprust; +use syntax::visit; // vtable resolution looks for places where trait bounds are // subsituted in and figures out which vtable is used. There is some diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index dd3f240f34343..8059ecd55b56f 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -12,12 +12,17 @@ // unresolved type variables and replaces "ty_var" types with their // substitutions. +use middle::pat_util; +use middle::ty; use middle::typeck::check::{fn_ctxt, lookup_local}; use middle::typeck::infer::{force_all, resolve_all, resolve_region}; use middle::typeck::infer::{resolve_type}; +use middle::typeck::infer; use util::ppaux; -use result::{Result, Ok, Err}; +use core::result::{Result, Ok, Err}; +use syntax::ast; +use syntax::visit; export resolve_type_vars_in_fn; export resolve_type_vars_in_expr; diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 15edea5213934..a7ccd29ac4bc7 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -14,8 +14,10 @@ // has at most one implementation for each type. Then we build a mapping from // each trait in the system to its implementations. +use driver; use metadata::csearch::{ProvidedTraitMethodInfo, each_path, get_impl_traits}; use metadata::csearch::{get_impls_for_mod}; +use metadata::csearch; use metadata::cstore::{CStore, iter_crate_data}; use metadata::decoder::{dl_def, dl_field, dl_impl}; use middle::resolve::{Impl, MethodInfo}; @@ -27,6 +29,7 @@ use middle::ty::{ty_rec, ty_rptr, ty_struct, ty_trait, ty_tup, ty_uint}; use middle::ty::{ty_param, ty_self, ty_type, ty_opaque_box, ty_uniq}; use middle::ty::{ty_opaque_closure_ptr, ty_unboxed_vec, type_kind_ext}; use middle::ty::{type_is_ty_var}; +use middle::ty; use middle::typeck::infer::{infer_ctxt, can_mk_subty}; use middle::typeck::infer::{new_infer_ctxt, resolve_ivar}; use middle::typeck::infer::{resolve_nested_tvar, resolve_type}; @@ -35,10 +38,13 @@ use syntax::ast::{item, item_struct, item_const, item_enum, item_fn}; use syntax::ast::{item_foreign_mod, item_impl, item_mac, item_mod}; use syntax::ast::{item_trait, item_ty, local_crate, method, node_id}; use syntax::ast::{trait_ref}; +use syntax::ast; use syntax::ast_map::node_item; +use syntax::ast_map; use syntax::ast_util::{def_id_of_def, dummy_sp}; use syntax::attr; use syntax::codemap::span; +use syntax::parse; use syntax::visit::{default_simple_visitor, default_visitor}; use syntax::visit::{mk_simple_visitor, mk_vt, visit_crate, visit_item}; use syntax::visit::{visit_mod}; @@ -307,7 +313,7 @@ impl CoherenceChecker { for self.each_provided_trait_method(trait_did) |trait_method| { // Synthesize an ID. let tcx = self.crate_context.tcx; - let new_id = syntax::parse::next_node_id(tcx.sess.parse_sess); + let new_id = parse::next_node_id(tcx.sess.parse_sess); let new_did = local_def(new_id); // XXX: Perform substitutions. @@ -883,7 +889,7 @@ impl CoherenceChecker { // Create a new def ID for this provided method. let parse_sess = &self.crate_context.tcx.sess.parse_sess; - let new_did = local_def(syntax::parse::next_node_id(*parse_sess)); + let new_did = local_def(parse::next_node_id(*parse_sess)); let provided_method_info = @ProvidedMethodInfo { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index b4ba9c3d65447..0b484ef63d8a7 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -30,15 +30,25 @@ are represented as `ty_param()` instances. */ +use metadata::csearch; use middle::ty::{FnMeta, FnSig, FnTyBase, InstantiatedTraitRef}; +use middle::ty; use middle::typeck::astconv::{ast_conv, ty_of_fn_decl, ty_of_arg}; use middle::typeck::astconv::{ast_ty_to_ty}; +use middle::typeck::astconv; +use middle::typeck::infer; use middle::typeck::rscope::*; +use middle::typeck::rscope; use util::common::pluralize; use util::ppaux; use util::ppaux::bound_to_str; +use syntax::ast; +use syntax::ast_map; use syntax::ast_util::trait_method_to_ty_method; +use syntax::ast_util; +use syntax::codemap; +use syntax::visit; fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { @@ -47,7 +57,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { for crate.node.module.items.each |crate_item| { if crate_item.ident - == syntax::parse::token::special_idents::intrinsic { + == ::syntax::parse::token::special_idents::intrinsic { match crate_item.node { ast::item_mod(m) => { diff --git a/src/librustc/middle/typeck/infer/assignment.rs b/src/librustc/middle/typeck/infer/assignment.rs index 1abe2156a1ebb..da68342a5da76 100644 --- a/src/librustc/middle/typeck/infer/assignment.rs +++ b/src/librustc/middle/typeck/infer/assignment.rs @@ -58,9 +58,12 @@ // A. But this upper-bound might be stricter than what is truly // needed. +use middle::ty; use middle::typeck::infer::combine::combine_fields; use middle::typeck::infer::to_str::ToStr; +use syntax::ast; + fn to_ares(+c: cres) -> ares { match c { Ok(_) => Ok(None), diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index da66ecd922b68..1c5551296f274 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -54,10 +54,13 @@ // terms of error reporting, although we do not do that properly right // now. +use middle::ty; use middle::ty::{FnTyBase, FnMeta, FnSig}; +use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::ToStr; use syntax::ast::Onceness; +use syntax::ast; fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export. diff --git a/src/librustc/middle/typeck/infer/floating.rs b/src/librustc/middle/typeck/infer/floating.rs index 9537325c097f8..59e661086a666 100644 --- a/src/librustc/middle/typeck/infer/floating.rs +++ b/src/librustc/middle/typeck/infer/floating.rs @@ -14,9 +14,12 @@ Code related to floating-point type inference. */ +use middle::ty; use middle::ty::ty_float; use middle::typeck::infer::to_str::ToStr; +use syntax::ast; + // Bitvector to represent sets of floating-point types. pub enum float_ty_set = uint; diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index b6e179d27a91b..6a6a817e97e83 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::infer::combine::*; use middle::typeck::infer::lattice::*; +use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::ToStr; use syntax::ast::{Many, Once}; diff --git a/src/librustc/middle/typeck/infer/integral.rs b/src/librustc/middle/typeck/infer/integral.rs index f3e5e1ac73e62..857b66966eb91 100644 --- a/src/librustc/middle/typeck/infer/integral.rs +++ b/src/librustc/middle/typeck/infer/integral.rs @@ -14,8 +14,11 @@ Code related to integral type inference. */ +use middle::ty; use middle::typeck::infer::to_str::ToStr; +use syntax::ast; + // Bitvector to represent sets of integral types enum int_ty_set = uint; diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index b47dd2064522e..c8d63ea796e6e 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::infer::combine::*; use middle::typeck::infer::unify::*; use middle::typeck::infer::to_str::ToStr; diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index cfb93e93a65ba..7a402e2218d94 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -8,10 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::infer::combine::*; use middle::typeck::infer::lattice::*; +use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::ToStr; +use std::list; use syntax::ast::{Many, Once}; fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export. diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 99d636559dbc2..9653bfffc83f5 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -454,6 +454,8 @@ write it) #[warn(deprecated_pattern)]; use middle::region::is_subregion_of; +use middle::region; +use middle::ty; use middle::ty::{Region, RegionVid, re_static, re_infer, re_free, re_bound}; use middle::ty::{re_scope, ReVar, ReSkolemized}; use middle::typeck::infer::to_str::ToStr; diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 91689ff06ddc9..b6073efbc8967 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -46,8 +46,11 @@ // future). If you want to resolve everything but one type, you are // probably better off writing `resolve_all - resolve_ivar`. +use middle::ty; use middle::typeck::infer::floating::*; +use middle::typeck::infer::floating; use middle::typeck::infer::integral::*; +use middle::typeck::infer::integral; use middle::typeck::infer::to_str::ToStr; const resolve_nested_tvar: uint = 0b00000001; diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 1cec971f15629..b87f42490e2e2 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::infer::combine::*; use middle::typeck::infer::to_str::ToStr; use middle::typeck::infer::unify::*; diff --git a/src/librustc/middle/typeck/infer/to_str.rs b/src/librustc/middle/typeck/infer/to_str.rs index 166907ba7a862..81fe7b5ecf579 100644 --- a/src/librustc/middle/typeck/infer/to_str.rs +++ b/src/librustc/middle/typeck/infer/to_str.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::infer::integral::int_ty_set; use middle::typeck::infer::floating::float_ty_set; use middle::typeck::infer::unify::{redirect, root, var_value}; +use util::ppaux; trait ToStr { fn to_str(cx: infer_ctxt) -> ~str; @@ -30,7 +32,7 @@ impl ty::mt: ToStr { impl ty::Region: ToStr { fn to_str(cx: infer_ctxt) -> ~str { - util::ppaux::region_to_str(cx.tcx, self) + ppaux::region_to_str(cx.tcx, self) } } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 2ec356a6dc845..d6530e018290c 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; use middle::typeck::infer::combine::combine; use middle::typeck::infer::floating::*; +use middle::typeck::infer::floating; use middle::typeck::infer::integral::*; +use middle::typeck::infer::integral; use middle::typeck::infer::to_str::ToStr; use std::smallintmap::SmallIntMap; diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index aaf53e017388a..ef3de4d576f31 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -52,6 +52,7 @@ independently: use metadata::csearch; use middle::pat_util::{pat_id_map, PatIdMap}; +use middle::resolve; use middle::ty::{arg, field, node_type_table, mk_nil, ty_param_bounds_and_ty}; use middle::ty::{ty_param_substs_and_ty, vstore_uniq}; use middle::ty; @@ -390,8 +391,8 @@ fn check_crate(tcx: ty::ctxt, -> (method_map, vtable_map) { let ccx = @crate_ctxt_({trait_map: trait_map, - method_map: std::map::HashMap(), - vtable_map: std::map::HashMap(), + method_map: map::HashMap(), + vtable_map: map::HashMap(), coherence_info: @coherence::CoherenceInfo(), tcx: tcx }); diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index 5fba2b7e6fad6..3d78d0a24ff43 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use middle::ty; + use core::result::Result; +use syntax::ast; use syntax::parse::token::special_idents; trait region_scope { diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index c934b09a7c47b..c33607f17dc89 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -19,8 +19,6 @@ #[license = "MIT"]; #[crate_type = "lib"]; -#[no_core]; - #[legacy_modes]; #[legacy_exports]; @@ -29,12 +27,9 @@ #[allow(deprecated_mode)]; #[warn(deprecated_pattern)]; -extern mod core(vers = "0.5"); extern mod std(vers = "0.5"); extern mod syntax(vers = "0.5"); -use core::*; - /* Alternate names for some modules. diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index c1a88cae13cde..e36c2ae88da72 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::map::HashMap; use syntax::ast; use syntax::codemap::{span}; use syntax::visit; use syntax::print; +use syntax; + +use std::map::HashMap; fn indent(op: fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index 14b7b52e4d360..bdb92611454b5 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -17,6 +17,10 @@ query AST-related information, shielding the rest of Rustdoc from its non-sendableness. */ +use parse; +use util; + +use core::oldcomm; use rustc::back::link; use rustc::driver::driver; use rustc::driver::session::Session; @@ -30,6 +34,7 @@ use syntax::ast_map; use syntax::codemap; use syntax::diagnostic::handler; use syntax::diagnostic; +use syntax; pub type Ctxt = { ast: @ast::crate, diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs index 7ce4ef4f901f9..7d552a03edc87 100644 --- a/src/librustdoc/attr_parser.rs +++ b/src/librustdoc/attr_parser.rs @@ -15,9 +15,13 @@ The attribute parser provides methods for pulling documentation out of an AST's attributes. */ +use core::str; +use core::tuple; +use core::vec; use syntax::ast; use syntax::attr; -use core::tuple; +use syntax::codemap; +use syntax; pub type CrateAttrs = { name: Option<~str> diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 0180d18668daf..7562016cf47c5 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -16,12 +16,20 @@ corresponding AST nodes. The information gathered here is the basis of the natural-language documentation for a crate. */ +use astsrv; +use attr_parser; use doc::ItemUtils; +use doc; use extract::to_str; use fold::Fold; +use fold; + +use core::option; +use core::vec; use syntax::ast; use syntax::ast_map; use std::map::HashMap; +use std::par; pub fn mk_pass() -> Pass { { diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index ec600860690bf..5bce6c8ffff7d 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -8,7 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use result::Result; +use core::cmp; +use core::os; +use core::result; +use core::run; +use core::vec; +use core::result::Result; use std::getopts; use std::cell::Cell; diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index fa21366d917cc..f9c0fb829d0b5 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -15,8 +15,15 @@ If the first paragraph of a long description is short enough then it is interpreted as the brief description. */ +use astsrv; use doc::ItemUtils; +use doc; use fold::Fold; +use fold; + +use core::str; +use core::vec; +use std::par; pub fn mk_pass() -> Pass { { diff --git a/src/librustdoc/doc.rs b/src/librustdoc/doc.rs index c7d52fb77d663..4b5f82235dd0b 100644 --- a/src/librustdoc/doc.rs +++ b/src/librustdoc/doc.rs @@ -10,6 +10,12 @@ //! The document model +use doc; + +use core::cmp; +use core::option; +use core::vec; + pub type AstId = int; pub type Doc_ = { diff --git a/src/librustdoc/escape_pass.rs b/src/librustdoc/escape_pass.rs index 9daf334758603..46b2106377463 100644 --- a/src/librustdoc/escape_pass.rs +++ b/src/librustdoc/escape_pass.rs @@ -10,6 +10,10 @@ //! Escapes text sequences +use text_pass; + +use core::str; + pub fn mk_pass() -> Pass { text_pass::mk_pass(~"escape", escape) } diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index 717ae9d7fba8e..b4912f13983db 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -10,9 +10,15 @@ //! Converts the Rust AST to the rustdoc document model -use syntax::ast; +use astsrv; use doc::ItemUtils; -use task::local_data::local_data_get; +use doc; + +use core::cast; +use core::task::local_data::local_data_get; +use core::vec; +use syntax::ast; +use syntax; /* can't import macros yet, so this is copied from token.rs. See its comment * there. */ diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index ba626f80ddb8f..85f218d8f1629 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -8,6 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use doc; + +use core::vec; +use std::par; + pub struct Fold { ctxt: T, fold_doc: FoldDoc, diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index b1cc778bd1bf3..cdf2c48dd7da0 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -10,8 +10,17 @@ //! Build indexes as appropriate for the markdown pass +use astsrv; +use config; use doc::ItemUtils; +use doc; use fold::Fold; +use fold; +use markdown_pass; +use markdown_writer; + +use core::str; +use std::par; pub fn mk_pass(+config: config::Config) -> Pass { { diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 3328cdd527a86..39ba0bafb0d59 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -10,10 +10,20 @@ //! Generate markdown from a document tree +use astsrv; use doc::ItemUtils; +use doc; +use fold; +use markdown_pass; use markdown_writer::Writer; use markdown_writer::WriterUtils; use markdown_writer::WriterFactory; +use sort_pass; + +use core::str; +use core::vec; +use std::par; +use syntax; pub fn mk_pass(+writer_factory: WriterFactory) -> Pass { let f = fn~(move writer_factory, diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index 9cf404e0533d5..adad3c5f5e17e 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -8,9 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use config; use doc::ItemUtils; -use io::ReaderUtil; +use doc; + +use core::io::ReaderUtil; +use core::io; +use core::libc; +use core::oldcomm; +use core::os; +use core::pipes; +use core::result; +use core::run; +use core::str; +use core::task; use std::future; +use syntax; pub enum WriteInstr { Write(~str), diff --git a/src/librustdoc/page_pass.rs b/src/librustdoc/page_pass.rs index af8ac5f1427ef..d582119081bec 100644 --- a/src/librustdoc/page_pass.rs +++ b/src/librustdoc/page_pass.rs @@ -15,10 +15,20 @@ Each page corresponds is a logical section. There may be pages for individual modules, pages for the crate, indexes, etc. */ +use astsrv; +use config; use doc::{ItemUtils, PageUtils}; +use doc; use fold::Fold; -use syntax::ast; +use fold; +use sort_pass; use util::NominalOp; +use util; + +use core::oldcomm; +use core::option; +use core::vec; +use syntax::ast; pub fn mk_pass(output_style: config::OutputStyle) -> Pass { { diff --git a/src/librustdoc/pass.rs b/src/librustdoc/pass.rs index 0fbc61ad4544d..cc3bdf9f82c65 100644 --- a/src/librustdoc/pass.rs +++ b/src/librustdoc/pass.rs @@ -8,6 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use astsrv; +use doc; + +use core::vec; + /// A single operation on the document model pub type Pass = { name: ~str, diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs index b17f4d67a5c32..e183c13b90fa6 100644 --- a/src/librustdoc/path_pass.rs +++ b/src/librustdoc/path_pass.rs @@ -10,8 +10,12 @@ //! Records the full path to items +use astsrv; use doc::ItemUtils; +use doc; use fold::Fold; +use fold; + use syntax::ast; pub fn mk_pass() -> Pass { diff --git a/src/librustdoc/prune_hidden_pass.rs b/src/librustdoc/prune_hidden_pass.rs index bfe6f83870416..c5756571a410a 100644 --- a/src/librustdoc/prune_hidden_pass.rs +++ b/src/librustdoc/prune_hidden_pass.rs @@ -10,8 +10,14 @@ //! Prunes things with the #[doc(hidden)] attribute +use astsrv; +use attr_parser; use doc::ItemUtils; +use doc; use fold::Fold; +use fold; + +use core::vec; use std::map::HashMap; pub fn mk_pass() -> Pass { diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index e3dc1553a6392..c1852128622b1 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -12,7 +12,13 @@ #[legacy_exports]; +use astsrv; +use doc; use fold::Fold; +use fold; + +use core::util; +use syntax::ast; export mk_pass; @@ -56,7 +62,7 @@ fn is_visible(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool { ast_map::node_item(item, _) => { item.vis == ast::public } - _ => core::util::unreachable() + _ => util::unreachable() } } } diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index 2c73d4c478b12..090016a6f9c16 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -10,8 +10,14 @@ //! Breaks rustdocs into sections according to their headers +use astsrv; use doc::ItemUtils; +use doc; use fold::Fold; +use fold; + +use core::str; +use std::par; pub fn mk_pass() -> Pass { { diff --git a/src/librustdoc/sort_item_name_pass.rs b/src/librustdoc/sort_item_name_pass.rs index 3ef4750b9ad84..58349318bbbec 100644 --- a/src/librustdoc/sort_item_name_pass.rs +++ b/src/librustdoc/sort_item_name_pass.rs @@ -10,7 +10,11 @@ //! Sorts items by name +use astsrv; use doc::ItemUtils; +use doc; +use extract; +use sort_pass; pub fn mk_pass() -> Pass { pure fn by_item_name(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool { diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs index 25fc11a4a2a0e..4f69a307c204b 100644 --- a/src/librustdoc/sort_item_type_pass.rs +++ b/src/librustdoc/sort_item_type_pass.rs @@ -10,7 +10,11 @@ //! Sorts items by type +use astsrv; use doc::ItemUtils; +use doc; +use extract; +use sort_pass; pub fn mk_pass() -> Pass { pure fn by_score(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool { diff --git a/src/librustdoc/sort_pass.rs b/src/librustdoc/sort_pass.rs index a4926e765a773..a660f0c42ad63 100644 --- a/src/librustdoc/sort_pass.rs +++ b/src/librustdoc/sort_pass.rs @@ -10,11 +10,15 @@ //! A general sorting pass +use astsrv; use doc::ItemUtils; +use doc; use fold::Fold; -use std::sort; +use fold; use util::NominalOp; +use std::sort; + pub type ItemLtEqOp = pure fn~(v1: &doc::ItemTag, v2: &doc::ItemTag) -> bool; type ItemLtEq = NominalOp; diff --git a/src/librustdoc/text_pass.rs b/src/librustdoc/text_pass.rs index 9a48822b45360..30e91f95569ca 100644 --- a/src/librustdoc/text_pass.rs +++ b/src/librustdoc/text_pass.rs @@ -10,10 +10,15 @@ //! Generic pass for performing an operation on all descriptions +use astsrv; use doc::ItemUtils; +use doc; use fold::Fold; +use fold; use util::NominalOp; +use std::par; + pub fn mk_pass(name: ~str, +op: fn~(~str) -> ~str) -> Pass { { name: name, diff --git a/src/librustdoc/trim_pass.rs b/src/librustdoc/trim_pass.rs index e6696b74eaec3..78f56ceaba7b9 100644 --- a/src/librustdoc/trim_pass.rs +++ b/src/librustdoc/trim_pass.rs @@ -16,6 +16,10 @@ is interpreted as the brief description. */ use doc::ItemUtils; +use doc; +use text_pass; + +use core::str; pub fn mk_pass() -> Pass { text_pass::mk_pass(~"trim", |s| str::trim(s) ) diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 4609454315f26..ae69e83c3c71c 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -10,13 +10,20 @@ //! Pulls type information out of the AST and attaches it to the document +use astsrv; use doc::ItemUtils; +use doc; +use extract::to_str; +use extract; use fold::Fold; +use fold; + +use core::vec; +use std::map::HashMap; +use std::par; use syntax::ast; use syntax::print::pprust; use syntax::ast_map; -use std::map::HashMap; -use extract::to_str; pub fn mk_pass() -> Pass { { diff --git a/src/librustdoc/unindent_pass.rs b/src/librustdoc/unindent_pass.rs index a2a402385004a..e18d1652a5b7e 100644 --- a/src/librustdoc/unindent_pass.rs +++ b/src/librustdoc/unindent_pass.rs @@ -19,6 +19,13 @@ instances where the string containing the doc comment is opened in the middle of a line, and each of the following lines is indented. */ +use text_pass; + +use core::str; +use core::uint; +use core::vec; +use std::par; + pub fn mk_pass() -> Pass { text_pass::mk_pass(~"unindent", unindent) } diff --git a/src/librustdoc/util.rs b/src/librustdoc/util.rs index ebeb9346d3c49..998b64421d506 100644 --- a/src/librustdoc/util.rs +++ b/src/librustdoc/util.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::oldcomm; +use core::task; + // Just a named container for our op, so it can have impls pub struct NominalOp { op: T diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index e2bbda46d7cf3..8348900ae9502 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -15,12 +15,12 @@ * between tasks. */ -use private::{SharedMutableState, shared_mutable_state, - clone_shared_mutable_state, unwrap_shared_mutable_state, - get_shared_mutable_state, get_shared_immutable_state}; -use sync::{Mutex, mutex_with_condvars, - RWlock, rwlock_with_condvars}; +use sync; +use sync::{Mutex, mutex_with_condvars, RWlock, rwlock_with_condvars}; +use core::private::{SharedMutableState, shared_mutable_state}; +use core::private::{clone_shared_mutable_state, unwrap_shared_mutable_state}; +use core::private::{get_shared_mutable_state, get_shared_immutable_state}; /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. pub struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar } diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 105e8fb122fe6..0cda436b96b74 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -34,10 +34,12 @@ #[forbid(deprecated_mode)]; +use list; use list::{List, Cons, Nil}; -use cast::reinterpret_cast; -use sys::TypeDesc; -use libc::size_t; + +use core::cast::reinterpret_cast; +use core::libc::size_t; +use core::sys::TypeDesc; #[abi = "rust-intrinsic"] extern mod rusti { diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 43f13b5b91f48..d258174c65049 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -9,7 +9,8 @@ // except according to those terms. #[forbid(deprecated_mode)]; -use io::Reader; + +use core::io::Reader; pub trait ToBase64 { pure fn to_base64() -> ~str; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 5b9dc6cf3a895..5a37b9da0ab38 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -10,7 +10,7 @@ #[forbid(deprecated_mode)]; -use vec::{to_mut, from_elem}; +use core::vec::{to_mut, from_elem}; struct SmallBitv { /// only the lowest nbits of this value are used. the rest is undefined. diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 1055f3ea7df72..bcbd3b882c170 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -17,8 +17,8 @@ Higher level communication abstractions. // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -use pipes::{GenericChan, GenericSmartChan, GenericPort, - Chan, Port, Selectable, Peekable}; +use core::pipes::{GenericChan, GenericSmartChan, GenericPort}; +use core::pipes::{Chan, Port, Selectable, Peekable}; /// An extension of `pipes::stream` that allows both sending and receiving. pub struct DuplexStream { diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index 75e25f75c6c21..6ef29b0446e3e 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -11,8 +11,7 @@ #[forbid(deprecated_mode)]; //! Unsafe debugging functions for inspecting values. -use cast::reinterpret_cast; - +use core::cast::reinterpret_cast; #[abi = "cdecl"] extern mod rustrt { diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 687eff887c8b2..23080b12b6c30 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -12,9 +12,8 @@ #[forbid(deprecated_mode)]; #[forbid(non_camel_case_types)]; -use option::{Some, None}; -use dvec::DVec; -use core::cmp::{Eq}; +use core::cmp::Eq; +use core::dvec::DVec; pub trait Deque { fn size() -> uint; diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 1c6384f87d41f..cb86292e06eb2 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -9,6 +9,7 @@ // except according to those terms. #[forbid(deprecated_mode)]; + use serialization; // Simple Extensible Binary Markup Language (ebml) reader and writer on a @@ -54,6 +55,7 @@ enum EbmlSerializerTag { // -------------------------------------- pub mod reader { + use serialization; // ebml reading @@ -271,7 +273,7 @@ pub mod reader { fn read_u8 (&self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) } fn read_uint(&self) -> uint { let v = doc_as_u64(self.next_doc(EsUint)); - if v > (core::uint::max_value as u64) { + if v > (::core::uint::max_value as u64) { fail fmt!("uint %? too large for this architecture", v); } v as uint @@ -546,7 +548,7 @@ pub mod writer { } } - impl Serializer: serialization::Serializer { + impl Serializer: ::serialization::Serializer { fn emit_nil(&self) {} fn emit_uint(&self, v: uint) { diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 1eccb5a8d92da..6a24e1e581774 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -22,8 +22,7 @@ */ use core::cmp::{Eq, Ord}; -use option::{Some, None}; -use option = option; +use core::option::{Some, None}; pub type Treemap = @TreeNode; diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 2a72c2f696a54..d0191fc83fd21 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -21,9 +21,9 @@ * ~~~ */ -use either::Either; -use pipes::{recv, oneshot, ChanOne, PortOne, send_one, recv_one}; -use cast::copy_lifetime; +use core::cast::copy_lifetime; +use core::either::Either; +use core::pipes::{recv, oneshot, ChanOne, PortOne, send_one, recv_one}; #[doc = "The future type"] pub struct Future { diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 38540524daca3..05306ea9135a8 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -450,6 +450,7 @@ enum FailType { * groups of short and long option names, together. */ pub mod groups { + use getopts::Result; /** one group of options, e.g., both -h and --help, along with * their shared description and properties diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 70bffb215878e..c777a60aed57c 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -15,11 +15,13 @@ //! json serialization -use core::cmp::{Eq, Ord}; -use io::{WriterUtil, ReaderUtil}; -use send_map::linear; +use serialization; use sort::Sort; +use core::cmp::{Eq, Ord}; +use core::io::{WriterUtil, ReaderUtil}; +use core::send_map::linear; + /// Represents a json value pub enum Json { Number(float), diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 6d2c10eb8274b..0fb84da975e42 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -13,8 +13,7 @@ use core::cmp::Eq; use core::option; -use option::*; -use option::{Some, None}; +use core::option::*; #[deriving_eq] pub enum List { diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 39124dfbfbae2..344067ea657f3 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -11,14 +11,13 @@ //! A map type #[forbid(deprecated_mode)]; -use io::WriterUtil; -use to_str::ToStr; -use mutable::Mut; -use send_map::linear::LinearMap; - use core::cmp::Eq; -use hash::Hash; -use to_bytes::IterBytes; +use core::hash::Hash; +use core::io::WriterUtil; +use core::to_str::ToStr; +use core::mutable::Mut; +use core::send_map::linear::LinearMap; +use core::to_bytes::IterBytes; /// A convenience type to treat a hashmap as a set pub type Set = HashMap; @@ -103,7 +102,7 @@ pub trait Map { pure fn each_value_ref(fn(value: &V) -> bool); } -mod util { +pub mod util { pub type Rational = {num: int, den: int}; // : int::positive(*.den); pub pure fn rational_leq(x: Rational, y: Rational) -> bool { @@ -117,6 +116,7 @@ mod util { // FIXME (#2344): package this up and export it as a datatype usable for // external code that doesn't want to pay the cost of a box. pub mod chained { + use map::util; const initial_capacity: uint = 32u; // 2^5 diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 1eb970526c36b..a64f029321635 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -139,6 +139,8 @@ pub fn get_addr(node: &str, iotask: iotask) } pub mod v4 { + use uv::ll; + /** * Convert a str to `ip_addr` * diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index c94a7fd112595..366c94d3ee23e 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -12,13 +12,16 @@ // XXX Need FFI fixes #[allow(deprecated_mode)]; +use future; +use future_spawn = future::spawn; use ip = net_ip; +use uv; use uv::iotask; use uv::iotask::IoTask; -use future_spawn = future::spawn; -use result::{Result}; -use libc::size_t; -use io::{Reader, ReaderUtil, Writer}; + +use core::io::{Reader, ReaderUtil, Writer}; +use core::libc::size_t; +use core::result::{Result}; #[nolink] extern mod rustrt { @@ -901,6 +904,8 @@ fn tear_down_socket_data(socket_data: @TcpSocketData) unsafe { // shared implementation for tcp::read fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint) -> result::Result<~[u8],TcpErrData> unsafe { + use timer; + log(debug, ~"starting tcp::read"); let iotask = (*socket_data).iotask; let rs_result = read_start_common_impl(socket_data); @@ -1258,6 +1263,10 @@ type TcpBufferedSocketData = { //#[cfg(test)] mod test { + use net; + use net::ip; + use uv; + // FIXME don't run on fbsd or linux 32 bit (#2064) #[cfg(target_os="win32")] #[cfg(target_os="darwin")] @@ -1566,7 +1575,8 @@ mod test { } fn impl_tcp_socket_impl_reader_handles_eof() { - use io::{Reader,ReaderUtil}; + use core::io::{Reader,ReaderUtil}; + let hl_loop = uv::global_loop::get(); let server_ip = ~"127.0.0.1"; let server_port = 10041u; diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 6b7dc3f1afdb4..31760d668401c 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -11,14 +11,16 @@ //! Types/fns concerning URLs (see RFC 3986) #[forbid(deprecated_mode)]; -use core::cmp::Eq; +use map; use map::HashMap; -use io::{Reader, ReaderUtil}; -use dvec::DVec; -use from_str::FromStr; -use result::{Err, Ok}; -use to_str::ToStr; -use to_bytes::IterBytes; + +use core::cmp::Eq; +use core::dvec::DVec; +use core::from_str::FromStr; +use core::io::{Reader, ReaderUtil}; +use core::to_bytes::IterBytes; +use core::to_str::ToStr; +use core::util; struct Url { scheme: ~str, diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index d282996754481..167b2a757112d 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -10,10 +10,11 @@ #[forbid(deprecated_mode)]; -use io::Writer; -use io::WriterUtil; use serialization; +use core::io::Writer; +use core::io::WriterUtil; + pub struct Serializer { wr: io::Writer, } diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 59d15c8b4c26d..ace55f7164a92 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -2,7 +2,7 @@ //! A priority queue implemented with a binary heap use core::cmp::Ord; -use ptr::addr_of; +use core::ptr::addr_of; #[abi = "rust-intrinsic"] extern "C" mod rusti { diff --git a/src/libstd/rl.rs b/src/libstd/rl.rs index b8cd1dc3ca2e9..9876ca1ce0ce7 100644 --- a/src/libstd/rl.rs +++ b/src/libstd/rl.rs @@ -11,7 +11,7 @@ // FIXME #3921. This is unsafe because linenoise uses global mutable // state without mutexes. -use libc::{c_char, c_int}; +use core::libc::{c_char, c_int}; extern mod rustrt { #[legacy_exports]; @@ -79,4 +79,4 @@ pub unsafe fn complete(cb: CompletionCb) unsafe { } rustrt::linenoiseSetCompletionCallback(callback); -} \ No newline at end of file +} diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 473992e68206f..90abb7fd567af 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -441,6 +441,8 @@ pub fn loop_leaves(rope: Rope, it: fn(node::Leaf) -> bool) -> bool{ pub mod iterator { pub mod leaf { + use rope::node; + pub fn start(rope: Rope) -> node::leaf_iterator::T { match (rope) { node::Empty => return node::leaf_iterator::empty(), @@ -452,6 +454,8 @@ pub mod iterator { } } pub mod char { + use rope::node; + pub fn start(rope: Rope) -> node::char_iterator::T { match (rope) { node::Empty => return node::char_iterator::empty(), @@ -543,7 +547,8 @@ pub fn char_at(rope: Rope, pos: uint) -> char { /* Section: Implementation */ -mod node { +pub mod node { + use rope::node; /// Implementation of type `rope` pub enum Root { @@ -1153,6 +1158,8 @@ mod node { } pub mod char_iterator { + use rope::node::leaf_iterator; + pub type T = { leaf_iterator: leaf_iterator::T, mut leaf: Option, diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index b16cf99cb4eff..b8816484cfbad 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -14,10 +14,12 @@ */ #[forbid(deprecated_mode)]; +use map; +use map::Map; + +use core::dvec::DVec; use core::option; use core::option::{Some, None}; -use dvec::DVec; -use map::Map; // FIXME (#2347): Should not be @; there's a bug somewhere in rustc that // requires this to be. diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 316e23ef7ac22..da62e5847aa57 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -11,9 +11,9 @@ //! Sorting methods #[forbid(deprecated_mode)]; -use vec::{len, push}; use core::cmp::{Eq, Ord}; -use dvec::DVec; +use core::dvec::DVec; +use core::vec::{len, push}; type Le = pure fn(v1: &T, v2: &T) -> bool; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index f5363ca23c503..a02abe93f6c84 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -26,8 +26,6 @@ not required in or otherwise suitable for the core library. #[license = "MIT"]; #[crate_type = "lib"]; -#[no_core]; - #[allow(vecs_implicitly_copyable)]; #[deny(non_camel_case_types)]; // XXX this is set to allow because there are two methods in serialization @@ -35,9 +33,6 @@ not required in or otherwise suitable for the core library. #[allow(deprecated_mode)]; #[forbid(deprecated_pattern)]; -extern mod core(vers = "0.5"); -use core::*; - // General io and system-services modules pub mod net; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index e1b029c5396f4..ee7568fe893b5 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -17,7 +17,7 @@ * in std. */ -use private::{Exclusive, exclusive}; +use core::private::{Exclusive, exclusive}; /**************************************************************************** * Internals diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index a87576789af55..c45952ed670bf 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -11,8 +11,8 @@ /// A task pool abstraction. Useful for achieving predictable CPU /// parallelism. -use pipes::{Chan, Port}; -use task::{SchedMode, SingleThreaded}; +use core::pipes::{Chan, Port}; +use core::task::{SchedMode, SingleThreaded}; enum Msg { Execute(~fn(&T)), diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 25ea4ad7bb5cf..1722394f8e41b 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -12,9 +12,6 @@ #[forbid(deprecated_mode)]; -use core::option; -use option::{None, Some}; - pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { let r = rand::Rng(); let mut i = 0u; diff --git a/src/libstd/test.rs b/src/libstd/test.rs index d365077d0639d..4e0a6edba374c 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -17,12 +17,15 @@ #[forbid(deprecated_mode)]; +use getopts; +use sort; +use term; + use core::cmp::Eq; -use either::Either; -use result::{Ok, Err}; -use io::WriterUtil; -use libc::size_t; -use task::TaskBuilder; +use core::either::Either; +use core::io::WriterUtil; +use core::libc::size_t; +use core::task::TaskBuilder; #[abi = "cdecl"] extern mod rustrt { diff --git a/src/libstd/time.rs b/src/libstd/time.rs index c4a6e39c86bfe..b71c507c9169d 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -11,9 +11,9 @@ #[forbid(deprecated_mode)]; use core::cmp::Eq; -use libc::{c_char, c_int, c_long, size_t, time_t}; -use io::{Reader, ReaderUtil}; -use result::{Result, Ok, Err}; +use core::libc::{c_char, c_int, c_long, size_t, time_t}; +use core::io::{Reader, ReaderUtil}; +use core::result::{Result, Ok, Err}; #[abi = "cdecl"] extern mod rustrt { diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index c3a2a11e1f840..04c5b59c551c3 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -12,6 +12,7 @@ #[forbid(deprecated_mode)]; +use uv; use uv::iotask; use uv::iotask::IoTask; diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 2efbfae3da4e2..35b763e87b97e 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -16,10 +16,11 @@ use ll = uv_ll; use iotask = uv_iotask; use get_gl = get; use uv_iotask::{IoTask, spawn_iotask}; -use private::{chan_from_global_ptr, weaken_task}; + +use core::either::{Left, Right}; use core::oldcomm::{Port, Chan, select2, listen}; -use task::TaskBuilder; -use either::{Left, Right}; +use core::private::{chan_from_global_ptr, weaken_task}; +use core::task::TaskBuilder; extern mod rustrt { fn rust_uv_get_kernel_global_chan_ptr() -> *libc::uintptr_t; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index d778606075d1a..c2399182fb8f7 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -16,12 +16,13 @@ */ #[forbid(deprecated_mode)]; -use libc::c_void; -use ptr::addr_of; -use core::oldcomm::{Port, Chan, listen}; -use task::TaskBuilder; use ll = uv_ll; +use core::libc::c_void; +use core::oldcomm::{Port, Chan, listen}; +use core::ptr::addr_of; +use core::task::TaskBuilder; + /// Used to abstract-away direct interaction with a libuv loop. pub enum IoTask { IoTask_({ diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 65333b41864e5..921a70c82ff51 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -32,8 +32,8 @@ #[allow(non_camel_case_types)]; // C types -use libc::size_t; -use ptr::to_unsafe_ptr; +use core::libc::size_t; +use core::ptr::to_unsafe_ptr; // libuv struct mappings pub type uv_ip4_addr = { diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 98efebc49b004..83fb2d9d401b4 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::cmp::Eq; -use send_map::linear::LinearMap; -use pipes::{recv, oneshot, PortOne, send_one}; -use either::{Right,Left,Either}; - use json; use sha1; -use serialization::{Serializer,Serializable, - Deserializer,Deserializable}; +use serialization::{Serializer,Serializable,Deserializer,Deserializable}; + +use core::either::{Either, Left, Right}; +use core::pipes::{recv, oneshot, PortOne, send_one}; +use core::send_map::linear::LinearMap; /** * diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 444f90c7f0458..94beee3eef8ee 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,13 +10,13 @@ // The Rust abstract syntax tree. -use std::serialization::{Serializable, - Deserializable, - Serializer, - Deserializer}; +use ast; use codemap::{span, FileName}; use parse::token; +use std::serialization::{Serializable, Deserializable, Serializer}; +use std::serialization::{Deserializer}; + #[auto_serialize] #[auto_deserialize] type spanned = {node: T, span: span}; diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 6e684d0daf4f3..ae8354b20d959 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -8,13 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::map; -use std::map::HashMap; use ast::*; -use print::pprust; +use ast; use ast_util::{path_to_ident, stmt_id}; +use ast_util; +use attr; +use codemap; use diagnostic::span_handler; use parse::token::ident_interner; +use print::pprust; +use visit; + +use std::map::HashMap; +use std::map; +use std; enum path_elt { path_mod(ident), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index ef7bd1d892859..11b3baa1d4d6c 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -8,8 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use codemap::{span, BytePos}; use ast::*; +use ast; +use ast_util; +use codemap::{span, BytePos}; +use visit; + +use core::to_bytes; pure fn spanned(+lo: BytePos, +hi: BytePos, +t: T) -> spanned { respan(mk_sp(lo, hi), move t) @@ -262,10 +267,10 @@ pure fn is_call_expr(e: @expr) -> bool { } // This makes def_id hashable -impl def_id : core::to_bytes::IterBytes { +impl def_id : to_bytes::IterBytes { #[inline(always)] - pure fn iter_bytes(&self, +lsb0: bool, f: core::to_bytes::Cb) { - core::to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f); + pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { + to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f); } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index aadea886407cd..3418e558fe313 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -10,13 +10,17 @@ // Functions dealing with attributes and meta_items -use std::map; -use std::map::HashMap; -use either::Either; -use diagnostic::span_handler; +use ast; use ast_util::{spanned, dummy_spanned}; -use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; +use attr; use codemap::BytePos; +use diagnostic::span_handler; +use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; + +use core::either::Either; +use std::map::HashMap; +use std::map; +use std; // Constructors export mk_name_value_item_str; diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 6481785e61af2..b2a68828428bc 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -21,11 +21,11 @@ source code snippets, etc. */ -use dvec::DVec; -use std::serialization::{Serializable, - Deserializable, - Serializer, - Deserializer}; +use ast_util; + +use core::dvec::DVec; +use std::serialization::{Serializable, Deserializable, Serializer}; +use std::serialization::{Deserializer}; trait Pos { static pure fn from_uint(n: uint) -> self; diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index e42bb00c2129d..af1cbcf14ae6b 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::term; -use io::WriterUtil; use codemap::span; +use codemap; + +use core::io::WriterUtil; +use std::term; export emitter, emit; export level, fatal, error, warning, note; diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index 0ff3dbe150613..759ec95b54808 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -88,8 +88,11 @@ node twice. */ -use ext::base::*; +use ast_util; +use attr; use codemap::span; +use ext::base::*; + use std::map; use std::map::HashMap; @@ -259,11 +262,20 @@ priv impl ext_ctxt { @{span: span, global: false, idents: strs, rp: None, types: ~[]} } + fn path_global(span: span, strs: ~[ast::ident]) -> @ast::path { + @{span: span, global: true, idents: strs, rp: None, types: ~[]} + } + fn path_tps(span: span, strs: ~[ast::ident], tps: ~[@ast::Ty]) -> @ast::path { @{span: span, global: false, idents: strs, rp: None, types: tps} } + fn path_tps_global(span: span, strs: ~[ast::ident], + tps: ~[@ast::Ty]) -> @ast::path { + @{span: span, global: true, idents: strs, rp: None, types: tps} + } + fn ty_path(span: span, strs: ~[ast::ident], tps: ~[@ast::Ty]) -> @ast::Ty { @{id: self.next_id(), @@ -334,6 +346,10 @@ priv impl ext_ctxt { self.expr(span, ast::expr_path(self.path(span, strs))) } + fn expr_path_global(span: span, strs: ~[ast::ident]) -> @ast::expr { + self.expr(span, ast::expr_path(self.path_global(span, strs))) + } + fn expr_var(span: span, var: ~str) -> @ast::expr { self.expr_path(span, ~[self.ident_of(var)]) } diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 4c1725b10000c..51a1683da463b 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -88,8 +88,14 @@ node twice. */ -use ext::base::*; +use ast; +use attr; +use ast_util; use codemap::span; +use codemap; +use ext::base::*; +use print; + use std::map; use std::map::HashMap; @@ -291,7 +297,7 @@ fn mk_ser_impl( let ty_param = cx.bind_path( span, cx.ident_of(~"__S"), - cx.path( + cx.path_global( span, ~[ cx.ident_of(~"std"), @@ -303,7 +309,7 @@ fn mk_ser_impl( ); // Make a path to the std::serialization::Serializable trait. - let path = cx.path_tps( + let path = cx.path_tps_global( span, ~[ cx.ident_of(~"std"), @@ -335,7 +341,7 @@ fn mk_deser_impl( let ty_param = cx.bind_path( span, cx.ident_of(~"__D"), - cx.path( + cx.path_global( span, ~[ cx.ident_of(~"std"), @@ -347,7 +353,7 @@ fn mk_deser_impl( ); // Make a path to the std::serialization::Deserializable trait. - let path = cx.path_tps( + let path = cx.path_tps_global( span, ~[ cx.ident_of(~"std"), @@ -682,7 +688,7 @@ fn mk_deser_fields( cx.expr_blk( cx.expr_call( span, - cx.expr_path(span, ~[ + cx.expr_path_global(span, ~[ cx.ident_of(~"std"), cx.ident_of(~"serialization"), cx.ident_of(~"deserialize"), @@ -885,7 +891,7 @@ fn mk_enum_deser_variant_nary( let expr_lambda = cx.lambda_expr( cx.expr_call( span, - cx.expr_path(span, ~[ + cx.expr_path_global(span, ~[ cx.ident_of(~"std"), cx.ident_of(~"serialization"), cx.ident_of(~"deserialize"), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index d245aa1c050c4..38f56b319adc2 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -8,12 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::map::HashMap; -use parse::parser; -use diagnostic::span_handler; -use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom}; +use ast; use ast_util::dummy_sp; -use parse::token; +use codemap; +use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom}; +use diagnostic::span_handler; +use ext; +use parse; +use parse::{parser, token}; + +use std::map::HashMap; // new-style macro! tt code: // diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1e7d27bee6e48..f50ae8410c230 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -8,8 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use ast; +use codemap; use codemap::span; use ext::base::ext_ctxt; +use ext::build; fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) -> @ast::expr { @@ -55,10 +58,19 @@ fn mk_raw_path_(sp: span, -> @ast::path { @{ span: sp, global: false, idents: idents, rp: None, types: move types } } +fn mk_raw_path_global(sp: span, idents: ~[ast::ident]) -> @ast::path { + let p : @ast::path = @{span: sp, global: true, idents: idents, + rp: None, types: ~[]}; + return p; +} fn mk_path(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) -> @ast::expr { mk_expr(cx, sp, ast::expr_path(mk_raw_path(sp, idents))) } +fn mk_path_global(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) -> + @ast::expr { + mk_expr(cx, sp, ast::expr_path(mk_raw_path_global(sp, idents))) +} fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident) -> @ast::expr { mk_expr(cx, sp, ast::expr_field(p, m, ~[])) @@ -80,6 +92,11 @@ fn mk_call(cx: ext_ctxt, sp: span, fn_path: ~[ast::ident], let pathexpr = mk_path(cx, sp, fn_path); return mk_call_(cx, sp, pathexpr, args); } +fn mk_call_global(cx: ext_ctxt, sp: span, fn_path: ~[ast::ident], + args: ~[@ast::expr]) -> @ast::expr { + let pathexpr = mk_path_global(cx, sp, fn_path); + return mk_call_(cx, sp, pathexpr, args); +} // e = expr, t = type fn mk_base_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { @@ -244,6 +261,15 @@ fn mk_ty_path(cx: ext_ctxt, let ty = @{ id: cx.next_id(), node: move ty, span: span }; ty } +fn mk_ty_path_global(cx: ext_ctxt, + span: span, + idents: ~[ ast::ident ]) + -> @ast::Ty { + let ty = build::mk_raw_path_global(span, idents); + let ty = ast::ty_path(ty, cx.next_id()); + let ty = @{ id: cx.next_id(), node: move ty, span: span }; + ty +} fn mk_simple_ty_path(cx: ext_ctxt, span: span, ident: ast::ident) diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index d84d79082a4f8..4f88ffeeb0468 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -9,6 +9,7 @@ // except according to those terms. use ext::base::*; +use ext::base; fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) -> base::mac_result { diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index d1ba835a3e519..1e77b8e360759 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -19,6 +19,7 @@ use ast::{struct_variant_kind, sty_by_ref, sty_region, tuple_variant_kind}; use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_rptr, unnamed_field}; use ast::{variant}; use ext::base::ext_ctxt; +use ext::build; use codemap::span; use parse::token::special_idents::clownshoes_extensions; @@ -202,7 +203,9 @@ fn create_derived_impl(cx: ext_ctxt, // Create the type parameters. let impl_ty_params = dvec::DVec(); for ty_params.each |ty_param| { - let bound = build::mk_ty_path(cx, span, trait_path.map(|x| *x)); + let bound = build::mk_ty_path_global(cx, + span, + trait_path.map(|x| *x)); let bounds = @~[ ty_param_bound(bound) ]; let impl_ty_param = build::mk_ty_param(cx, ty_param.ident, bounds); impl_ty_params.push(move impl_ty_param); @@ -212,7 +215,7 @@ fn create_derived_impl(cx: ext_ctxt, // Create the reference to the trait. let trait_path = { span: span, - global: false, + global: true, idents: trait_path.map(|x| *x), rp: None, types: ~[] diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index b5c55437d70b3..c07853a400bbc 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -14,8 +14,14 @@ * should all get sucked into either the compiler syntax extension plugin * interface. */ + use ext::base::*; +use ext::base; use ext::build::mk_uniq_str; + +use core::option; +use core::os; + export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a35f351451bdc..0157cec467c57 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::map::HashMap; - -use ast::{crate, expr_, expr_mac, mac_invoc_tt, - tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi}; -use fold::*; +use ast::{crate, expr_, expr_mac, mac_invoc_tt}; +use ast::{tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi}; +use ast; +use codemap::{span, ExpandedFrom}; use ext::base::*; +use fold::*; use parse::{parser, parse_expr_from_source_str, new_parser_from_tts}; +use std::map::HashMap; -use codemap::{span, ExpandedFrom}; fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt, @@ -276,17 +276,17 @@ fn core_macros() -> ~str { macro_rules! ignore (($($x:tt)*) => (())) macro_rules! error ( ($( $arg:expr ),+) => ( - log(core::error, fmt!( $($arg),+ )) )) + log(::core::error, fmt!( $($arg),+ )) )) macro_rules! warn ( ($( $arg:expr ),+) => ( - log(core::warn, fmt!( $($arg),+ )) )) + log(::core::warn, fmt!( $($arg),+ )) )) macro_rules! info ( ($( $arg:expr ),+) => ( - log(core::info, fmt!( $($arg),+ )) )) + log(::core::info, fmt!( $($arg),+ )) )) macro_rules! debug ( ($( $arg:expr ),+) => ( - log(core::debug, fmt!( $($arg),+ )) )) + log(::core::debug, fmt!( $($arg),+ )) )) macro_rules! die( ($msg: expr) => ( - core::sys::begin_unwind($msg, file!(), line!()) + ::core::sys::begin_unwind($msg, file!(), line!()) ); () => ( die!(~\"explicit failure\") diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 2b5f95c4066da..b8a27096f7304 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -15,10 +15,14 @@ * should all get sucked into either the standard library extfmt module or the * compiler syntax extension plugin interface. */ -use extfmt::ct::*; -use ext::base::*; + +use ast; use codemap::span; +use ext::base::*; +use ext::base; use ext::build::*; +use extfmt::ct::*; + export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree]) @@ -57,7 +61,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } fn make_rt_path_expr(cx: ext_ctxt, sp: span, nm: @~str) -> @ast::expr { let path = make_path_vec(cx, nm); - return mk_path(cx, sp, path); + return mk_path_global(cx, sp, path); } // Produces an AST expression that represents a RT::conv record, // which tells the RT::conv* functions how to perform the conversion @@ -87,7 +91,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let count_lit = mk_uint(cx, sp, c as uint); let count_is_path = make_path_vec(cx, @~"CountIs"); let count_is_args = ~[count_lit]; - return mk_call(cx, sp, count_is_path, count_is_args); + return mk_call_global(cx, sp, count_is_path, count_is_args); } _ => cx.span_unimpl(sp, ~"unimplemented fmt! conversion") } @@ -129,7 +133,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let path = make_path_vec(cx, @fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let args = ~[cnv_expr, arg]; - return mk_call(cx, arg.span, path, args); + return mk_call_global(cx, arg.span, path, args); } fn make_new_conv(cx: ext_ctxt, sp: span, cnv: Conv, arg: @ast::expr) -> @@ -285,10 +289,11 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs); - return mk_call(cx, fmt_sp, - ~[cx.parse_sess().interner.intern(@~"str"), - cx.parse_sess().interner.intern(@~"concat")], - ~[arg_vec]); + return mk_call_global(cx, + fmt_sp, + ~[cx.parse_sess().interner.intern(@~"str"), + cx.parse_sess().interner.intern(@~"concat")], + ~[arg_vec]); } // // Local Variables: diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 47096182fe848..563c56e02b506 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -8,8 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use ast; +use codemap; use ext::base::*; -use io::WriterUtil; +use ext::base; +use print; + +use core::io::WriterUtil; +use core::option; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, tt: ~[ast::token_tree]) -> base::mac_result { diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 56f426e3853bf..06d81fcc24545 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -14,7 +14,10 @@ // something smarter. use ast::{ident, node_id}; +use ast; use ast_util::{ident_to_path, respan, dummy_sp}; +use ast_util; +use attr; use codemap::span; use ext::base::mk_ctxt; use ext::quote::rt::*; @@ -34,6 +37,14 @@ fn path(ids: ~[ident], span: span) -> @ast::path { types: ~[]} } +fn path_global(ids: ~[ident], span: span) -> @ast::path { + @{span: span, + global: true, + idents: ids, + rp: None, + types: ~[]} +} + trait append_types { fn add_ty(ty: @ast::Ty) -> @ast::path; fn add_tys(+tys: ~[@ast::Ty]) -> @ast::path; @@ -82,6 +93,7 @@ trait ext_ctxt_ast_builder { +params: ~[ast::ty_param]) -> @ast::item; fn item_ty(name: ident, span: span, ty: @ast::Ty) -> @ast::item; fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty]; + fn ty_vars_global(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty]; fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field; fn ty_rec(+v: ~[ast::ty_field]) -> @ast::Ty; fn field_imm(name: ident, e: @ast::expr) -> ast::field; @@ -303,4 +315,9 @@ impl ext_ctxt: ext_ctxt_ast_builder { ty_params.map(|p| self.ty_path_ast_builder( path(~[p.ident], dummy_sp()))) } + + fn ty_vars_global(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] { + ty_params.map(|p| self.ty_path_ast_builder( + path(~[p.ident], dummy_sp()))) + } } diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 7193a00950e28..8eecafa8fa43a 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -29,9 +29,10 @@ that. */ +use ast; use ext::base::ext_ctxt; - use ext::pipes::proto::{state, protocol, next_state}; +use ext::pipes::proto; impl ext_ctxt: proto::visitor<(), (), ()> { fn visit_proto(_proto: protocol, diff --git a/src/libsyntax/ext/pipes/mod.rs b/src/libsyntax/ext/pipes/mod.rs index 0a02bca88ca99..67b5c81ad2d82 100644 --- a/src/libsyntax/ext/pipes/mod.rs +++ b/src/libsyntax/ext/pipes/mod.rs @@ -43,14 +43,15 @@ FIXME (#3072) - This is still incomplete. */ +use ast; +use ast::tt_delim; use codemap::span; +use ext::base; use ext::base::ext_ctxt; -use ast::tt_delim; -use parse::lexer::{new_tt_reader, reader}; -use parse::parser::Parser; - use ext::pipes::parse_proto::proto_parser; use ext::pipes::proto::{visit, protocol}; +use parse::lexer::{new_tt_reader, reader}; +use parse::parser::Parser; #[legacy_exports] mod ast_builder; diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index c07170e5c3640..04f7ce2005308 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -21,7 +21,7 @@ use ext::base::ext_ctxt; use parse::*; use ext::pipes::proto::*; use ext::quote::rt::*; -use ext::pipes::ast_builder::{append_types, path}; +use ext::pipes::ast_builder::{append_types, path, path_global}; trait gen_send { fn gen_send(cx: ext_ctxt, try: bool) -> @ast::item; @@ -59,13 +59,14 @@ impl message: gen_send { let pipe_ty = cx.ty_path_ast_builder( path(~[this.data_name()], span) - .add_tys(cx.ty_vars(this.ty_params))); + .add_tys(cx.ty_vars_global(this.ty_params))); let args_ast = vec::append( ~[cx.arg(cx.ident_of(~"pipe"), pipe_ty)], args_ast); let mut body = ~"{\n"; + body += fmt!("use super::%s;\n", self.name()); if this.proto.is_bounded() { let (sp, rp) = match (this.dir, next.dir) { @@ -76,11 +77,11 @@ impl message: gen_send { }; body += ~"let b = pipe.reuse_buffer();\n"; - body += fmt!("let %s = pipes::SendPacketBuffered(\ - ptr::addr_of(&(b.buffer.data.%s)));\n", + body += fmt!("let %s = ::pipes::SendPacketBuffered(\ + ::ptr::addr_of(&(b.buffer.data.%s)));\n", sp, next.name); - body += fmt!("let %s = pipes::RecvPacketBuffered(\ - ptr::addr_of(&(b.buffer.data.%s)));\n", + body += fmt!("let %s = ::pipes::RecvPacketBuffered(\ + ::ptr::addr_of(&(b.buffer.data.%s)));\n", rp, next.name); } else { @@ -91,24 +92,23 @@ impl message: gen_send { (recv, recv) => "(move c, move s)" }; - body += fmt!("let %s = pipes::entangle();\n", pat); + body += fmt!("let %s = ::pipes::entangle();\n", pat); } - body += fmt!("let message = %s::%s(%s);\n", - this.proto.name, + body += fmt!("let message = %s(%s);\n", self.name(), str::connect(vec::append_one( arg_names.map(|x| ~"move " + cx.str_of(*x)), ~"move s"), ~", ")); if !try { - body += fmt!("pipes::send(move pipe, move message);\n"); + body += fmt!("::pipes::send(move pipe, move message);\n"); // return the new channel body += ~"move c }"; } else { - body += fmt!("if pipes::send(move pipe, move message) {\n \ - pipes::rt::make_some(move c) \ - } else { pipes::rt::make_none() } }"); + body += fmt!("if ::pipes::send(move pipe, move message) {\n \ + ::pipes::rt::make_some(move c) \ + } else { ::pipes::rt::make_none() } }"); } let body = cx.parse_expr(body); @@ -142,7 +142,8 @@ impl message: gen_send { ~[cx.arg(cx.ident_of(~"pipe"), cx.ty_path_ast_builder( path(~[this.data_name()], span) - .add_tys(cx.ty_vars(this.ty_params))))], + .add_tys(cx.ty_vars_global( + this.ty_params))))], args_ast); let message_args = if arg_names.len() == 0 { @@ -154,18 +155,21 @@ impl message: gen_send { }; let mut body = ~"{ "; - body += fmt!("let message = %s::%s%s;\n", - this.proto.name, + body += fmt!("use super::%s;\n", self.name()); + body += fmt!("let message = %s%s;\n", self.name(), message_args); if !try { - body += fmt!("pipes::send(move pipe, move message);\n"); + body += fmt!("::pipes::send(move pipe, move message);\n"); body += ~" }"; } else { - body += fmt!("if pipes::send(move pipe, move message) { \ - pipes::rt::make_some(()) \ - } else { pipes::rt::make_none() } }"); + body += fmt!("if ::pipes::send(move pipe, move message) \ + { \ + ::pipes::rt::make_some(()) \ + } else { \ + ::pipes::rt::make_none() \ + } }"); } let body = cx.parse_expr(body); @@ -190,7 +194,7 @@ impl message: gen_send { fn to_ty(cx: ext_ctxt) -> @ast::Ty { cx.ty_path_ast_builder(path(~[cx.ident_of(self.name())], self.span()) - .add_tys(cx.ty_vars(self.get_params()))) + .add_tys(cx.ty_vars_global(self.get_params()))) } } @@ -261,14 +265,14 @@ impl state: to_type_decls { self.data_name(), self.span, cx.ty_path_ast_builder( - path(~[cx.ident_of(~"pipes"), - cx.ident_of(dir.to_str() + ~"Packet")], + path_global(~[cx.ident_of(~"pipes"), + cx.ident_of(dir.to_str() + ~"Packet")], dummy_sp()) .add_ty(cx.ty_path_ast_builder( - path(~[cx.ident_of(self.proto.name), + path(~[cx.ident_of(~"super"), self.data_name()], dummy_sp()) - .add_tys(cx.ty_vars(self.ty_params))))), + .add_tys(cx.ty_vars_global(self.ty_params))))), self.ty_params)); } else { @@ -277,15 +281,15 @@ impl state: to_type_decls { self.data_name(), self.span, cx.ty_path_ast_builder( - path(~[cx.ident_of(~"pipes"), - cx.ident_of(dir.to_str() - + ~"PacketBuffered")], + path_global(~[cx.ident_of(~"pipes"), + cx.ident_of(dir.to_str() + + ~"PacketBuffered")], dummy_sp()) .add_tys(~[cx.ty_path_ast_builder( - path(~[cx.ident_of(self.proto.name), + path(~[cx.ident_of(~"super"), self.data_name()], - dummy_sp()) - .add_tys(cx.ty_vars(self.ty_params))), + dummy_sp()) + .add_tys(cx.ty_vars_global(self.ty_params))), self.proto.buffer_ty_path(cx)])), self.ty_params)); }; @@ -303,10 +307,10 @@ impl protocol: gen_init { let body = if !self.is_bounded() { match start_state.dir { - send => quote_expr!( pipes::entangle() ), + send => quote_expr!( ::pipes::entangle() ), recv => { quote_expr!({ - let (s, c) = pipes::entangle(); + let (s, c) = ::pipes::entangle(); (move c, move s) }) } @@ -338,7 +342,7 @@ impl protocol: gen_init { let fty = s.to_ty(ext_cx); ext_cx.field_imm(ext_cx.ident_of(s.name), quote_expr!( - pipes::mk_packet::<$fty>() + ::pipes::mk_packet::<$fty>() )) })) } @@ -347,7 +351,7 @@ impl protocol: gen_init { debug!("gen_init_bounded"); let buffer_fields = self.gen_buffer_init(ext_cx); let buffer = quote_expr!( - ~{header: pipes::BufferHeader(), + ~{header: ::pipes::BufferHeader(), data: $buffer_fields} ); @@ -358,12 +362,12 @@ impl protocol: gen_init { fmt!("data.%s.set_buffer_(buffer)", s.name))), ext_cx.parse_expr( - fmt!("ptr::addr_of(&(data.%s))", + fmt!("::ptr::addr_of(&(data.%s))", self.states[0].name)))); quote_expr!({ let buffer = $buffer; - do pipes::entangle_buffer(move buffer) |buffer, data| { + do ::pipes::entangle_buffer(move buffer) |buffer, data| { $entangle_body } }) @@ -381,7 +385,7 @@ impl protocol: gen_init { } cx.ty_path_ast_builder(path(~[cx.ident_of(~"__Buffer")], self.span) - .add_tys(cx.ty_vars(params))) + .add_tys(cx.ty_vars_global(params))) } fn gen_buffer_type(cx: ext_ctxt) -> @ast::item { @@ -395,7 +399,7 @@ impl protocol: gen_init { } } let ty = s.to_ty(cx); - let fty = quote_ty!( pipes::Packet<$ty> ); + let fty = quote_ty!( ::pipes::Packet<$ty> ); cx.ty_field_imm(cx.ident_of(s.name), fty) }; diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 76757d027a5c8..baa0a046241a7 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use to_str::ToStr; -use dvec::DVec; - +use ast; use ext::pipes::ast_builder::{path, append_types}; +use core::cmp; +use core::dvec::DVec; +use core::to_str::ToStr; + enum direction { send, recv } impl direction : cmp::Eq { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index c498c3407c28a..8925bc9b77b08 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -8,12 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use mod ast; -use mod parse::token; - +use ast; +use attr; use codemap::{span, BytePos}; use ext::base::ext_ctxt; +use ext::base; +use ext::build; use parse::token::*; +use parse::token; +use parse; /** * @@ -27,6 +30,9 @@ use parse::token::*; */ pub mod rt { + use ast; + use parse; + pub use ast::*; pub use parse::token::*; pub use parse::new_parser_from_tts; @@ -577,15 +583,15 @@ fn expand_parse_call(cx: ext_ctxt, id_ext(cx, ~"parse_sess")), ~[]); let new_parser_call = - build::mk_call(cx, sp, - ids_ext(cx, ~[~"syntax", - ~"ext", - ~"quote", - ~"rt", - ~"new_parser_from_tts"]), - ~[parse_sess_call(), - cfg_call(), - tts_expr]); + build::mk_call_global(cx, sp, + ids_ext(cx, ~[~"syntax", + ~"ext", + ~"quote", + ~"rt", + ~"new_parser_from_tts"]), + ~[parse_sess_call(), + cfg_call(), + tts_expr]); build::mk_call_(cx, sp, build::mk_access_(cx, sp, new_parser_call, diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 099764a3278b4..31d4a8a7a76cf 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ext::base::*; +use codemap; use codemap::{span, Loc, FileMap}; -use print::pprust; +use ext::base; +use ext::base::*; use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_uniq_str}; +use print::pprust; export expand_line; export expand_col; diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index 6bf7437e15277..c202778d0df59 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -8,7 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use ast; use codemap::span; +use ext::base; use ext::base::ext_ctxt; use ast::tt_delim; use parse::lexer::{new_tt_reader, reader}; diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index ad4677942accd..7b815ce401c84 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -9,19 +9,19 @@ // except according to those terms. // Earley-like parser for macros. -use parse::token; -use parse::token::{Token, EOF, to_str, nonterminal}; -use parse::lexer::*; //resolve bug? -//import parse::lexer::{reader, tt_reader, tt_reader_as_reader}; -use parse::parser::Parser; -//import parse::common::parser_common; -use parse::common::*; //resolve bug? -use parse::parse_sess; -use dvec::DVec; use ast::{matcher, match_tok, match_seq, match_nonterminal, ident}; use ast_util::mk_sp; -use std::map::HashMap; use codemap::BytePos; +use codemap; +use parse::common::*; //resolve bug? +use parse::lexer::*; //resolve bug? +use parse::parse_sess; +use parse::parser::Parser; +use parse::token::{Token, EOF, to_str, nonterminal}; +use parse::token; + +use core::dvec::DVec; +use std::map::HashMap; /* This is an Earley-like parser, without support for in-grammar nonterminals, only by calling out to the main rust parser for named nonterminals (which it diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index e93f3d6e38b24..822b4b01425ca 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -8,19 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ext::base::{ext_ctxt, mac_result, mr_any, mr_def, normal_tt}; +use ast::{ident, matcher_, matcher, match_tok, match_nonterminal, match_seq}; +use ast::{tt_delim}; +use ast; +use ast_util::dummy_sp; use codemap::span; -use ast::{ident, matcher_, matcher, match_tok, - match_nonterminal, match_seq, tt_delim}; +use ext::base::{ext_ctxt, mac_result, mr_any, mr_def, normal_tt}; +use ext::base; +use ext::tt::macro_parser::{error}; +use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; +use ext::tt::macro_parser::{parse, parse_or_else, success, failure}; use parse::lexer::{new_tt_reader, reader}; -use parse::token::{FAT_ARROW, SEMI, LBRACE, RBRACE, nt_matchers, nt_tt}; use parse::parser::Parser; -use ext::tt::macro_parser::{parse, parse_or_else, success, failure, - named_match, matched_seq, matched_nonterminal, - error}; -use std::map::HashMap; use parse::token::special_idents; -use ast_util::dummy_sp; +use parse::token::{FAT_ARROW, SEMI, LBRACE, RBRACE, nt_matchers, nt_tt}; +use print; + +use std::map::HashMap; fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, arg: ~[ast::token_tree]) -> base::mac_result { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index a68482ea46b36..880b336e47383 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -8,11 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use diagnostic::span_handler; +use ast; use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,ident}; -use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; +use ast_util; use codemap::span; +use diagnostic::span_handler; +use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident, ident_interner}; + +use std; use std::map::HashMap; export tt_reader, new_tt_reader, dup_tt_reader, tt_next_token; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 93845f3dbb859..ed2dcc2add4b4 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use codemap::span; use ast::*; +use ast; +use codemap::span; export ast_fold_precursor; export ast_fold; diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index a4bef47fdf290..a3fd069afbb8d 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use either::{Either, Left, Right}; +use ast; use ast_util::spanned; use parse::common::*; //resolve bug? +use parse::token; + +use core::either::{Either, Left, Right}; export parser_attr; diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 0ff5c296125f0..7f57c77783366 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -12,6 +12,7 @@ Predicates on exprs and stmts that the pretty-printer and parser use */ +use ast; use ast_util::operator_prec; fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 22b40736748b5..9324c0047fceb 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -8,11 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use io::ReaderUtil; +use ast; +use codemap::{CodeMap, FileMap, CharPos}; +use diagnostic; +use parse::lexer::{is_whitespace, get_str_from, reader}; +use parse::lexer::{string_reader, bump, is_eof, nextch}; +use parse::lexer; +use parse::token; +use parse; use util::interner; -use parse::lexer::{string_reader, bump, is_eof, nextch, - is_whitespace, get_str_from, reader}; -use codemap::{FileMap, CharPos}; + +use core::io::ReaderUtil; export cmnt; export lit; diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 246a8fa9c7c55..0abe2a364cc4e 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -8,10 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::map::{HashMap}; +use ast; use ast_util::spanned; -use parse::parser::Parser; use parse::lexer::reader; +use parse::parser::Parser; +use parse::token; + +use std::map::HashMap; type seq_sep = { sep: Option, diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index c4e34311b8898..aed0d6e6f30c7 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -8,10 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use diagnostic::span_handler; +use ast; +use ast_util; use codemap::{span, CodeMap, CharPos, BytePos}; -use ext::tt::transcribe::{tt_reader, new_tt_reader, dup_tt_reader, - tt_next_token}; +use codemap; +use diagnostic::span_handler; +use ext::tt::transcribe::{tt_next_token}; +use ext::tt::transcribe::{tt_reader, new_tt_reader, dup_tt_reader}; +use parse::token; + +use std; export reader, string_reader, new_string_reader, is_whitespace; export tt_reader, new_tt_reader; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 803135f7599e2..0d5c48daf0dab 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -12,6 +12,17 @@ #[legacy_exports]; +use ast::node_id; +use ast; +use codemap::{span, CodeMap, FileMap, CharPos, BytePos}; +use codemap; +use diagnostic::{span_handler, mk_span_handler, mk_handler, emitter}; +use parse::attr::parser_attr; +use parse::lexer::{reader, string_reader}; +use parse::parser::Parser; +use parse::token::{ident_interner, mk_ident_interner}; +use util::interner; + export parser; export common; export lexer; @@ -36,15 +47,6 @@ export parse_stmt_from_source_str; export parse_tts_from_source_str; export parse_from_source_str; -use ast::node_id; -use codemap::{span, CodeMap, FileMap, CharPos, BytePos}; -use diagnostic::{span_handler, mk_span_handler, mk_handler, emitter}; -use parse::attr::parser_attr; -use parse::lexer::{reader, string_reader}; -use parse::parser::Parser; -use parse::token::{ident_interner, mk_ident_interner}; -use util::interner; - #[legacy_exports] mod lexer; diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 3db635f3b431d..c64941b33805c 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -17,10 +17,12 @@ Obsolete syntax that becomes too hard to parse can be removed. */ -use codemap::span; use ast::{expr, expr_lit, lit_nil}; +use ast; use ast_util::{respan}; +use codemap::span; use parse::token::Token; +use parse::token; /// The specific types of unsupported syntax pub enum ObsoleteSyntax { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 47f65ed2f8d37..45c3b1a6aa693 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -8,30 +8,32 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use ast; +use classify; use print::pprust::expr_to_str; - -use result::Result; +use core::result::Result; use either::{Either, Left, Right}; use std::map::HashMap; use parse::token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident, INTERPOLATED, special_idents}; use codemap::{span,FssNone, BytePos}; +use codemap; use util::interner::Interner; use ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec}; +use ast_util; +use parse::token; use parse::lexer::reader; use parse::prec::{as_prec, token_to_binop}; use parse::attr::parser_attr; -use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed, - seq_sep_none, token_to_str}; -use dvec::DVec; -use vec::{push}; -use parse::obsolete::{ - ObsoleteSyntax, - ObsoleteLowerCaseKindBounds, ObsoleteLet, - ObsoleteFieldTerminator, ObsoleteStructCtor, - ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits, - ObsoleteModeInFnType, ObsoleteMoveInit, ObsoleteBinaryMove, -}; +use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed}; +use parse::common::{seq_sep_none, token_to_str}; +use core::dvec::DVec; +use core::vec::push; +use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; +use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator}; +use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith, ObsoleteClassMethod}; +use parse::obsolete::{ObsoleteClassTraits, ObsoleteModeInFnType}; +use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove}; use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer, bind_by_value, bind_by_move, bitand, bitor, bitxor, blk, blk_check_mode, box, by_copy, @@ -195,7 +197,7 @@ fn Parser(sess: parse_sess, cfg: ast::crate_cfg, keywords: token::keyword_table(), strict_keywords: token::strict_keyword_table(), reserved_keywords: token::reserved_keyword_table(), - obsolete_set: std::map::HashMap(), + obsolete_set: HashMap(), mod_path_stack: ~[], } } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 7e7c61d2bf249..7bafa8b88e98a 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -8,8 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use util::interner; +use ast; +use ast_util; +use parse::token; use util::interner::Interner; +use util::interner; + use std::map::HashMap; #[auto_serialize] @@ -332,7 +336,7 @@ mod special_idents { } struct ident_interner { - priv interner: util::interner::Interner<@~str>, + priv interner: Interner<@~str>, } impl ident_interner { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e977327e919b4..c3929a5768ecb 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -8,16 +8,26 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use parse::{comments, lexer, token}; -use codemap::{CodeMap, BytePos}; -use print::pp::{break_offset, word, printer, space, zerobreak, hardbreak}; -use print::pp::{breaks, consistent, inconsistent, eof}; use ast::{required, provided}; +use ast; +use ast_util; use ast_util::{operator_prec}; -use dvec::DVec; +use attr; +use codemap::{CodeMap, BytePos}; +use codemap; +use diagnostic; use parse::classify::*; use parse::token::ident_interner; -use str::{push_str, push_char}; +use parse::token; +use parse::{comments, lexer, token}; +use parse; +use print::pp::{break_offset, word, printer, space, zerobreak, hardbreak}; +use print::pp::{breaks, consistent, inconsistent, eof}; +use print::pp; +use print::pprust; + +use core::dvec::DVec; +use core::str::{push_str, push_char}; // The ps is stored here to prevent recursive type. enum ann_node { diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc index 6013178c5eea9..18043c699f570 100644 --- a/src/libsyntax/syntax.rc +++ b/src/libsyntax/syntax.rc @@ -16,8 +16,6 @@ #[crate_type = "lib"]; -#[no_core]; - #[legacy_modes]; #[legacy_exports]; @@ -26,11 +24,8 @@ #[allow(deprecated_mode)]; #[warn(deprecated_pattern)]; -extern mod core(vers = "0.5"); extern mod std(vers = "0.5"); -use core::*; - pub mod syntax { pub use ext; pub use parse; diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 7b406564114b8..2008d7f9178c2 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - use ast::*; +use ast; +use ast_util; use codemap::span; +use parse; // Context-passing AST walker. Each overridden visit method has full control // over what happens with its node, it can do its own traversal of the node's diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs new file mode 100644 index 0000000000000..0eb922643c620 --- /dev/null +++ b/src/test/run-pass/super.rs @@ -0,0 +1,12 @@ +pub mod a { + pub fn f() {} + pub mod b { + fn g() { + super::f(); + } + } +} + +fn main() { +} +