diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index 2ff6305548083..b46b09781ca38 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -537,11 +537,12 @@ extern crate core; use core::prelude::*; use core::mem; -use core::raw::Slice; #[no_mangle] pub extern fn dot_product(a: *const u32, a_len: u32, b: *const u32, b_len: u32) -> u32 { + use core::raw::Slice; + // Convert the provided arrays into Rust slices. // The core::raw module guarantees that the Slice // structure has the same memory layout as a &[T] diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 7745a0d887ee8..244fa4800d740 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -68,12 +68,11 @@ use core::default::Default; use core::fmt; use core::iter::Take; use core::iter; -use core::ops::Index; use core::slice; use core::uint; use std::hash; -use {Collection, Mutable, Set, MutableSet, MutableSeq}; +use {Mutable, Set, MutableSet, MutableSeq}; use vec::Vec; diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 4c5f8ef09879e..166d2c6c7901f 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -24,7 +24,7 @@ use alloc::boxed::Box; use core::fmt; use core::fmt::Show; -use {Collection, MutableSeq}; +use MutableSeq; use vec::Vec; #[allow(missing_doc)] diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 8344ad7c79d7b..6f47780a0e6f5 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -31,7 +31,7 @@ use core::mem; use core::ptr; use std::hash::{Writer, Hash}; -use {Collection, Mutable, Deque, MutableSeq}; +use {Mutable, Deque, MutableSeq}; /// A doubly-linked list. pub struct DList { diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index d2d8ad696d7c5..5fdcee14f891e 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -22,9 +22,12 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(macro_rules, managed_boxes, default_type_params, phase, globs)] -#![feature(unsafe_destructor)] +#![feature(unsafe_destructor, import_shadowing)] #![no_std] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + #[phase(plugin, link)] extern crate core; extern crate unicode; extern crate alloc; @@ -36,11 +39,11 @@ extern crate alloc; #[cfg(test)] #[phase(plugin, link)] extern crate std; #[cfg(test)] #[phase(plugin, link)] extern crate log; -use core::prelude::*; +use core::prelude::Option; -pub use core::collections::Collection; pub use bitv::{Bitv, BitvSet}; pub use btree::BTree; +pub use core::prelude::Collection; pub use dlist::DList; pub use enum_set::EnumSet; pub use priority_queue::PriorityQueue; diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index a88a833c9edca..34cc02258157f 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -154,7 +154,7 @@ use core::default::Default; use core::mem::{zeroed, replace, swap}; use core::ptr; -use {Collection, Mutable, MutableSeq}; +use {Mutable, MutableSeq}; use slice; use vec::Vec; diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 354beb56d2dc3..9d074813343b3 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -18,11 +18,10 @@ use core::prelude::*; use core::cmp; use core::default::Default; use core::fmt; -use core::iter::RandomAccessIterator; use core::iter; use std::hash::{Writer, Hash}; -use {Deque, Collection, Mutable, MutableSeq}; +use {Deque, Mutable, MutableSeq}; use vec::Vec; static INITIAL_CAPACITY: uint = 8u; // 2^3 diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index aac5b24fa6f02..7190bbfbc012c 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -86,23 +86,22 @@ for &x in numbers.iter() { #![doc(primitive = "slice")] -use core::prelude::*; - use core::cmp; use core::mem::size_of; use core::mem; +use core::prelude::{Clone, Collection, Greater, Iterator, Less, None, Option}; +use core::prelude::{Ord, Ordering, RawPtr, Some, range}; use core::ptr; use core::iter::{range_step, MultiplicativeIterator}; -use {Collection, MutableSeq}; +use MutableSeq; use vec::Vec; -pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows}; pub use core::slice::{Chunks, Slice, ImmutableSlice, ImmutablePartialEqSlice}; pub use core::slice::{ImmutableOrdSlice, MutableSlice, Items, MutItems}; -pub use core::slice::{MutSplits, MutChunks}; -pub use core::slice::{bytes, MutableCloneableSlice}; -pub use core::slice::{BinarySearchResult, Found, NotFound}; +pub use core::slice::{MutSplits, MutChunks, Splits}; +pub use core::slice::{bytes, ref_slice, MutableCloneableSlice}; +pub use core::slice::{Found, NotFound}; // Functional utilities diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 4529c8782a194..44db9147226b0 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -21,7 +21,7 @@ use core::iter; use core::iter::{Enumerate, FilterMap}; use core::mem::replace; -use {Collection, Mutable, Map, MutableMap, MutableSeq}; +use {Mutable, Map, MutableMap, MutableSeq}; use {vec, slice}; use vec::Vec; use hash; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 60ee8cc04f74c..1c50b228bb8de 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -69,15 +69,17 @@ is the same as `&[u8]`. #![doc(primitive = "str")] -use core::prelude::*; - use core::default::Default; use core::fmt; use core::cmp; use core::iter::AdditiveIterator; use core::mem; +use core::prelude::{Char, Clone, Collection, Eq, Equiv, ImmutableSlice}; +use core::prelude::{Iterator, MutableSlice, None, Option, Ord, Ordering}; +use core::prelude::{PartialEq, PartialOrd, Result, Slice, Some, Tuple2}; +use core::prelude::{range}; -use {Collection, Deque, MutableSeq}; +use {Deque, MutableSeq}; use hash; use ringbuf::RingBuf; use string::String; diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 3b9e2ac72dc4b..fb2dc5ffb112b 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -20,9 +20,8 @@ use core::mem; use core::ptr; // FIXME: ICE's abound if you import the `Slice` type while importing `Slice` trait use RawSlice = core::raw::Slice; -use core::slice::Slice; -use {Collection, Mutable, MutableSeq}; +use {Mutable, MutableSeq}; use hash; use str; use str::{CharRange, StrAllocating, MaybeOwned, Owned}; diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index ae87411133f4f..7787893925d53 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -40,7 +40,7 @@ use core::mem::{replace, swap}; use core::ptr; use std::hash::{Writer, Hash}; -use {Collection, Mutable, Set, MutableSet, MutableMap, Map, MutableSeq}; +use {Mutable, Set, MutableSet, MutableMap, Map, MutableSeq}; use vec::Vec; /// This is implemented as an AA tree, which is a simplified variation of diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index dcfe256807467..911262e90cba7 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -23,7 +23,7 @@ use core::uint; use core::iter; use std::hash::{Writer, Hash}; -use {Collection, Mutable, Map, MutableMap, Set, MutableSet}; +use {Mutable, Map, MutableMap, Set, MutableSet}; use slice::{Items, MutItems}; use slice; diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index b49e8aa01bb41..3c705580f6354 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -14,17 +14,15 @@ use core::prelude::*; use alloc::heap::{allocate, reallocate, deallocate}; use RawSlice = core::raw::Slice; -use core::slice::Slice; use core::cmp::max; use core::default::Default; use core::fmt; use core::mem; -use core::num::{CheckedMul, CheckedAdd}; use core::num; use core::ptr; use core::uint; -use {Collection, Mutable, MutableSeq}; +use {Mutable, MutableSeq}; use slice::{MutableOrdSlice, MutableSliceAllocating, CloneableVector}; use slice::{Items, MutItems}; diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 942f7f8b71019..28fe6434462b7 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -14,12 +14,10 @@ use any; use cell::{Cell, Ref, RefMut}; -use char::Char; use collections::Collection; use iter::{Iterator, range}; use kinds::Copy; use mem; -use num::Float; use option::{Option, Some, None}; use ops::Deref; use result::{Ok, Err}; @@ -342,8 +340,12 @@ impl<'a> Formatter<'a> { /// /// This function will correctly account for the flags provided as well as /// the minimum width. It will not take precision into account. - pub fn pad_integral(&mut self, is_positive: bool, prefix: &str, - buf: &[u8]) -> Result { + pub fn pad_integral(&mut self, + is_positive: bool, + prefix: &str, + buf: &[u8]) + -> Result { + use char::Char; use fmt::rt::{FlagAlternate, FlagSignPlus, FlagSignAwareZeroPad}; let mut width = buf.len(); @@ -456,6 +458,7 @@ impl<'a> Formatter<'a> { padding: uint, default: rt::Alignment, f: |&mut Formatter| -> Result) -> Result { + use char::Char; let align = match self.align { rt::AlignUnknown => default, rt::AlignLeft | rt::AlignRight => self.align @@ -539,6 +542,8 @@ impl<'a, T: str::Str> String for T { impl Char for char { fn fmt(&self, f: &mut Formatter) -> Result { + use char::Char; + let mut utf8 = [0u8, ..4]; let amt = self.encode_utf8(utf8); let s: &str = unsafe { mem::transmute(utf8.slice_to(amt)) }; @@ -571,7 +576,7 @@ impl<'a, T> Pointer for &'a mut T { macro_rules! floating(($ty:ident) => { impl Float for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { - use num::Signed; + use num::{Float, Signed}; let digits = match fmt.precision { Some(i) => float::DigExact(i), @@ -592,7 +597,7 @@ macro_rules! floating(($ty:ident) => { impl LowerExp for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { - use num::Signed; + use num::{Float, Signed}; let digits = match fmt.precision { Some(i) => float::DigExact(i), @@ -613,7 +618,7 @@ macro_rules! floating(($ty:ident) => { impl UpperExp for $ty { fn fmt(&self, fmt: &mut Formatter) -> Result { - use num::Signed; + use num::{Float, Signed}; let digits = match fmt.precision { Some(i) => float::DigExact(i), diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 3350d8f548a86..d41035d3a160f 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -19,7 +19,10 @@ #![license = "MIT/ASL2"] #![crate_type = "rlib"] #![crate_type = "dylib"] -#![feature(macro_rules, globs)] +#![feature(macro_rules, globs, import_shadowing)] + +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] use std::char; use std::str; diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 6339dc5844620..3286c329755a6 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -88,8 +88,12 @@ html_root_url = "http://doc.rust-lang.org/master/", html_playground_url = "http://play.rust-lang.org/")] #![feature(globs, phase)] +#![feature(import_shadowing)] #![deny(missing_doc)] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + #[cfg(test)] extern crate debug; #[cfg(test)] #[phase(plugin, link)] extern crate log; diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index c005ae7148051..bf0a9f06df896 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -226,7 +226,7 @@ pub use funcs::bsd43::{shutdown}; #[cfg(windows)] pub use consts::os::extra::{FILE_FLAG_BACKUP_SEMANTICS, INVALID_HANDLE_VALUE}; #[cfg(windows)] pub use consts::os::extra::{MOVEFILE_REPLACE_EXISTING}; #[cfg(windows)] pub use consts::os::extra::{GENERIC_READ, GENERIC_WRITE}; -#[cfg(windows)] pub use consts::os::extra::{VOLUME_NAME_DOS, FILE_ATTRIBUTE_NORMAL}; +#[cfg(windows)] pub use consts::os::extra::{VOLUME_NAME_DOS}; #[cfg(windows)] pub use consts::os::extra::{PIPE_ACCESS_DUPLEX, FILE_FLAG_FIRST_PIPE_INSTANCE}; #[cfg(windows)] pub use consts::os::extra::{FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE}; #[cfg(windows)] pub use consts::os::extra::{PIPE_READMODE_BYTE, PIPE_WAIT}; @@ -255,10 +255,10 @@ pub use funcs::bsd43::{shutdown}; #[cfg(windows)] pub use funcs::extra::kernel32::{UnmapViewOfFile, CloseHandle}; #[cfg(windows)] pub use funcs::extra::kernel32::{WaitForSingleObject, GetSystemTimeAsFileTime}; #[cfg(windows)] pub use funcs::extra::kernel32::{QueryPerformanceCounter}; -#[cfg(windows)] pub use funcs::extra::kernel32::{WaitForSingleObject, QueryPerformanceFrequency}; +#[cfg(windows)] pub use funcs::extra::kernel32::{QueryPerformanceFrequency}; #[cfg(windows)] pub use funcs::extra::kernel32::{GetExitCodeProcess, TerminateProcess}; #[cfg(windows)] pub use funcs::extra::kernel32::{ReadFile, WriteFile, SetFilePointerEx}; -#[cfg(windows)] pub use funcs::extra::kernel32::{FlushFileBuffers, SetEndOfFile, CreateFileW}; +#[cfg(windows)] pub use funcs::extra::kernel32::{SetEndOfFile, CreateFileW}; #[cfg(windows)] pub use funcs::extra::kernel32::{CreateDirectoryW, FindFirstFileW}; #[cfg(windows)] pub use funcs::extra::kernel32::{FindNextFileW, FindClose, DeleteFileW}; #[cfg(windows)] pub use funcs::extra::kernel32::{CreateHardLinkW, CreateEventW}; diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index faafbc4421e24..9d401d1307ce2 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -24,7 +24,6 @@ that do not need to record state. use core::prelude::*; use core::num; -use core::num::CheckedAdd; use {Rng, Rand}; diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index a6b23957fd648..2e048cb029d4a 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -35,12 +35,11 @@ use distributions::{Sample, IndependentSample}; /// # Example /// /// ```rust -/// use std::rand; /// use std::rand::distributions::{IndependentSample, Range}; /// /// fn main() { /// let between = Range::new(10u, 10000u); -/// let mut rng = rand::task_rng(); +/// let mut rng = std::rand::task_rng(); /// let mut sum = 0; /// for _ in range(0u, 1000) { /// sum += between.ind_sample(&mut rng); diff --git a/src/librlibc/lib.rs b/src/librlibc/lib.rs index 706b5c3325576..739ec2cf43ffe 100644 --- a/src/librlibc/lib.rs +++ b/src/librlibc/lib.rs @@ -28,13 +28,16 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(intrinsics, phase)] +#![feature(import_shadowing, intrinsics, phase)] #![no_std] // This library defines the builtin functions, so it would be a shame for // LLVM to optimize these function calls to themselves! #![no_builtins] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + #[cfg(test)] extern crate native; #[cfg(test)] extern crate test; #[cfg(test)] extern crate debug; diff --git a/src/librustc/front/feature_gate.rs b/src/librustc/front/feature_gate.rs index fdfbdea245bb2..7c19b25e01cd7 100644 --- a/src/librustc/front/feature_gate.rs +++ b/src/librustc/front/feature_gate.rs @@ -68,6 +68,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("rustc_diagnostic_macros", Active), ("unboxed_closures", Active), + ("import_shadowing", Active), // if you change this list without updating src/doc/rust.md, cmr will be sad @@ -98,7 +99,8 @@ pub struct Features { pub default_type_params: Cell, pub issue_5723_bootstrap: Cell, pub overloaded_calls: Cell, - pub rustc_diagnostic_macros: Cell + pub rustc_diagnostic_macros: Cell, + pub import_shadowing: Cell, } impl Features { @@ -107,7 +109,8 @@ impl Features { default_type_params: Cell::new(false), issue_5723_bootstrap: Cell::new(false), overloaded_calls: Cell::new(false), - rustc_diagnostic_macros: Cell::new(false) + rustc_diagnostic_macros: Cell::new(false), + import_shadowing: Cell::new(false), } } } @@ -439,4 +442,6 @@ pub fn check_crate(sess: &Session, krate: &ast::Crate) { sess.features.issue_5723_bootstrap.set(cx.has_feature("issue_5723_bootstrap")); sess.features.overloaded_calls.set(cx.has_feature("overloaded_calls")); sess.features.rustc_diagnostic_macros.set(cx.has_feature("rustc_diagnostic_macros")); + sess.features.import_shadowing.set(cx.has_feature("import_shadowing")); } + diff --git a/src/librustc/front/std_inject.rs b/src/librustc/front/std_inject.rs index 5dca09faf34b0..ff8711c5df01f 100644 --- a/src/librustc/front/std_inject.rs +++ b/src/librustc/front/std_inject.rs @@ -19,6 +19,7 @@ use syntax::fold::Folder; use syntax::fold; use syntax::owned_slice::OwnedSlice; use syntax::parse::token::InternedString; +use syntax::parse::token::special_idents; use syntax::parse::token; use syntax::util::small_vector::SmallVector; @@ -197,7 +198,19 @@ impl<'a> fold::Folder for PreludeInjector<'a> { ast::DUMMY_NODE_ID)); let vi2 = ast::ViewItem { node: ast::ViewItemUse(vp), - attrs: Vec::new(), + attrs: vec!(ast::Attribute { + span: DUMMY_SP, + node: ast::Attribute_ { + id: attr::mk_attr_id(), + style: ast::AttrOuter, + value: box(GC) ast::MetaItem { + span: DUMMY_SP, + node: ast::MetaWord(token::get_name( + special_idents::prelude_import.name)), + }, + is_sugared_doc: false, + }, + }), vis: ast::Inherited, span: DUMMY_SP, }; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index f9774e83e8a1c..239e858eeeb12 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -34,6 +34,7 @@ This API is completely unstable and subject to change. #![allow(unknown_features)] // NOTE: Remove after next snapshot #![feature(rustc_diagnostic_macros)] +#![feature(import_shadowing)] extern crate arena; extern crate debug; diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 738c5d9be7907..7e0ba613e3db5 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -581,6 +581,9 @@ impl LintPass for UnusedAttribute { "thread_local", "no_debug", + // used in resolve + "prelude_import", + // not used anywhere (!?) but apparently we want to keep them around "comment", "desc", diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 1d426aaaf5c91..29b5db51cc429 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -42,7 +42,6 @@ use syntax::ast_map::{PathElem, PathElems}; use syntax::ast_map; use syntax::ast_util::*; use syntax::ast_util; -use syntax::ast_util::PostExpansionMethod; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::diagnostic::SpanHandler; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 26cb2f25129aa..ff2830421e065 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -47,8 +47,8 @@ use rbml::io::SeekableMemWriter; use rbml::{reader, writer}; use rbml; use serialize; -use serialize::{Encoder, Encodable, EncoderHelpers, DecoderHelpers}; -use serialize::{Decoder, Decodable}; +use serialize::{Decodable, Decoder, DecoderHelpers, Encodable}; +use serialize::{EncoderHelpers}; #[cfg(test)] use syntax::parse; #[cfg(test)] use syntax::print::pprust; @@ -620,6 +620,8 @@ fn encode_method_callee(ecx: &e::EncodeContext, rbml_w: &mut Encoder, adjustment: typeck::ExprAdjustment, method: &MethodCallee) { + use serialize::Encoder; + rbml_w.emit_struct("MethodCallee", 4, |rbml_w| { rbml_w.emit_struct_field("adjustment", 0u, |rbml_w| { adjustment.encode(rbml_w) @@ -695,6 +697,8 @@ fn encode_vtable_res_with_key(ecx: &e::EncodeContext, rbml_w: &mut Encoder, adjustment: typeck::ExprAdjustment, dr: &typeck::vtable_res) { + use serialize::Encoder; + rbml_w.emit_struct("VtableWithKey", 2, |rbml_w| { rbml_w.emit_struct_field("adjustment", 0u, |rbml_w| { adjustment.encode(rbml_w) @@ -728,6 +732,8 @@ pub fn encode_vtable_param_res(ecx: &e::EncodeContext, pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder, kind: ty::UnboxedClosureKind) { + use serialize::Encoder; + ebml_w.emit_enum("UnboxedClosureKind", |ebml_w| { match kind { ty::FnUnboxedClosureKind => { @@ -755,6 +761,8 @@ pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder, pub fn encode_vtable_origin(ecx: &e::EncodeContext, rbml_w: &mut Encoder, vtable_origin: &typeck::vtable_origin) { + use serialize::Encoder; + rbml_w.emit_enum("vtable_origin", |rbml_w| { match *vtable_origin { typeck::vtable_static(def_id, ref substs, ref vtable_res) => { @@ -985,6 +993,8 @@ impl<'a> rbml_writer_helpers for Encoder<'a> { fn emit_polytype(&mut self, ecx: &e::EncodeContext, pty: ty::Polytype) { + use serialize::Encoder; + self.emit_struct("Polytype", 2, |this| { this.emit_struct_field("generics", 0, |this| { this.emit_struct("Generics", 2, |this| { @@ -1013,6 +1023,8 @@ impl<'a> rbml_writer_helpers for Encoder<'a> { } fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment) { + use serialize::Encoder; + self.emit_enum("AutoAdjustment", |this| { match *adj { ty::AutoAddEnv(store) => { diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 3ce6f72610095..bd779b865d695 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -21,10 +21,31 @@ use middle::subst::{ParamSpace, FnSpace, TypeSpace}; use middle::ty::{ExplicitSelfCategory, StaticExplicitSelfCategory}; use util::nodemap::{NodeMap, DefIdSet, FnvHashMap}; -use syntax::ast::*; +use syntax::ast::{Arm, BindByRef, BindByValue, BindingMode, Block, Crate}; +use syntax::ast::{DeclItem, DefId, Expr, ExprAgain, ExprBreak, ExprField}; +use syntax::ast::{ExprFnBlock, ExprForLoop, ExprLoop, ExprMethodCall}; +use syntax::ast::{ExprPath, ExprProc, ExprStruct, ExprUnboxedFn, FnDecl}; +use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic, Generics}; +use syntax::ast::{Ident, ImplItem, Item, ItemEnum, ItemFn, ItemForeignMod}; +use syntax::ast::{ItemImpl, ItemMac, ItemMod, ItemStatic, ItemStruct}; +use syntax::ast::{ItemTrait, ItemTy, LOCAL_CRATE, Local, Method}; +use syntax::ast::{MethodImplItem, Mod, Name, NamedField, NodeId}; +use syntax::ast::{OtherRegionTyParamBound, P, Pat, PatEnum, PatIdent, PatLit}; +use syntax::ast::{PatRange, PatStruct, Path, PathListIdent, PathListMod}; +use syntax::ast::{PrimTy, Public, SelfExplicit, SelfStatic}; +use syntax::ast::{StaticRegionTyParamBound, StmtDecl, StructField}; +use syntax::ast::{StructVariantKind, TraitRef, TraitTyParamBound}; +use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32}; +use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt}; +use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyProc, TyRptr}; +use syntax::ast::{TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint}; +use syntax::ast::{UnboxedFnTyParamBound, UnnamedField, UnsafeFn, Variant}; +use syntax::ast::{ViewItem, ViewItemExternCrate, ViewItemUse, ViewPathGlob}; +use syntax::ast::{ViewPathList, ViewPathSimple, Visibility}; use syntax::ast; -use syntax::ast_util::{local_def, PostExpansionMethod}; -use syntax::ast_util::{walk_pat, trait_item_to_ty_method}; +use syntax::ast_util::{PostExpansionMethod, local_def}; +use syntax::ast_util::{trait_item_to_ty_method, walk_pat}; +use syntax::attr::AttrMetaMethods; use syntax::ext::mtwt; use syntax::parse::token::special_names; use syntax::parse::token::special_idents; @@ -355,6 +376,7 @@ struct ImportDirective { span: Span, id: NodeId, is_public: bool, // see note in ImportResolution about how to use this + shadowable: bool, } impl ImportDirective { @@ -362,7 +384,8 @@ impl ImportDirective { subclass: ImportDirectiveSubclass, span: Span, id: NodeId, - is_public: bool) + is_public: bool, + shadowable: bool) -> ImportDirective { ImportDirective { module_path: module_path, @@ -370,6 +393,7 @@ impl ImportDirective { span: span, id: id, is_public: is_public, + shadowable: shadowable, } } } @@ -379,13 +403,18 @@ impl ImportDirective { struct Target { target_module: Rc, bindings: Rc, + shadowable: bool, } impl Target { - fn new(target_module: Rc, bindings: Rc) -> Target { + fn new(target_module: Rc, + bindings: Rc, + shadowable: bool) + -> Target { Target { target_module: target_module, - bindings: bindings + bindings: bindings, + shadowable: shadowable, } } } @@ -1018,6 +1047,10 @@ impl<'a> Resolver<'a> { let module_ = reduced_graph_parent.module(); + self.check_for_conflicts_between_external_crates_and_items(&*module_, + name.name, + sp); + // Add or reuse the child. let child = module_.children.borrow().find_copy(&name.name); match child { @@ -1481,6 +1514,14 @@ impl<'a> Resolver<'a> { // Build up the import directives. let module_ = parent.module(); let is_public = view_item.vis == ast::Public; + let shadowable = + view_item.attrs + .iter() + .any(|attr| { + attr.name() == token::get_ident( + special_idents::prelude_import) + }); + match view_path.node { ViewPathSimple(binding, ref full_path, id) => { let source_ident = @@ -1497,7 +1538,8 @@ impl<'a> Resolver<'a> { subclass, view_path.span, id, - is_public); + is_public, + shadowable); } ViewPathList(_, ref source_items, _) => { // Make sure there's at most one `mod` import in the list. @@ -1542,7 +1584,9 @@ impl<'a> Resolver<'a> { module_path, SingleImport(name, name), source_item.span, - source_item.node.id(), is_public); + source_item.node.id(), + is_public, + shadowable); } } ViewPathGlob(_, id) => { @@ -1551,7 +1595,8 @@ impl<'a> Resolver<'a> { GlobImport, view_path.span, id, - is_public); + is_public, + shadowable); } } } @@ -1571,6 +1616,10 @@ impl<'a> Resolver<'a> { true)); debug!("(build reduced graph for item) found extern `{}`", self.module_to_string(&*external_module)); + self.check_for_conflicts_between_external_crates( + &*parent.module(), + name.name, + view_item.span); parent.module().external_module_children.borrow_mut() .insert(name.name, external_module.clone()); self.build_reduced_graph_for_external_crate(external_module); @@ -1989,11 +2038,14 @@ impl<'a> Resolver<'a> { subclass: ImportDirectiveSubclass, span: Span, id: NodeId, - is_public: bool) { + is_public: bool, + shadowable: bool) { module_.imports.borrow_mut().push(ImportDirective::new(module_path, subclass, - span, id, - is_public)); + span, + id, + is_public, + shadowable)); self.unresolved_imports += 1; // Bump the reference count on the name. Or, if this is a glob, set // the appropriate flag. @@ -2241,8 +2293,7 @@ impl<'a> Resolver<'a> { resolution_result = self.resolve_glob_import(&*module_, containing_module, - import_directive.id, - import_directive.is_public, + import_directive, lp); } } @@ -2397,7 +2448,11 @@ impl<'a> Resolver<'a> { None => { return UnboundResult; } - Some(Target {target_module, bindings}) => { + Some(Target { + target_module, + bindings, + shadowable: _ + }) => { debug!("(resolving single import) found \ import in ns {:?}", namespace); let id = import_resolution.id(namespace); @@ -2462,8 +2517,16 @@ impl<'a> Resolver<'a> { match value_result { BoundResult(ref target_module, ref name_bindings) => { debug!("(resolving single import) found value target"); - import_resolution.value_target = Some(Target::new(target_module.clone(), - name_bindings.clone())); + self.check_for_conflicting_import( + &import_resolution.value_target, + directive.span, + target.name, + ValueNS); + + import_resolution.value_target = + Some(Target::new(target_module.clone(), + name_bindings.clone(), + directive.shadowable)); import_resolution.value_id = directive.id; import_resolution.is_public = directive.is_public; value_used_public = name_bindings.defined_in_public_namespace(ValueNS); @@ -2477,8 +2540,16 @@ impl<'a> Resolver<'a> { BoundResult(ref target_module, ref name_bindings) => { debug!("(resolving single import) found type target: {:?}", { name_bindings.type_def.borrow().clone().unwrap().type_def }); + self.check_for_conflicting_import( + &import_resolution.type_target, + directive.span, + target.name, + TypeNS); + import_resolution.type_target = - Some(Target::new(target_module.clone(), name_bindings.clone())); + Some(Target::new(target_module.clone(), + name_bindings.clone(), + directive.shadowable)); import_resolution.type_id = directive.id; import_resolution.is_public = directive.is_public; type_used_public = name_bindings.defined_in_public_namespace(TypeNS); @@ -2489,6 +2560,12 @@ impl<'a> Resolver<'a> { } } + self.check_for_conflicts_between_imports_and_items( + module_, + import_resolution, + directive.span, + target.name); + if value_result.is_unbound() && type_result.is_unbound() { let msg = format!("There is no `{}` in `{}`", token::get_ident(source), @@ -2540,10 +2617,12 @@ impl<'a> Resolver<'a> { fn resolve_glob_import(&mut self, module_: &Module, containing_module: Rc, - id: NodeId, - is_public: bool, + import_directive: &ImportDirective, lp: LastPrivate) -> ResolveResult<()> { + let id = import_directive.id; + let is_public = import_directive.is_public; + // This function works in a highly imperative manner; it eagerly adds // everything it can to the list of import resolutions of the module // node. @@ -2619,9 +2698,12 @@ impl<'a> Resolver<'a> { for (&name, name_bindings) in containing_module.children .borrow().iter() { - self.merge_import_resolution(module_, containing_module.clone(), - id, is_public, - name, name_bindings.clone()); + self.merge_import_resolution(module_, + containing_module.clone(), + import_directive, + name, + name_bindings.clone()); + } // Add external module children from the containing module. @@ -2629,9 +2711,11 @@ impl<'a> Resolver<'a> { .borrow().iter() { let name_bindings = Rc::new(Resolver::create_name_bindings_from_module(module.clone())); - self.merge_import_resolution(module_, containing_module.clone(), - id, is_public, - name, name_bindings); + self.merge_import_resolution(module_, + containing_module.clone(), + import_directive, + name, + name_bindings); } // Record the destination of this import @@ -2650,10 +2734,12 @@ impl<'a> Resolver<'a> { fn merge_import_resolution(&mut self, module_: &Module, containing_module: Rc, - id: NodeId, - is_public: bool, + import_directive: &ImportDirective, name: Name, name_bindings: Rc) { + let id = import_directive.id; + let is_public = import_directive.is_public; + let mut import_resolutions = module_.import_resolutions.borrow_mut(); let dest_import_resolution = import_resolutions.find_or_insert_with(name, |_| { // Create a new import resolution from this child. @@ -2670,16 +2756,169 @@ impl<'a> Resolver<'a> { if name_bindings.defined_in_public_namespace(ValueNS) { debug!("(resolving glob import) ... for value target"); dest_import_resolution.value_target = - Some(Target::new(containing_module.clone(), name_bindings.clone())); + Some(Target::new(containing_module.clone(), + name_bindings.clone(), + import_directive.shadowable)); dest_import_resolution.value_id = id; } if name_bindings.defined_in_public_namespace(TypeNS) { debug!("(resolving glob import) ... for type target"); dest_import_resolution.type_target = - Some(Target::new(containing_module, name_bindings.clone())); + Some(Target::new(containing_module, + name_bindings.clone(), + import_directive.shadowable)); dest_import_resolution.type_id = id; } dest_import_resolution.is_public = is_public; + + self.check_for_conflicts_between_imports_and_items( + module_, + dest_import_resolution, + import_directive.span, + name); + } + + /// Checks that imported names and items don't have the same name. + fn check_for_conflicting_import(&mut self, + target: &Option, + import_span: Span, + name: Name, + namespace: Namespace) { + if self.session.features.import_shadowing.get() { + return + } + + match *target { + Some(ref target) if !target.shadowable => { + let msg = format!("a {} named `{}` has already been imported \ + in this module", + match namespace { + TypeNS => "type", + ValueNS => "value", + }, + token::get_name(name).get()); + self.session.span_err(import_span, msg.as_slice()); + } + Some(_) | None => {} + } + } + + /// Checks that imported names and items don't have the same name. + fn check_for_conflicts_between_imports_and_items(&mut self, + module: &Module, + import_resolution: + &mut ImportResolution, + import_span: Span, + name: Name) { + if self.session.features.import_shadowing.get() { + return + } + + // First, check for conflicts between imports and `extern crate`s. + if module.external_module_children + .borrow() + .contains_key(&name) { + match import_resolution.type_target { + Some(ref target) if !target.shadowable => { + self.session.span_err(import_span, + "import conflicts with imported \ + crate in this module"); + } + Some(_) | None => {} + } + } + + // Check for item conflicts. + let children = module.children.borrow(); + let name_bindings = match children.find(&name) { + None => { + // There can't be any conflicts. + return + } + Some(ref name_bindings) => (*name_bindings).clone(), + }; + + match import_resolution.value_target { + Some(ref target) if !target.shadowable => { + match *name_bindings.value_def.borrow() { + None => {} + Some(ref value) => { + self.session.span_err(import_span, + "import conflicts with value \ + in this module"); + match value.value_span { + None => {} + Some(span) => { + self.session + .span_note(span, + "note conflicting value here"); + } + } + } + } + } + Some(_) | None => {} + } + + match import_resolution.type_target { + Some(ref target) if !target.shadowable => { + match *name_bindings.type_def.borrow() { + None => {} + Some(ref ty) => { + self.session.span_err(import_span, + "import conflicts with type in \ + this module"); + match ty.type_span { + None => {} + Some(span) => { + self.session + .span_note(span, + "note conflicting type here") + } + } + } + } + } + Some(_) | None => {} + } + } + + /// Checks that the names of external crates don't collide with other + /// external crates. + fn check_for_conflicts_between_external_crates(&self, + module: &Module, + name: Name, + span: Span) { + if self.session.features.import_shadowing.get() { + return + } + + if module.external_module_children.borrow().contains_key(&name) { + self.session + .span_err(span, + format!("an external crate named `{}` has already \ + been imported into this module", + token::get_name(name).get()).as_slice()); + } + } + + /// Checks that the names of items don't collide with external crates. + fn check_for_conflicts_between_external_crates_and_items(&self, + module: &Module, + name: Name, + span: Span) { + if self.session.features.import_shadowing.get() { + return + } + + if module.external_module_children.borrow().contains_key(&name) { + self.session + .span_err(span, + format!("the name `{}` conflicts with an external \ + crate that has been imported into this \ + module", + token::get_name(name).get()).as_slice()); + } } /// Resolves the given module path from the given root `module_`. @@ -2947,7 +3186,9 @@ impl<'a> Resolver<'a> { Some(name_bindings) if name_bindings.defined_in_namespace(namespace) => { debug!("top name bindings succeeded"); - return Success((Target::new(module_.clone(), name_bindings.clone()), + return Success((Target::new(module_.clone(), + name_bindings.clone(), + false), false)); } Some(_) | None => { /* Not found; continue. */ } @@ -2987,7 +3228,10 @@ impl<'a> Resolver<'a> { let name_bindings = Rc::new(Resolver::create_name_bindings_from_module(module)); debug!("lower name bindings succeeded"); - return Success((Target::new(module_, name_bindings), false)); + return Success((Target::new(module_, + name_bindings, + false), + false)); } } } @@ -3210,7 +3454,9 @@ impl<'a> Resolver<'a> { Some(name_bindings) if name_bindings.defined_in_namespace(namespace) => { debug!("(resolving name in module) found node as child"); - return Success((Target::new(module_.clone(), name_bindings.clone()), + return Success((Target::new(module_.clone(), + name_bindings.clone(), + false), false)); } Some(_) | None => { @@ -3261,7 +3507,10 @@ impl<'a> Resolver<'a> { Some(module) => { let name_bindings = Rc::new(Resolver::create_name_bindings_from_module(module)); - return Success((Target::new(module_, name_bindings), false)); + return Success((Target::new(module_, + name_bindings, + false), + false)); } } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 85b6294ae34e6..5f54fbef74e18 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -203,7 +203,8 @@ use middle::pat_util::*; use middle::resolve::DefMap; use middle::trans::adt; use middle::trans::base::*; -use middle::trans::build::*; +use middle::trans::build::{And, BitCast, Br, CondBr, GEPi, InBoundsGEP, Load}; +use middle::trans::build::{Mul, Not, Store, Sub, Switch, add_comment}; use middle::trans::build; use middle::trans::callee; use middle::trans::cleanup; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 8ea99a5cad3ff..2098f923dbe06 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -47,11 +47,17 @@ use middle::trans::builder::{Builder, noname}; use middle::trans::callee; use middle::trans::cleanup::{CleanupMethods, ScopeId}; use middle::trans::cleanup; -use middle::trans::common::*; +use middle::trans::common::{Block, C_bool, C_bytes, C_i32, C_integral, C_nil}; +use middle::trans::common::{C_null, C_struct, C_u64, C_u8, C_uint, C_undef}; +use middle::trans::common::{CrateContext, ExternMap, FunctionContext}; +use middle::trans::common::{NodeInfo, Result, SubstP, monomorphize_type}; +use middle::trans::common::{node_id_type, param_substs, return_type_is_void}; +use middle::trans::common::{tydesc_info, type_is_immediate}; +use middle::trans::common::{type_is_zero_size, val_ty}; +use middle::trans::common; use middle::trans::consts; use middle::trans::controlflow; use middle::trans::datum; -// use middle::trans::datum::{Datum, Lvalue, Rvalue, ByRef, ByValue}; use middle::trans::debuginfo; use middle::trans::expr; use middle::trans::foreign; @@ -1074,7 +1080,7 @@ pub fn raw_block<'a>( is_lpad: bool, llbb: BasicBlockRef) -> &'a Block<'a> { - Block::new(llbb, is_lpad, None, fcx) + common::Block::new(llbb, is_lpad, None, fcx) } pub fn with_cond<'a>( diff --git a/src/librustc/middle/trans/cabi_mips.rs b/src/librustc/middle/trans/cabi_mips.rs index d07090686874f..ac4c56a1d1f11 100644 --- a/src/librustc/middle/trans/cabi_mips.rs +++ b/src/librustc/middle/trans/cabi_mips.rs @@ -15,8 +15,8 @@ use std::cmp; use llvm; use llvm::{Integer, Pointer, Float, Double, Struct, Array}; use llvm::{StructRetAttribute, ZExtAttribute}; +use middle::trans::cabi::{ArgType, FnType}; use middle::trans::context::CrateContext; -use middle::trans::cabi::*; use middle::trans::type_::Type; fn align_up_to(off: uint, a: uint) -> uint { diff --git a/src/librustc/middle/trans/cabi_x86.rs b/src/librustc/middle/trans/cabi_x86.rs index d9812677d64cb..b5de0ae29d41a 100644 --- a/src/librustc/middle/trans/cabi_x86.rs +++ b/src/librustc/middle/trans/cabi_x86.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use syntax::abi::{OsWindows, OsMacos, OsiOS}; use llvm::*; -use super::cabi::*; +use middle::trans::cabi::{ArgType, FnType}; +use middle::trans::type_::Type; use super::common::*; use super::machine::*; -use middle::trans::type_::Type; +use syntax::abi::{OsWindows, OsMacos, OsiOS}; pub fn compute_abi_info(ccx: &CrateContext, atys: &[Type], diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 493aca0ddf0c4..32e481dd2d480 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -17,7 +17,7 @@ use llvm; use llvm::{Integer, Pointer, Float, Double}; use llvm::{Struct, Array, Attribute}; use llvm::{StructRetAttribute, ByValAttribute, ZExtAttribute}; -use middle::trans::cabi::*; +use middle::trans::cabi::{ArgType, FnType}; use middle::trans::context::CrateContext; use middle::trans::type_::Type; diff --git a/src/librustc/middle/trans/cabi_x86_win64.rs b/src/librustc/middle/trans/cabi_x86_win64.rs index e036ab6675d60..6bcd9aefcc6df 100644 --- a/src/librustc/middle/trans/cabi_x86_win64.rs +++ b/src/librustc/middle/trans/cabi_x86_win64.rs @@ -9,9 +9,9 @@ // except according to those terms. use llvm::*; -use super::cabi::*; use super::common::*; use super::machine::*; +use middle::trans::cabi::{ArgType, FnType}; use middle::trans::type_::Type; // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 56c1c66533133..59148c5d4c3fd 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -37,7 +37,6 @@ use middle::trans::closure; use middle::trans::common; use middle::trans::common::*; use middle::trans::datum::*; -use middle::trans::datum::{Datum, KindOps}; use middle::trans::expr; use middle::trans::glue; use middle::trans::inline; diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 193303f4d1cd3..7a1864448e26b 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -22,10 +22,10 @@ use middle::trans::cleanup; use middle::trans::common::*; use middle::trans::consts; use middle::trans::datum; -use middle::trans::debuginfo; use middle::trans::expr; use middle::trans::meth; use middle::trans::type_::Type; +use middle::trans; use middle::ty; use middle::typeck::MethodCall; use util::ppaux::Repr; @@ -66,7 +66,8 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>, ast::DeclLocal(ref local) => { bcx = init_local(bcx, &**local); if cx.sess().opts.debuginfo == FullDebugInfo { - debuginfo::create_local_var_metadata(bcx, &**local); + trans::debuginfo::create_local_var_metadata(bcx, + &**local); } } // Inner items are visited by `trans_item`/`trans_meth`. @@ -154,7 +155,7 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>, } // if true { .. } [else { .. }] bcx = trans_block(bcx, &*thn, dest); - debuginfo::clear_source_location(bcx.fcx); + trans::debuginfo::clear_source_location(bcx.fcx); } else { let mut trans = TransItemVisitor { ccx: bcx.fcx.ccx } ; trans.visit_block(&*thn, ()); @@ -163,7 +164,7 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>, // if false { .. } else { .. } Some(elexpr) => { bcx = expr::trans_into(bcx, &*elexpr, dest); - debuginfo::clear_source_location(bcx.fcx); + trans::debuginfo::clear_source_location(bcx.fcx); } // if false { .. } @@ -177,7 +178,7 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>, let name = format!("then-block-{}-", thn.id); let then_bcx_in = bcx.fcx.new_id_block(name.as_slice(), thn.id); let then_bcx_out = trans_block(then_bcx_in, &*thn, dest); - debuginfo::clear_source_location(bcx.fcx); + trans::debuginfo::clear_source_location(bcx.fcx); let next_bcx; match els { @@ -198,7 +199,7 @@ pub fn trans_if<'a>(bcx: &'a Block<'a>, // Clear the source location because it is still set to whatever has been translated // right before. - debuginfo::clear_source_location(next_bcx.fcx); + trans::debuginfo::clear_source_location(next_bcx.fcx); next_bcx } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 40c4d9682c4a3..3a2c4857aad18 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -51,7 +51,10 @@ use std::ops; use std::rc::Rc; use std::collections::{HashMap, HashSet}; use syntax::abi; -use syntax::ast::*; +use syntax::ast::{CrateNum, DefId, FnStyle, Ident, ItemTrait, LOCAL_CRATE}; +use syntax::ast::{MutImmutable, MutMutable, Name, NamedField, NodeId}; +use syntax::ast::{Onceness, StmtExpr, StmtSemi, StructField, UnnamedField}; +use syntax::ast::{Visibility}; use syntax::ast_util::{is_local, lit_is_str}; use syntax::ast_util; use syntax::attr; diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs index 5dd61c03d17e7..d68fef306227a 100644 --- a/src/librustrt/c_str.rs +++ b/src/librustrt/c_str.rs @@ -65,14 +65,15 @@ fn main() { */ -use core::prelude::*; - use alloc::libc_heap::malloc_raw; use collections::string::String; use collections::hash; use core::fmt; use core::kinds::marker; use core::mem; +use core::prelude::{Clone, Collection, Drop, Eq, ImmutableSlice, Iterator}; +use core::prelude::{MutableSlice, None, Option, Ordering, PartialEq}; +use core::prelude::{PartialOrd, RawPtr, Some, StrSlice, range}; use core::ptr; use core::raw::Slice; use core::slice; diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index b7b5e09a5562a..70ce85ee649a9 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -18,9 +18,13 @@ #![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)] #![feature(linkage, lang_items, unsafe_destructor, default_type_params)] +#![feature(import_shadowing)] #![no_std] #![experimental] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + #[phase(plugin, link)] extern crate core; extern crate alloc; extern crate libc; diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index 27858b025c6cb..6a0b599179c0c 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -42,7 +42,7 @@ use core::prelude::*; use alloc::heap; use collections::treemap::TreeMap; -use collections::{Map, MutableMap}; +use collections::MutableMap; use core::cmp; use core::kinds::marker; use core::mem; @@ -261,6 +261,8 @@ impl KeyValue { /// assert_eq!(*key.get().unwrap(), 3); /// ``` pub fn get(&'static self) -> Option> { + use collections::Map; + let map = match unsafe { get_local_map() } { Some(map) => map, None => return None, diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 881756c5266fc..acd53535e3bee 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -13,8 +13,6 @@ //! local storage, and logging. Even a 'freestanding' Rust would likely want //! to implement this. -use core::prelude::*; - use alloc::arc::Arc; use alloc::boxed::{BoxAny, Box}; use core::any::Any; @@ -22,6 +20,8 @@ use core::atomic::{AtomicUint, SeqCst}; use core::iter::Take; use core::kinds::marker; use core::mem; +use core::prelude::{Clone, Drop, Err, Iterator, None, Ok, Option, Send, Some}; +use core::prelude::{drop}; use core::raw; use local_data; diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index 79f83df5be809..459d655b4c998 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -72,7 +72,7 @@ use core::raw::Closure; use libc::c_void; use local::Local; -use task::{Task, Result}; +use task::Task; use uw = libunwind; diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index 2182c43d4a0c2..841567a9120c2 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -437,8 +437,6 @@ pub use core::fmt::{secret_signed, secret_lower_hex, secret_upper_hex}; #[doc(hidden)] pub use core::fmt::{secret_bool, secret_char, secret_octal, secret_binary}; #[doc(hidden)] -pub use core::fmt::{secret_bool, secret_char, secret_octal, secret_binary}; -#[doc(hidden)] pub use core::fmt::{secret_float, secret_upper_exp, secret_lower_exp}; #[doc(hidden)] pub use core::fmt::{secret_pointer}; diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index d88af8dd30aa3..eb25107541839 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -26,12 +26,7 @@ instances as clients. use prelude::*; -use c_str::ToCStr; -use clone::Clone; -use io::{Listener, Acceptor, Reader, Writer, IoResult, IoError}; -use io::{standard_error, TimedOut}; -use kinds::Send; -use boxed::Box; +use io::{Listener, Acceptor, IoResult, IoError, TimedOut, standard_error}; use rt::rtio::{IoFactory, LocalIo, RtioUnixListener}; use rt::rtio::{RtioUnixAcceptor, RtioPipe}; use time::Duration; diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index c476a99fee9dc..1304877fc14c5 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -20,7 +20,6 @@ use prelude::*; use io::{IoResult, IoError}; use libc; use os; -use boxed::Box; use rt::rtio::{RtioPipe, LocalIo}; /// A synchronous, in-memory pipe. diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 3dd4343c5f4fc..dd6c1f6016c50 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -20,7 +20,6 @@ use io::{IoResult, IoError}; use io; use libc; use mem; -use boxed::Box; use rt::rtio::{RtioProcess, ProcessConfig, IoFactory, LocalIo}; use rt::rtio; use c_str::CString; diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index c3cd2faf773b5..1fe0ba780a6fd 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -13,7 +13,6 @@ use prelude::*; use cmp; use io; -use boxed::Box; use slice::bytes::MutableByteVector; /// Wraps a `Reader`, limiting the number of bytes that can be read from it. diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 103cd574e7381..fb6599d808c3e 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -107,10 +107,14 @@ #![feature(macro_rules, globs, managed_boxes, linkage)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)] +#![feature(import_shadowing)] // Don't link to std. We are std. #![no_std] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + #![allow(deprecated)] #![deny(missing_doc)] diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 680620f5a752f..d91f5579c0d7a 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -22,7 +22,6 @@ use intrinsics; use libc::c_int; use num::strconv; use num; -use string::String; pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE}; pub use core::f32::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP}; diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 3180ee28c6fee..d8d118a6721d9 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -21,7 +21,6 @@ use intrinsics; use libc::c_int; use num::strconv; use num; -use string::String; pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE}; pub use core::f64::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP}; diff --git a/src/libsync/atomic.rs b/src/libsync/atomic.rs index 301d444b1b15b..cd7102a756a4d 100644 --- a/src/libsync/atomic.rs +++ b/src/libsync/atomic.rs @@ -103,10 +103,9 @@ #![allow(deprecated)] -use core::prelude::*; - use alloc::boxed::Box; use core::mem; +use core::prelude::{Drop, None, Option, Some}; pub use core::atomic::{AtomicBool, AtomicInt, AtomicUint, AtomicPtr}; pub use core::atomic::{Ordering, Relaxed, Release, Acquire, AcqRel, SeqCst}; diff --git a/src/libsync/comm/sync.rs b/src/libsync/comm/sync.rs index aef02f654c102..1ee9fef191866 100644 --- a/src/libsync/comm/sync.rs +++ b/src/libsync/comm/sync.rs @@ -37,7 +37,6 @@ use core::prelude::*; use alloc::boxed::Box; use collections::Vec; -use collections::Collection; use core::mem; use core::cell::UnsafeCell; use rustrt::local::Local; diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index de98f79093e49..bed90743503c3 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -28,9 +28,13 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(phase, globs, macro_rules, unsafe_destructor)] +#![feature(import_shadowing)] #![deny(missing_doc)] #![no_std] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + #[phase(plugin, link)] extern crate core; extern crate alloc; extern crate collections; diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index f9f2a86d18249..4b185419b407c 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -198,7 +198,7 @@ use owned_slice::OwnedSlice; use parse::token::InternedString; use parse::token::special_idents; -use self::ty::*; +use self::ty::{LifetimeBounds, Path, Ptr, PtrTy, Self, Ty}; pub mod ty; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 13d2a632f3638..291c876082fda 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -24,9 +24,12 @@ html_root_url = "http://doc.rust-lang.org/master/")] #![feature(macro_rules, globs, managed_boxes, default_type_params, phase)] -#![feature(quote, struct_variant, unsafe_destructor)] +#![feature(quote, struct_variant, unsafe_destructor, import_shadowing)] #![allow(deprecated)] +// NOTE(stage0, pcwalton): Remove after snapshot. +#![allow(unknown_features)] + extern crate fmt_macros; extern crate debug; #[phase(plugin, link)] extern crate log; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 4c959932f415d..cce14be1ba526 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -456,62 +456,63 @@ declare_special_idents_and_keywords! { (7, opaque, ""); (8, unnamed_field, ""); (9, type_self, "Self"); + (10, prelude_import, "prelude_import"); } pub mod keywords { // These ones are variants of the Keyword enum 'strict: - (10, As, "as"); - (11, Break, "break"); - (12, Crate, "crate"); - (13, Else, "else"); - (14, Enum, "enum"); - (15, Extern, "extern"); - (16, False, "false"); - (17, Fn, "fn"); - (18, For, "for"); - (19, If, "if"); - (20, Impl, "impl"); - (21, In, "in"); - (22, Let, "let"); - (23, Loop, "loop"); - (24, Match, "match"); - (25, Mod, "mod"); - (26, Mut, "mut"); - (27, Once, "once"); - (28, Pub, "pub"); - (29, Ref, "ref"); - (30, Return, "return"); + (11, As, "as"); + (12, Break, "break"); + (13, Crate, "crate"); + (14, Else, "else"); + (15, Enum, "enum"); + (16, Extern, "extern"); + (17, False, "false"); + (18, Fn, "fn"); + (19, For, "for"); + (20, If, "if"); + (21, Impl, "impl"); + (22, In, "in"); + (23, Let, "let"); + (24, Loop, "loop"); + (25, Match, "match"); + (26, Mod, "mod"); + (27, Mut, "mut"); + (28, Once, "once"); + (29, Pub, "pub"); + (30, Ref, "ref"); + (31, Return, "return"); // Static and Self are also special idents (prefill de-dupes) (super::STATIC_KEYWORD_NAME_NUM, Static, "static"); (super::SELF_KEYWORD_NAME_NUM, Self, "self"); - (31, Struct, "struct"); - (32, Super, "super"); - (33, True, "true"); - (34, Trait, "trait"); - (35, Type, "type"); - (36, Unsafe, "unsafe"); - (37, Use, "use"); - (38, Virtual, "virtual"); - (39, While, "while"); - (40, Continue, "continue"); - (41, Proc, "proc"); - (42, Box, "box"); - (43, Const, "const"); - (44, Where, "where"); + (32, Struct, "struct"); + (33, Super, "super"); + (34, True, "true"); + (35, Trait, "trait"); + (36, Type, "type"); + (37, Unsafe, "unsafe"); + (38, Use, "use"); + (39, Virtual, "virtual"); + (40, While, "while"); + (41, Continue, "continue"); + (42, Proc, "proc"); + (43, Box, "box"); + (44, Const, "const"); + (45, Where, "where"); 'reserved: - (45, Alignof, "alignof"); - (46, Be, "be"); - (47, Offsetof, "offsetof"); - (48, Priv, "priv"); - (49, Pure, "pure"); - (50, Sizeof, "sizeof"); - (51, Typeof, "typeof"); - (52, Unsized, "unsized"); - (53, Yield, "yield"); - (54, Do, "do"); + (46, Alignof, "alignof"); + (47, Be, "be"); + (48, Offsetof, "offsetof"); + (49, Priv, "priv"); + (50, Pure, "pure"); + (51, Sizeof, "sizeof"); + (52, Typeof, "typeof"); + (53, Unsized, "unsized"); + (54, Yield, "yield"); + (55, Do, "do"); } } diff --git a/src/libuuid/lib.rs b/src/libuuid/lib.rs index 78c8fbad959ee..98dd129f3d251 100644 --- a/src/libuuid/lib.rs +++ b/src/libuuid/lib.rs @@ -523,7 +523,7 @@ impl rand::Rand for Uuid { } #[cfg(test)] -mod test { +mod uuidtest { use super::{Uuid, VariantMicrosoft, VariantNCS, VariantRFC4122, Version1Mac, Version2Dce, Version3Md5, Version4Random, Version5Sha1}; diff --git a/src/test/compile-fail/ambig_impl_2_exe.rs b/src/test/compile-fail/ambig_impl_2_exe.rs index 664a168450583..13cceaa71ae06 100644 --- a/src/test/compile-fail/ambig_impl_2_exe.rs +++ b/src/test/compile-fail/ambig_impl_2_exe.rs @@ -11,9 +11,9 @@ // aux-build:ambig_impl_2_lib.rs extern crate ambig_impl_2_lib; use ambig_impl_2_lib::me; -trait me { +trait me2 { fn me(&self) -> uint; } -impl me for uint { fn me(&self) -> uint { *self } } //~ NOTE is `uint.me::me` +impl me2 for uint { fn me(&self) -> uint { *self } } //~ NOTE is `uint.me2::me` fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope //~^ NOTE is `ambig_impl_2_lib::uint.me::me` diff --git a/src/test/compile-fail/issue-7663.rs b/src/test/compile-fail/issue-7663.rs deleted file mode 100644 index baea483ad982b..0000000000000 --- a/src/test/compile-fail/issue-7663.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(globs)] -#![deny(unused_imports)] -#![allow(dead_code)] - -mod test1 { - - mod foo { pub fn p() -> int { 1 } } - mod bar { pub fn p() -> int { 2 } } - - pub mod baz { - use test1::foo::*; //~ ERROR: unused import - use test1::bar::*; - - pub fn my_main() { assert!(p() == 2); } - } -} - -mod test2 { - - mod foo { pub fn p() -> int { 1 } } - mod bar { pub fn p() -> int { 2 } } - - pub mod baz { - use test2::foo::p; //~ ERROR: unused import - use test2::bar::p; - - pub fn my_main() { assert!(p() == 2); } - } -} - -mod test3 { - - mod foo { pub fn p() -> int { 1 } } - mod bar { pub fn p() -> int { 2 } } - - pub mod baz { - use test3::foo::*; //~ ERROR: unused import - use test3::bar::p; - - pub fn my_main() { assert!(p() == 2); } - } -} - -fn main() { -} - diff --git a/src/test/compile-fail/issue-9957.rs b/src/test/compile-fail/issue-9957.rs index 3c6a1a7b27557..a90a1ac1a75f0 100644 --- a/src/test/compile-fail/issue-9957.rs +++ b/src/test/compile-fail/issue-9957.rs @@ -8,13 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub extern crate std; //~ ERROR: `pub` visibility is not allowed -extern crate std; - -pub use std::bool; -use std::bool; +pub extern crate core; //~ ERROR: `pub` visibility is not allowed fn main() { pub use std::bool; //~ ERROR: imports in functions are never reachable - use std::bool; } diff --git a/src/test/compile-fail/lint-unused-import-tricky-globs.rs b/src/test/compile-fail/lint-unused-import-tricky-globs.rs deleted file mode 100644 index 62ea337656d77..0000000000000 --- a/src/test/compile-fail/lint-unused-import-tricky-globs.rs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(globs)] -#![deny(unused_imports)] -#![allow(dead_code)] - -mod A { - pub fn p() {} -} -mod B { - pub fn p() {} -} - -mod C { - pub fn q() {} -} -mod D { - pub fn q() {} -} - -mod E { - pub fn r() {} -} -mod F { - pub fn r() {} -} - -mod G { - pub fn s() {} - pub fn t() {} -} -mod H { - pub fn s() {} -} - -mod I { - pub fn u() {} - pub fn v() {} -} -mod J { - pub fn u() {} - pub fn v() {} -} - -mod K { - pub fn w() {} -} -mod L { - pub fn w() {} -} - -mod m { - use A::p; //~ ERROR: unused import - use B::p; - use C::q; //~ ERROR: unused import - use D::*; - use E::*; //~ ERROR: unused import - use F::r; - use G::*; - use H::*; - use I::*; - use J::v; - use K::*; //~ ERROR: unused import - use L::*; - - #[main] - fn my_main() { - p(); - q(); - r(); - s(); - t(); - u(); - v(); - w(); - } -} - diff --git a/src/test/compile-fail/lint-unused-import-tricky-names.rs b/src/test/compile-fail/lint-unused-import-tricky-names.rs deleted file mode 100644 index 39e344da115e1..0000000000000 --- a/src/test/compile-fail/lint-unused-import-tricky-names.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_imports)] -#![allow(non_camel_case_types)] -#![allow(dead_code)] - -// Regression test for issue #6633 -mod issue6633 { - use self::foo::name::name; //~ ERROR: unused import - use self::foo::name; - - pub mod foo { - pub mod name { - pub type a = int; - pub mod name { - pub type a = f64; - } - } - } - - fn bar() -> name::a { 1 } -} - -// Regression test for issue #6935 -mod issue6935 { - use self::a::foo::a::foo; - use self::a::foo; //~ ERROR: unused import - - pub mod a { - pub mod foo { - pub mod a { - pub fn foo() {} - } - } - } - - fn bar() { foo(); } -} - -fn main(){} diff --git a/src/test/compile-fail/privacy-ns2.rs b/src/test/compile-fail/privacy-ns2.rs index 5ce0fb7e56a2c..769bdae80f118 100644 --- a/src/test/compile-fail/privacy-ns2.rs +++ b/src/test/compile-fail/privacy-ns2.rs @@ -70,7 +70,6 @@ pub mod foo3 { fn test_unused3() { use foo3::Bar; //~ ERROR `Bar` is private - use foo3::{Bar,Baz}; //~ ERROR `Bar` is private } fn test_single3() { diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs index e52a4da135287..c30261b9d3b50 100644 --- a/src/test/compile-fail/privacy1.rs +++ b/src/test/compile-fail/privacy1.rs @@ -171,7 +171,6 @@ pub mod mytest { // Even though the inner `A` struct is a publicly exported item (usable from // external crates through `foo::foo`, it should not be accessible through // its definition path (which has the private `i` module). - use self::foo::foo; use self::foo::i::A; //~ ERROR: type `A` is inaccessible //~^ NOTE: module `i` is private diff --git a/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs new file mode 100644 index 0000000000000..8673d95de1b17 --- /dev/null +++ b/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate std; +//~^ ERROR an external crate named `std` has already been imported + +fn main(){} + diff --git a/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs new file mode 100644 index 0000000000000..dcd6ee6e9571c --- /dev/null +++ b/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std = std::slice; //~ ERROR import conflicts with imported crate + +fn main() { +} + diff --git a/src/test/compile-fail/resolve-conflict-import-vs-import.rs b/src/test/compile-fail/resolve-conflict-import-vs-import.rs new file mode 100644 index 0000000000000..beb4b74f3264b --- /dev/null +++ b/src/test/compile-fail/resolve-conflict-import-vs-import.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem::transmute; +use std::mem::transmute; +//~^ ERROR a value named `transmute` has already been imported + +fn main() { +} + diff --git a/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs new file mode 100644 index 0000000000000..9d40196d4ac6b --- /dev/null +++ b/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn std() {} //~ ERROR the name `std` conflicts with an external crate + +fn main() { +} + diff --git a/src/test/compile-fail/resolve-conflict-item-vs-import.rs b/src/test/compile-fail/resolve-conflict-item-vs-import.rs new file mode 100644 index 0000000000000..3834007f5ffe9 --- /dev/null +++ b/src/test/compile-fail/resolve-conflict-item-vs-import.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem::transmute; +//~^ ERROR import conflicts with value in this module + +fn transmute() {} + +fn main() { +} + diff --git a/src/test/compile-fail/resolve-priv-shadowing-pub.rs b/src/test/compile-fail/resolve-priv-shadowing-pub.rs deleted file mode 100644 index 0830722f96929..0000000000000 --- a/src/test/compile-fail/resolve-priv-shadowing-pub.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub fn foobar() -> int { 1 } -} - -mod b { - pub fn foobar() -> int { 2 } -} - -mod c { - // Technically the second use shadows the first, but in theory it should - // only be shadowed for this module. The implementation of resolve currently - // doesn't implement this, so this test is ensuring that using "c::foobar" - // is *not* getting b::foobar. Today it's an error, but perhaps one day it - // can correctly get a::foobar instead. - pub use a::foobar; - use b::foobar; -} - -fn main() { - assert_eq!(c::foobar(), 1); - //~^ ERROR: unresolved name `c::foobar` -} - diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs index 3e1e08c7b58dd..0a5a9db8fa8e9 100644 --- a/src/test/compile-fail/unused-attr.rs +++ b/src/test/compile-fail/unused-attr.rs @@ -13,7 +13,7 @@ #![foo] //~ ERROR unused attribute #[foo] //~ ERROR unused attribute -extern crate std; +extern crate core; #[foo] //~ ERROR unused attribute use std::collections; diff --git a/src/test/compile-fail/use-mod-3.rs b/src/test/compile-fail/use-mod-3.rs index 0263dc392f1de..b6b86a9993db1 100644 --- a/src/test/compile-fail/use-mod-3.rs +++ b/src/test/compile-fail/use-mod-3.rs @@ -12,9 +12,8 @@ use foo::bar::{ mod //~ ERROR module `bar` is private }; use foo::bar::{ - Bar, //~ ERROR type `Bar` is inaccessible + Bar //~ ERROR type `Bar` is inaccessible //~^ NOTE module `bar` is private - mod //~ ERROR module `bar` is private }; mod foo { diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index a9f57a48f442c..e1ad27ec5c7a2 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -4,6 +4,7 @@ #[phase(plugin, link)] extern crate std = "std"; extern crate rt = "native"; +#[prelude_import] use std::prelude::*; // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at diff --git a/src/test/run-fail/glob-use-std.rs b/src/test/run-fail/glob-use-std.rs index fffe146f7f4d4..bee60cd120584 100644 --- a/src/test/run-fail/glob-use-std.rs +++ b/src/test/run-fail/glob-use-std.rs @@ -10,6 +10,10 @@ // Issue #7580 +// ignore-pretty +// +// Expanded pretty printing causes resolve conflicts. + // error-pattern:fail works #![feature(globs)] diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index 9cee83a8598c7..c7a02a419c0d4 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -41,7 +41,7 @@ macro_rules! iotest ( use std::str; use std::io::process::Command; use native; - use super::*; + use super::{sleeper, test_destroy_actually_kills}; fn f() $b diff --git a/src/test/run-pass/extern-mod-ordering-exe.rs b/src/test/run-pass/extern-mod-ordering-exe.rs index 7e9e6073252b9..56c29b54b6877 100644 --- a/src/test/run-pass/extern-mod-ordering-exe.rs +++ b/src/test/run-pass/extern-mod-ordering-exe.rs @@ -12,8 +12,8 @@ extern crate extern_mod_ordering_lib; -use extern_mod_ordering_lib::extern_mod_ordering_lib; +use the_lib = extern_mod_ordering_lib::extern_mod_ordering_lib; pub fn main() { - extern_mod_ordering_lib::f(); + the_lib::f(); } diff --git a/src/test/run-pass/issue-11736.rs b/src/test/run-pass/issue-11736.rs index 10d6e0158f6f2..cdd3252df4bdc 100644 --- a/src/test/run-pass/issue-11736.rs +++ b/src/test/run-pass/issue-11736.rs @@ -9,7 +9,6 @@ // except according to those terms. extern crate collections; -extern crate std; use std::collections::Bitv; diff --git a/src/test/run-pass/issue-12612.rs b/src/test/run-pass/issue-12612.rs index fcb658036b6b1..3e8ac2f2783f1 100644 --- a/src/test/run-pass/issue-12612.rs +++ b/src/test/run-pass/issue-12612.rs @@ -14,8 +14,6 @@ extern crate foo = "issue-12612-1"; extern crate bar = "issue-12612-2"; -use foo::bar; - mod test { use bar::baz; } diff --git a/src/test/run-pass/issue-14082.rs b/src/test/run-pass/issue-14082.rs index b8683c86164cb..9aff6b917484e 100644 --- a/src/test/run-pass/issue-14082.rs +++ b/src/test/run-pass/issue-14082.rs @@ -14,7 +14,6 @@ use foo::GC; mod foo { - use d::*; pub use m::GC; // this should shadow d::GC } diff --git a/src/test/run-pass/issue-14330.rs b/src/test/run-pass/issue-14330.rs index a7f2ebf9e1123..26b282b7180f4 100644 --- a/src/test/run-pass/issue-14330.rs +++ b/src/test/run-pass/issue-14330.rs @@ -10,6 +10,6 @@ #![feature(phase)] -#[phase(plugin, link)] extern crate std; +#[phase(plugin, link)] extern crate std2 = "std"; fn main() {} diff --git a/src/test/run-pass/issue-5521.rs b/src/test/run-pass/issue-5521.rs index 760ac5c9383b9..150bd9a74a942 100644 --- a/src/test/run-pass/issue-5521.rs +++ b/src/test/run-pass/issue-5521.rs @@ -13,7 +13,7 @@ extern crate foo = "issue-5521"; -fn foo(a: foo::map) { +fn bar(a: foo::map) { if false { fail!(); } else { diff --git a/src/test/run-pass/issue-7663.rs b/src/test/run-pass/issue-7663.rs index baf37e314173d..ee500b3d4fa36 100644 --- a/src/test/run-pass/issue-7663.rs +++ b/src/test/run-pass/issue-7663.rs @@ -30,7 +30,6 @@ mod test2 { mod bar { pub fn p() -> int { 2 } } pub mod baz { - use test2::foo::p; use test2::bar::p; pub fn my_main() { assert!(p() == 2); } @@ -43,7 +42,6 @@ mod test3 { mod bar { pub fn p() -> int { 2 } } pub mod baz { - use test3::foo::*; use test3::bar::p; pub fn my_main() { assert!(p() == 2); } diff --git a/src/test/run-pass/match-ref-binding-in-guard-3256.rs b/src/test/run-pass/match-ref-binding-in-guard-3256.rs index 4fdbdf8f5c7ae..a07c63490e78e 100644 --- a/src/test/run-pass/match-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/match-ref-binding-in-guard-3256.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::rt; - pub fn main() { unsafe { - let x = Some(rt::exclusive::Exclusive::new(true)); + let x = Some(::std::rt::exclusive::Exclusive::new(true)); match x { Some(ref z) if *z.lock() => { assert!(*z.lock()); diff --git a/src/test/run-pass/privacy-ns.rs b/src/test/run-pass/privacy-ns.rs index 5915b3e3a76db..336791e65fdee 100644 --- a/src/test/run-pass/privacy-ns.rs +++ b/src/test/run-pass/privacy-ns.rs @@ -27,8 +27,6 @@ pub mod foo1 { } fn test_unused1() { - use foo1::Bar; - use foo1::{Bar,Baz}; use foo1::*; } @@ -60,8 +58,6 @@ pub mod foo2 { } fn test_unused2() { - use foo2::Bar; - use foo2::{Bar,Baz}; use foo2::*; } @@ -93,8 +89,6 @@ pub mod foo3 { } fn test_unused3() { - use foo3::Bar; - use foo3::{Bar,Baz}; use foo3::*; } diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index 970a5c5011b2e..2596bc9c83763 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate std; use std::mem::size_of; struct t {a: u8, b: i8} diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index f2d29c97f155e..6d57bff1bd673 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::rt; - struct Point {x: int, y: int, z: int} fn f(p: &mut Point) { p.z = 13; } pub fn main() { unsafe { - let x = Some(rt::exclusive::Exclusive::new(true)); + let x = Some(::std::rt::exclusive::Exclusive::new(true)); match x { Some(ref z) if *z.lock() => { assert!(*z.lock());