librustc: Forbid chained imports and fix the logic for one-level renaming imports

This commit is contained in:
Patrick Walton 2013-03-01 10:44:43 -08:00
parent 347d19934d
commit a3f728238b
92 changed files with 402 additions and 544 deletions

View file

@ -1360,7 +1360,7 @@ Functions within foreign modules are declared in the same way as other Rust func
with the exception that they may not have a body and are instead terminated by a semicolon.
~~~
# use libc::{c_char, FILE};
# use core::libc::{c_char, FILE};
# #[nolink]
extern mod c {

View file

@ -14,7 +14,7 @@ should compile and run without any extra effort.
~~~~ {.xfail-test}
extern mod std;
use libc::c_uint;
use core::libc::c_uint;
extern mod crypto {
fn SHA1(src: *u8, sz: c_uint, out: *u8) -> *u8;
@ -217,7 +217,7 @@ microsecond-resolution timer.
~~~~
extern mod std;
use libc::c_ulonglong;
use core::libc::c_ulonglong;
struct timeval {
tv_sec: c_ulonglong,

View file

@ -80,8 +80,8 @@ calling the `spawn` function with a closure argument. `spawn` executes the
closure in the new task.
~~~~
# use io::println;
use task::spawn;
# use core::io::println;
use core::task::spawn;
// Print something profound in a different task using a named function
fn print_message() { println("I am running in a different task!"); }
@ -110,8 +110,8 @@ execution. Like any closure, the function passed to `spawn` may capture
an environment that it carries across tasks.
~~~
# use io::println;
# use task::spawn;
# use core::io::println;
# use core::task::spawn;
# fn generate_task_number() -> int { 0 }
// Generate some state locally
let child_task_number = generate_task_number();
@ -127,8 +127,8 @@ in parallel. Thus, on a multicore machine, running the following code
should interleave the output in vaguely random order.
~~~
# use io::print;
# use task::spawn;
# use core::io::print;
# use core::task::spawn;
for int::range(0, 20) |child_task_number| {
do spawn {
@ -156,8 +156,8 @@ endpoint. Consider the following example of calculating two results
concurrently:
~~~~
use task::spawn;
use comm::{stream, Port, Chan};
use core::task::spawn;
use core::comm::{stream, Port, Chan};
let (port, chan): (Port<int>, Chan<int>) = stream();
@ -178,7 +178,7 @@ stream for sending and receiving integers (the left-hand side of the `let`,
a tuple into its component parts).
~~~~
# use comm::{stream, Chan, Port};
# use core::comm::{stream, Chan, Port};
let (port, chan): (Port<int>, Chan<int>) = stream();
~~~~
@ -187,9 +187,8 @@ which will wait to receive the data on the port. The next statement
spawns the child task.
~~~~
# use task::{spawn};
# use task::spawn;
# use comm::{stream, Port, Chan};
# use core::task::spawn;
# use core::comm::{stream, Port, Chan};
# fn some_expensive_computation() -> int { 42 }
# let (port, chan) = stream();
do spawn || {
@ -209,7 +208,7 @@ computation, then waits for the child's result to arrive on the
port:
~~~~
# use comm::{stream, Port, Chan};
# use core::comm::{stream, Port, Chan};
# fn some_other_expensive_computation() {}
# let (port, chan) = stream::<int>();
# chan.send(0);
@ -224,8 +223,8 @@ example needed to compute multiple results across a number of tasks? The
following program is ill-typed:
~~~ {.xfail-test}
# use task::{spawn};
# use comm::{stream, Port, Chan};
# use core::task::{spawn};
# use core::comm::{stream, Port, Chan};
# fn some_expensive_computation() -> int { 42 }
let (port, chan) = stream();
@ -244,8 +243,8 @@ Instead we can use a `SharedChan`, a type that allows a single
`Chan` to be shared by multiple senders.
~~~
# use task::spawn;
use comm::{stream, SharedChan};
# use core::task::spawn;
use core::comm::{stream, SharedChan};
let (port, chan) = stream();
let chan = SharedChan(chan);
@ -277,8 +276,8 @@ illustrate the point. For reference, written with multiple streams, it
might look like the example below.
~~~
# use task::spawn;
# use comm::{stream, Port, Chan};
# use core::task::spawn;
# use core::comm::{stream, Port, Chan};
// Create a vector of ports, one for each child task
let ports = do vec::from_fn(3) |init_val| {
@ -309,7 +308,7 @@ All tasks are, by default, _linked_ to each other. That means that the fates
of all tasks are intertwined: if one fails, so do all the others.
~~~
# use task::spawn;
# use core::task::spawn;
# fn do_some_work() { loop { task::yield() } }
# do task::try {
// Create a child task that fails
@ -393,8 +392,8 @@ internally, with additional logic to wait for the child task to finish
before returning. Hence:
~~~
# use comm::{stream, Chan, Port};
# use task::{spawn, try};
# use core::comm::{stream, Chan, Port};
# use core::task::{spawn, try};
# fn sleep_forever() { loop { task::yield() } }
# do task::try {
let (receiver, sender): (Port<int>, Chan<int>) = stream();
@ -489,8 +488,8 @@ response itself is simply the stringified version of the received value,
Here is the code for the parent task:
~~~~
# use core::task::spawn;
# use std::comm::DuplexStream;
# use task::spawn;
# fn stringifier(channel: &DuplexStream<~str, uint>) {
# let mut value: uint;
# loop {

View file

@ -1313,7 +1313,7 @@ and [`core::str`]. Here are some examples.
[`core::str`]: core/str.html
~~~
# use io::println;
# use core::io::println;
# enum Crayon {
# Almond, AntiqueBrass, Apricot,
# Aquamarine, Asparagus, AtomicTangerine,
@ -1368,7 +1368,7 @@ Rust also supports _closures_, functions that can access variables in
the enclosing scope.
~~~~
# use println = io::println;
# use println = core::io::println;
fn call_closure_with_ten(b: fn(int)) { b(10); }
let captured_var = 20;
@ -1525,7 +1525,7 @@ words, it is a function that takes an owned closure that takes no
arguments.
~~~~
use task::spawn;
use core::task::spawn;
do spawn() || {
debug!("I'm a task, whatever");
@ -1537,7 +1537,7 @@ lists back to back. Since that is so unsightly, empty argument lists
may be omitted from `do` expressions.
~~~~
# use task::spawn;
# use core::task::spawn;
do spawn {
debug!("Kablam!");
}
@ -1568,8 +1568,8 @@ fn each(v: &[int], op: fn(v: &int) -> bool) {
And using this function to iterate over a vector:
~~~~
# use each = vec::each;
# use println = io::println;
# use each = core::vec::each;
# use println = core::io::println;
each([2, 4, 8, 5, 16], |n| {
if *n % 2 != 0 {
println("found odd number!");
@ -1585,8 +1585,8 @@ out of the loop, you just write `break`. To skip ahead
to the next iteration, write `loop`.
~~~~
# use each = vec::each;
# use println = io::println;
# use each = core::vec::each;
# use println = core::io::println;
for each([2, 4, 8, 5, 16]) |n| {
if *n % 2 != 0 {
println("found odd number!");
@ -1601,7 +1601,7 @@ normally allowed in closures, in a block that appears as the body of a
the enclosing function, not just the loop body.
~~~~
# use each = vec::each;
# use each = core::vec::each;
fn contains(v: &[int], elt: int) -> bool {
for each(v) |x| {
if (*x == elt) { return true; }
@ -1616,7 +1616,7 @@ In these situations it can be convenient to lean on Rust's
argument patterns to bind `x` to the actual value, not the pointer.
~~~~
# use each = vec::each;
# use each = core::vec::each;
# fn contains(v: &[int], elt: int) -> bool {
for each(v) |&x| {
if (x == elt) { return true; }
@ -1758,8 +1758,8 @@ Constructors are one common application for static methods, as in `new` above.
To call a static method, you have to prefix it with the type name and a double colon:
~~~~
# use float::consts::pi;
# use float::sqrt;
# use core::float::consts::pi;
# use core::float::sqrt;
struct Circle { radius: float }
impl Circle {
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
@ -2030,8 +2030,8 @@ The compiler will use type inference to decide which implementation to call.
~~~~
trait Shape { static fn new(area: float) -> Self; }
# use float::consts::pi;
# use float::sqrt;
# use core::float::consts::pi;
# use core::float::sqrt;
struct Circle { radius: float }
struct Square { length: float }
@ -2189,8 +2189,8 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`.
# trait Shape { fn area(&self) -> float; }
# trait Circle : Shape { fn radius(&self) -> float; }
# struct Point { x: float, y: float }
# use float::consts::pi;
# use float::sqrt;
# use core::float::consts::pi;
# use core::float::sqrt;
# fn square(x: float) -> float { x * x }
struct CircleStruct { center: Point, radius: float }
impl Circle for CircleStruct {
@ -2224,8 +2224,8 @@ Likewise, supertrait methods may also be called on trait objects.
~~~ {.xfail-test}
# trait Shape { fn area(&self) -> float; }
# trait Circle : Shape { fn radius(&self) -> float; }
# use float::consts::pi;
# use float::sqrt;
# use core::float::consts::pi;
# use core::float::sqrt;
# struct Point { x: float, y: float }
# struct CircleStruct { center: Point, radius: float }
# impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } }

View file

@ -22,18 +22,18 @@ extern mod std(vers = "0.6");
use core::*;
mod procsrv;
mod util;
mod header;
mod runtest;
mod common;
mod errors;
pub mod procsrv;
pub mod util;
pub mod header;
pub mod runtest;
pub mod common;
pub mod errors;
use std::getopts;
use std::test;
use core::{result, either};
use result::{Ok, Err};
use core::result::{Ok, Err};
use common::config;
use common::mode_run_pass;

View file

@ -11,9 +11,10 @@
use core::prelude::*;
use common::config;
use io;
use io::ReaderUtil;
use str;
use core::io;
use core::io::ReaderUtil;
use core::str;
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }

View file

@ -12,10 +12,11 @@
use common;
use common::config;
use io;
use io::ReaderUtil;
use os;
use str;
use core::io::ReaderUtil;
use core::io;
use core::os;
use core::str;
pub struct TestProps {
// Lines that should be expected, in order, on standard out

View file

@ -10,17 +10,17 @@
use core::prelude::*;
use io;
use io::{ReaderUtil, WriterUtil};
use libc;
use libc::{c_int, pid_t};
use os;
use run;
use run::spawn_process;
use pipes;
use str;
use task;
use vec;
use core::io::{ReaderUtil, WriterUtil};
use core::io;
use core::libc::{c_int, pid_t};
use core::libc;
use core::os;
use core::pipes;
use core::run::spawn_process;
use core::run;
use core::str;
use core::task;
use core::vec;
#[cfg(target_os = "win32")]
fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {

View file

@ -10,13 +10,6 @@
use core::prelude::*;
use io;
use io::WriterUtil;
use os;
use str;
use uint;
use vec;
use common;
use common::mode_run_pass;
use common::mode_run_fail;
@ -31,6 +24,13 @@
use util;
use util::logv;
use core::io::WriterUtil;
use core::io;
use core::os;
use core::str;
use core::uint;
use core::vec;
pub fn run(config: config, testfile: ~str) {
if config.verbose {
// We're going to be dumping a lot of info. Start on a new line.

View file

@ -10,13 +10,13 @@
use core::prelude::*;
use io;
use os;
use os::getenv;
use common;
use common::config;
use core::io;
use core::os::getenv;
use core::os;
pub fn make_new_path(path: ~str) -> ~str {
// Windows just uses PATH as the library search path, so we have to

View file

@ -52,7 +52,7 @@ d.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
d.write("extern mod std;\n")
d.write("extern mod run_pass_stage2;\n")
d.write("use run_pass_stage2::*;\n")
d.write("use io::WriterUtil;\n");
d.write("use core::io::WriterUtil;\n");
d.write("fn main() {\n");
d.write(" let out = io::stdout();\n");
i = 0

View file

@ -235,10 +235,10 @@ pub mod private {
/* For internal use, not exported */
mod unicode;
pub mod unicode;
#[path = "num/cmath.rs"]
mod cmath;
mod stackwalk;
pub mod cmath;
pub mod stackwalk;
// A curious inner-module that's not exported that contains the binding
@ -253,8 +253,9 @@ pub mod core {
pub use cmp;
pub use condition;
pub use option;
pub use kinds;
pub use ops;
pub use option;
pub use sys;
pub use pipes;
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
//! An interface for numeric types
use core::cmp::{Ord, Eq};
use cmp::{Ord, Eq};
use ops::{Add, Div, Modulo, Mul, Neg, Sub};
use option::{None, Option, Some};
use char;

View file

@ -27,8 +27,8 @@
*/
use prelude::*;
use rt;
use task::local_data_priv::{local_get, local_pop, local_modify, local_set};
use task::rt;
use task;
/**

View file

@ -31,8 +31,7 @@ extern mod std(vers = "0.6");
extern mod syntax(vers = "0.6");
use core::*;
use io::WriterUtil;
use core::io::WriterUtil;
use syntax::{ast, ast_util, fold, visit, codemap};
use syntax::parse;

View file

@ -220,7 +220,7 @@ fn usage() {
}
fn main() {
pub fn main() {
let args = os::args().tail();
if !args.is_empty() {

View file

@ -9,8 +9,8 @@
// except according to those terms.
use back::target_strs;
use driver::session::sess_os_to_meta_os;
use driver::session;
use session::sess_os_to_meta_os;
use metadata::loader::meta_section_name;
pub fn get_target_strs(target_os: session::os) -> target_strs::t {

View file

@ -11,6 +11,7 @@
use core::prelude::*;
use back::rpath;
use driver::session::Session;
use driver::session;
use lib::llvm::llvm;
use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False};
@ -21,8 +22,6 @@
use metadata::{encoder, cstore};
use middle::trans::common::CrateContext;
use middle::ty;
use session::Session;
use session;
use util::ppaux;
use core::char;
@ -89,10 +88,10 @@ pub fn WriteOutputFile(sess: Session,
pub mod jit {
use back::link::llvm_err;
use driver::session::Session;
use lib::llvm::llvm;
use lib::llvm::{ModuleRef, PassManagerRef, mk_target_data};
use metadata::cstore;
use session::Session;
use core::cast;
use core::libc::c_int;
@ -170,11 +169,11 @@ pub mod write {
use back::link::{output_type_assembly, output_type_bitcode};
use back::link::{output_type_exe, output_type_llvm_assembly};
use back::link::{output_type_object};
use driver::session::Session;
use driver::session;
use lib::llvm::llvm;
use lib::llvm::{False, True, ModuleRef, mk_pass_manager, mk_target_data};
use lib;
use session::Session;
use core::char;
use core::libc::{c_char, c_int, c_uint};

View file

@ -10,9 +10,9 @@
use back::target_strs;
use driver::session::sess_os_to_meta_os;
use driver::session;
use metadata::loader::meta_section_name;
use session::sess_os_to_meta_os;
pub fn get_target_strs(target_os: session::os) -> target_strs::t {
return target_strs::t {

View file

@ -10,9 +10,9 @@
use back::target_strs;
use driver::session::sess_os_to_meta_os;
use driver::session;
use metadata::loader::meta_section_name;
use session::sess_os_to_meta_os;
pub fn get_target_strs(target_os: session::os) -> target_strs::t {
return target_strs::t {

View file

@ -12,14 +12,15 @@
use back::link;
use back::{arm, x86, x86_64};
use driver::session::{Aggressive};
use driver::session::{Session, Session_, OptLevel, No, Less, Default};
use driver::session;
use front;
use lib::llvm::llvm;
use metadata::{creader, cstore, filesearch};
use metadata;
use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
use middle;
use session::{Session, Session_, OptLevel, No, Less, Default, Aggressive};
use session;
use util::ppaux;
use core::cmp;

View file

@ -13,7 +13,7 @@
use back::link;
use back::target_strs;
use back;
use driver;
use driver::driver::host_triple;
use driver::session;
use metadata::filesearch;
use metadata;
@ -293,7 +293,7 @@ pub fn basic_options() -> @options {
output_type: link::output_type_exe,
addl_lib_search_paths: ~[],
maybe_sysroot: None,
target_triple: driver::host_triple(),
target_triple: host_triple(),
cfg: ~[],
binary: ~"rustc",
test: false,

View file

@ -11,7 +11,7 @@
// NB: this file is include_str!'ed into the compiler, re-parsed
// and injected into each crate the compiler builds. Keep it small.
mod intrinsic {
pub mod intrinsic {
pub use intrinsic::rusti::visit_tydesc;
// FIXME (#3727): remove this when the interface has settled and the

View file

@ -12,23 +12,22 @@
use core::prelude::*;
use driver::session::Session;
use driver::session;
use front::config;
use session::Session;
use core::dvec::DVec;
use core::option;
use core::vec;
use syntax::ast_util::*;
use syntax::attr::attrs_contains_name;
use syntax::attr;
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
use syntax::codemap;
use syntax::ext::base::{mk_ctxt, ext_ctxt};
use syntax::fold;
use syntax::print::pprust;
use syntax::{ast, ast_util};
use syntax::attr::attrs_contains_name;
use syntax::ext::base::{mk_ctxt, ext_ctxt};
type node_id_gen = fn@() -> ast::node_id;
@ -286,7 +285,7 @@ fn mk_std(cx: &TestCtxt) -> @ast::view_item {
let vi = ast::view_item {
node: vi,
attrs: ~[],
vis: ast::private,
vis: ast::public,
span: dummy_sp()
};
return @vi;

View file

@ -80,7 +80,7 @@ fn dump_crates(+crate_cache: @mut ~[cache_entry]) {
fn warn_if_multiple_versions(e: @mut Env,
diag: span_handler,
crate_cache: @mut ~[cache_entry]) {
use either::*;
use core::either::*;
if crate_cache.len() != 0u {
let name = loader::crate_name_from_metas(

View file

@ -14,9 +14,6 @@
use core::prelude::*;
use metadata::cstore::crate_metadata;
use dvec::DVec;
use hash::{Hash, HashUtil};
use io::WriterUtil;
use metadata::common::*;
use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo};
use metadata::csearch;
@ -28,8 +25,11 @@
use util::ppaux::ty_to_str;
use core::cmp;
use core::dvec::DVec;
use core::dvec;
use core::hash::{Hash, HashUtil};
use core::int;
use core::io::WriterUtil;
use core::io;
use core::option;
use core::str;

View file

@ -34,7 +34,7 @@
use core::ptr;
use std::oldmap::HashMap;
use str_eq = str::eq;
use str_eq = core::str::eq;
pub enum LangItem {
ConstTraitLangItem, // 0

View file

@ -77,15 +77,14 @@
use syntax::opt_vec;
use syntax::opt_vec::OptVec;
use managed::ptr_eq;
use dvec::DVec;
use option::{Some, get, is_some, is_none};
use str::{connect, split_str};
use vec::pop;
use core::dvec::DVec;
use core::managed::ptr_eq;
use core::option::{Some, get, is_some, is_none};
use core::str::{connect, split_str};
use core::vec::pop;
use std::list::{Cons, List, Nil};
use std::oldmap::HashMap;
use str_eq = str::eq;
use str_eq = core::str::eq;
// Definition mapping
pub type DefMap = HashMap<node_id,def>;
@ -305,6 +304,12 @@ pub enum AllowCapturingSelfFlag {
DontAllowCapturingSelf, //< The "self" definition cannot be captured.
}
#[deriving_eq]
enum NameSearchType {
SearchItemsAndPublicImports, //< Search items and public imports.
SearchItemsAndAllImports, //< Search items and all imports.
}
pub enum BareIdentifierPatternResolution {
FoundStructOrEnumVariant(def),
FoundConst(def),
@ -1488,7 +1493,7 @@ fn build_reduced_graph_for_view_item(@mut self,
let parent_link = ModuleParentLink
(self.get_module_from_parent(new_parent), name);
child_name_bindings.define_module(privacy,
child_name_bindings.define_module(Public,
parent_link,
Some(def_id),
NormalModuleKind,
@ -1948,10 +1953,8 @@ fn resolve_imports(@mut self) {
}
}
/**
* Attempts to resolve imports for the given module and all of its
* submodules.
*/
/// Attempts to resolve imports for the given module and all of its
/// submodules.
fn resolve_imports_for_module_subtree(@mut self, module_: @mut Module) {
debug!("(resolving imports for module subtree) resolving %s",
self.module_to_str(module_));
@ -1974,19 +1977,19 @@ fn resolve_imports_for_module_subtree(@mut self, module_: @mut Module) {
}
/// Attempts to resolve imports for the given module only.
fn resolve_imports_for_module(@mut self, module_: @mut Module) {
if (*module_).all_imports_resolved() {
fn resolve_imports_for_module(@mut self, module: @mut Module) {
if module.all_imports_resolved() {
debug!("(resolving imports for module) all imports resolved for \
%s",
self.module_to_str(module_));
self.module_to_str(module));
return;
}
let import_count = module_.imports.len();
while module_.resolved_import_count < import_count {
let import_index = module_.resolved_import_count;
let import_directive = module_.imports.get_elt(import_index);
match self.resolve_import_for_module(module_, import_directive) {
let import_count = module.imports.len();
while module.resolved_import_count < import_count {
let import_index = module.resolved_import_count;
let import_directive = module.imports.get_elt(import_index);
match self.resolve_import_for_module(module, import_directive) {
Failed => {
// We presumably emitted an error. Continue.
let idents = import_directive.module_path.get();
@ -2004,7 +2007,7 @@ fn resolve_imports_for_module(@mut self, module_: @mut Module) {
}
}
module_.resolved_import_count += 1;
module.resolved_import_count += 1;
}
}
@ -2037,72 +2040,71 @@ fn import_path_to_str(@mut self,
}
}
/**
* Attempts to resolve the given import. The return value indicates
* failure if we're certain the name does not exist, indeterminate if we
* don't know whether the name exists at the moment due to other
* currently-unresolved imports, or success if we know the name exists.
* If successful, the resolved bindings are written into the module.
*/
fn resolve_import_for_module(@mut self,
module_: @mut Module,
/// Attempts to resolve the given import. The return value indicates
/// failure if we're certain the name does not exist, indeterminate if we
/// don't know whether the name exists at the moment due to other
/// currently-unresolved imports, or success if we know the name exists.
/// If successful, the resolved bindings are written into the module.
fn resolve_import_for_module(@mut self, module_: @mut Module,
import_directive: @ImportDirective)
-> ResolveResult<()> {
let mut resolution_result;
let mut resolution_result = Failed;
let module_path = import_directive.module_path;
debug!("(resolving import for module) resolving import `%s::...` in \
`%s`",
self.idents_to_str((*module_path).get()),
self.idents_to_str(module_path.get()),
self.module_to_str(module_));
// One-level renaming imports of the form `import foo = bar;` are
// handled specially.
if (*module_path).len() == 0 {
resolution_result =
self.resolve_one_level_renaming_import(module_,
import_directive);
// First, resolve the module path for the directive, if necessary.
let containing_module = if module_path.len() == 0 {
// Use the crate root.
Some(self.graph_root.get_module())
} else {
// First, resolve the module path for the directive, if necessary.
match self.resolve_module_path_for_import(module_,
module_path,
DontUseLexicalScope,
import_directive.span) {
Failed => {
resolution_result = Failed;
}
Failed => None,
Indeterminate => {
resolution_result = Indeterminate;
None
}
Success(containing_module) => {
// We found the module that the target is contained
// within. Attempt to resolve the import within it.
Success(containing_module) => Some(containing_module),
}
};
match *import_directive.subclass {
SingleImport(target, source, AnyNS) => {
resolution_result =
self.resolve_single_import(module_,
containing_module,
target,
source);
}
SingleImport(target, source, TypeNSOnly) => {
resolution_result =
self.resolve_single_module_import
(module_, containing_module, target,
source);
}
GlobImport => {
let span = import_directive.span;
let p = import_directive.privacy;
resolution_result =
self.resolve_glob_import(p,
module_,
containing_module,
span);
}
match containing_module {
None => {}
Some(containing_module) => {
// We found the module that the target is contained
// within. Attempt to resolve the import within it.
match *import_directive.subclass {
SingleImport(target, source, AnyNS) => {
resolution_result =
self.resolve_single_import(module_,
containing_module,
target,
source);
}
SingleImport(target, source, TypeNSOnly) => {
resolution_result =
self.resolve_single_module_import(
module_,
containing_module,
target,
source);
}
GlobImport => {
let span = import_directive.span;
let privacy = import_directive.privacy;
resolution_result =
self.resolve_glob_import(privacy,
module_,
containing_module,
span);
}
}
}
@ -2575,11 +2577,13 @@ fn resolve_glob_import(@mut self,
return Success(());
}
/// Resolves the given module path from the given root `module_`.
fn resolve_module_path_from_root(@mut self,
module_: @mut Module,
module_path: @DVec<ident>,
index: uint,
span: span)
span: span,
mut name_search_type: NameSearchType)
-> ResolveResult<@mut Module> {
let mut search_module = module_;
let mut index = index;
@ -2594,7 +2598,7 @@ fn resolve_module_path_from_root(@mut self,
match self.resolve_name_in_module(search_module,
name,
TypeNS,
false) {
name_search_type) {
Failed => {
self.session.span_err(span, ~"unresolved name");
return Failed;
@ -2639,22 +2643,33 @@ fn resolve_module_path_from_root(@mut self,
}
index += 1;
// After the first element of the path, allow searching through
// items and imports unconditionally. This allows things like:
//
// pub mod core {
// pub use vec;
// }
//
// pub mod something_else {
// use core::vec;
// }
name_search_type = SearchItemsAndPublicImports;
}
return Success(search_module);
}
/**
* Attempts to resolve the module part of an import directive or path
* rooted at the given module.
*/
/// Attempts to resolve the module part of an import directive or path
/// rooted at the given module.
fn resolve_module_path_for_import(@mut self,
module_: @mut Module,
module_path: @DVec<ident>,
use_lexical_scope: UseLexicalScopeFlag,
span: span)
-> ResolveResult<@mut Module> {
let module_path_len = (*module_path).len();
let module_path_len = module_path.len();
assert module_path_len > 0;
debug!("(resolving module path for import) processing `%s` rooted at \
@ -2721,12 +2736,15 @@ fn resolve_module_path_for_import(@mut self,
}
}
return self.resolve_module_path_from_root(search_module,
module_path,
start_index,
span);
self.resolve_module_path_from_root(search_module,
module_path,
start_index,
span,
SearchItemsAndPublicImports)
}
/// Invariant: This must only be called during main resolution, not during
/// import resolution.
fn resolve_item_in_lexical_scope(@mut self,
module_: @mut Module,
name: ident,
@ -2822,7 +2840,7 @@ fn resolve_item_in_lexical_scope(@mut self,
match self.resolve_name_in_module(search_module,
name,
namespace,
false) {
SearchItemsAndAllImports) {
Failed => {
// Continue up the search chain.
}
@ -2973,16 +2991,14 @@ fn resolve_module_prefix(@mut self,
return Success(PrefixFound(containing_module, i));
}
/**
* Attempts to resolve the supplied name in the given module for the
* given namespace. If successful, returns the target corresponding to
* the name.
*/
/// Attempts to resolve the supplied name in the given module for the
/// given namespace. If successful, returns the target corresponding to
/// the name.
fn resolve_name_in_module(@mut self,
module_: @mut Module,
name: ident,
namespace: Namespace,
allow_globs: bool)
+name_search_type: NameSearchType)
-> ResolveResult<Target> {
debug!("(resolving name in module) resolving `%s` in `%s`",
*self.session.str_of(name),
@ -3001,35 +3017,42 @@ fn resolve_name_in_module(@mut self,
}
}
// Next, check the module's imports. If the module has a glob and
// globs were not allowed, then we bail out; we don't know its imports
// yet.
if !allow_globs && module_.glob_count > 0 {
debug!("(resolving name in module) module has glob; bailing out");
return Indeterminate;
// Next, check the module's imports if necessary.
// If this is a search of all imports, we should be done with glob
// resolution at this point.
if name_search_type == SearchItemsAndAllImports {
assert module_.glob_count == 0;
}
// Otherwise, we check the list of resolved imports.
// Check the list of resolved imports.
match module_.import_resolutions.find(&name) {
Some(import_resolution) => {
if import_resolution.outstanding_references != 0 {
debug!("(resolving name in module) import unresolved; \
bailing out");
debug!("(resolving name in module) import \
unresolved; bailing out");
return Indeterminate;
}
match (*import_resolution).target_for_namespace(namespace) {
match import_resolution.target_for_namespace(namespace) {
None => {
debug!("(resolving name in module) name found, but \
not in namespace %?",
debug!("(resolving name in module) name found, \
but not in namespace %?",
namespace);
}
Some(target) => {
Some(target)
if name_search_type ==
SearchItemsAndAllImports ||
import_resolution.privacy == Public => {
debug!("(resolving name in module) resolved to \
import");
import_resolution.state.used = true;
return Success(copy target);
}
Some(_) => {
debug!("(resolving name in module) name found, \
but not public");
}
}
}
None => {
@ -3043,168 +3066,6 @@ fn resolve_name_in_module(@mut self,
return Failed;
}
/**
* Resolves a one-level renaming import of the kind `import foo = bar;`
* This needs special handling, as, unlike all of the other imports, it
* needs to look in the scope chain for modules and non-modules alike.
*/
fn resolve_one_level_renaming_import(@mut self,
module_: @mut Module,
import_directive: @ImportDirective)
-> ResolveResult<()> {
let mut target_name;
let mut source_name;
let allowable_namespaces;
match *import_directive.subclass {
SingleImport(target, source, namespaces) => {
target_name = target;
source_name = source;
allowable_namespaces = namespaces;
}
GlobImport => {
fail!(~"found `import *`, which is invalid");
}
}
debug!("(resolving one-level naming result) resolving import `%s` = \
`%s` in `%s`",
*self.session.str_of(target_name),
*self.session.str_of(source_name),
self.module_to_str(module_));
// Find the matching items in the lexical scope chain for every
// namespace. If any of them come back indeterminate, this entire
// import is indeterminate.
let mut module_result;
debug!("(resolving one-level naming result) searching for module");
match self.resolve_item_in_lexical_scope(module_,
source_name,
TypeNS,
SearchThroughModules) {
Failed => {
debug!("(resolving one-level renaming import) didn't find \
module result");
module_result = None;
}
Indeterminate => {
debug!("(resolving one-level renaming import) module result \
is indeterminate; bailing");
return Indeterminate;
}
Success(name_bindings) => {
debug!("(resolving one-level renaming import) module result \
found");
module_result = Some(copy name_bindings);
}
}
let mut value_result;
let mut type_result;
if allowable_namespaces == TypeNSOnly {
value_result = None;
type_result = None;
} else {
debug!("(resolving one-level naming result) searching for value");
match self.resolve_item_in_lexical_scope(module_,
source_name,
ValueNS,
SearchThroughModules) {
Failed => {
debug!("(resolving one-level renaming import) didn't \
find value result");
value_result = None;
}
Indeterminate => {
debug!("(resolving one-level renaming import) value \
result is indeterminate; bailing");
return Indeterminate;
}
Success(name_bindings) => {
debug!("(resolving one-level renaming import) value \
result found");
value_result = Some(copy name_bindings);
}
}
debug!("(resolving one-level naming result) searching for type");
match self.resolve_item_in_lexical_scope(module_,
source_name,
TypeNS,
SearchThroughModules) {
Failed => {
debug!("(resolving one-level renaming import) didn't \
find type result");
type_result = None;
}
Indeterminate => {
debug!("(resolving one-level renaming import) type \
result is indeterminate; bailing");
return Indeterminate;
}
Success(name_bindings) => {
debug!("(resolving one-level renaming import) type \
result found");
type_result = Some(copy name_bindings);
}
}
}
//
// NB: This one results in effects that may be somewhat surprising. It
// means that this:
//
// mod A {
// impl foo for ... { ... }
// mod B {
// impl foo for ... { ... }
// import bar = foo;
// ...
// }
// }
//
// results in only A::B::foo being aliased to A::B::bar, not A::foo
// *and* A::B::foo being aliased to A::B::bar.
//
// If nothing at all was found, that's an error.
if is_none(&module_result) &&
is_none(&value_result) &&
is_none(&type_result) {
self.session.span_err(import_directive.span,
~"unresolved import");
return Failed;
}
// Otherwise, proceed and write in the bindings.
match module_.import_resolutions.find(&target_name) {
None => {
fail!(~"(resolving one-level renaming import) reduced graph \
construction or glob importing should have created the \
import resolution name by now");
}
Some(import_resolution) => {
debug!("(resolving one-level renaming import) writing module \
result %? for `%s` into `%s`",
is_none(&module_result),
*self.session.str_of(target_name),
self.module_to_str(module_));
import_resolution.value_target = value_result;
import_resolution.type_target = type_result;
assert import_resolution.outstanding_references >= 1;
import_resolution.outstanding_references -= 1;
}
}
debug!("(resolving one-level renaming import) successfully resolved");
return Success(());
}
fn report_unresolved_imports(@mut self, module_: @mut Module) {
let index = module_.resolved_import_count;
let import_count = module_.imports.len();
@ -4538,10 +4399,8 @@ fn resolve_bare_identifier_pattern(@mut self, name: ident)
}
}
/**
* If `check_ribs` is true, checks the local definitions first; i.e.
* doesn't skip straight to the containing module.
*/
/// If `check_ribs` is true, checks the local definitions first; i.e.
/// doesn't skip straight to the containing module.
fn resolve_path(@mut self,
path: @path,
namespace: Namespace,
@ -4714,6 +4573,8 @@ fn resolve_module_relative_path(@mut self,
}
}
/// Invariant: This must be called only during main resolution, not during
/// import resolution.
fn resolve_crate_relative_path(@mut self,
path: @path,
+xray: XrayFlag,
@ -4727,8 +4588,8 @@ fn resolve_crate_relative_path(@mut self,
match self.resolve_module_path_from_root(root_module,
module_path_idents,
0,
path.span) {
path.span,
SearchItemsAndAllImports) {
Failed => {
self.session.span_err(path.span,
fmt!("use of undeclared module `::%s`",

View file

@ -8,26 +8,25 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use codemap::span;
use lib;
use lib::llvm::llvm;
use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering};
use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False};
use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
use libc::{c_uint, c_int, c_ulonglong};
use lib;
use middle::trans::common::*;
use middle::trans::machine::llsize_of_real;
use core::prelude::*;
use core::cast::transmute;
use core::cast;
use core::libc::{c_uint, c_int, c_ulonglong};
use core::libc;
use core::option::Some;
use core::ptr;
use core::str;
use core::vec;
use std::oldmap::HashMap;
use syntax::codemap::span;
use syntax::codemap;
pub fn terminate(cx: block, _: &str) {

View file

@ -10,6 +10,7 @@
use core::prelude::*;
use driver::session::Session;
use driver::session;
use metadata::csearch;
use metadata;
@ -22,7 +23,6 @@
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, tys_to_str};

View file

@ -24,10 +24,10 @@
use util::ppaux::tys_to_str;
use util::ppaux;
use core::result::{Result, Ok, Err};
use core::result;
use core::uint;
use core::vec;
use result::{Result, Ok, Err};
use std::oldmap::HashMap;
use syntax::ast;
use syntax::ast_util;

View file

@ -552,13 +552,12 @@ fn<a,b>(&a, &b, &a) fn<x,y>(&x, &y, &y) fn<a>(&a, &a, &a) fn<a,b,c>(&a,&b,&c)
use core::cell::{Cell, empty_cell};
use core::cmp;
use core::dvec::DVec;
use core::result::{Err, Ok, Result};
use core::to_bytes;
use core::uint;
use core::vec;
use result::Result;
use result::{Ok, Err};
use std::oldmap::HashMap;
use std::list::{List, Nil, Cons};
use std::oldmap::HashMap;
use syntax::codemap::span;
use syntax::codemap;

View file

@ -134,22 +134,22 @@ pub mod lib {
pub mod llvm;
}
use result::{Ok, Err};
use io::ReaderUtil;
use std::getopts;
use std::oldmap::HashMap;
use getopts::{opt_present};
use getopts::groups;
use syntax::codemap;
use syntax::diagnostic;
use driver::driver::{host_triple, optgroups, early_error,
str_input, file_input, build_session_options,
build_session, build_configuration, parse_pretty,
pp_mode, pretty_print_input, list_metadata,
compile_input};
use driver::driver::{host_triple, optgroups, early_error};
use driver::driver::{str_input, file_input, build_session_options};
use driver::driver::{build_session, build_configuration, parse_pretty};
use driver::driver::{pp_mode, pretty_print_input, list_metadata};
use driver::driver::{compile_input};
use driver::session;
use middle::lint;
use core::io::ReaderUtil;
use core::result::{Ok, Err};
use std::getopts::{groups, opt_present};
use std::getopts;
use std::oldmap::HashMap;
use syntax::codemap;
use syntax::diagnostic;
pub fn version(argv0: &str) {
let mut vers = ~"unknown version";
let env_vers = env!("CFG_VERSION");

View file

@ -85,7 +85,7 @@ fn opts() -> ~[(getopts::Opt, ~str)] {
}
pub fn usage() {
use io::println;
use core::io::println;
println(~"Usage: rustdoc [options] <cratefile>\n");
println(~"Options:\n");

View file

@ -108,7 +108,7 @@ fn pandoc_writer(
];
do generic_writer |markdown| {
use io::WriterUtil;
use core::io::WriterUtil;
debug!("pandoc cmd: %s", pandoc_cmd);
debug!("pandoc args: %s", str::connect(pandoc_args, ~" "));
@ -281,7 +281,7 @@ pub fn mk_doc(name: ~str, source: ~str) -> doc::Doc {
}
fn write_file(path: &Path, s: ~str) {
use io::WriterUtil;
use core::io::WriterUtil;
match io::file_writer(path, ~[io::Create, io::Truncate]) {
result::Ok(writer) => {

View file

@ -31,41 +31,41 @@ extern mod syntax(vers = "0.6");
use core::*;
use std::par;
mod pass;
mod config;
mod parse;
mod extract;
mod attr_parser;
mod doc;
mod markdown_index_pass;
mod markdown_pass;
mod markdown_writer;
mod fold;
mod path_pass;
mod attr_pass;
mod tystr_pass;
mod prune_hidden_pass;
mod desc_to_brief_pass;
mod text_pass;
mod unindent_pass;
mod trim_pass;
mod astsrv;
mod demo;
mod sort_pass;
mod sort_item_name_pass;
mod sort_item_type_pass;
mod page_pass;
mod sectionalize_pass;
mod escape_pass;
mod prune_private_pass;
mod util;
pub mod pass;
pub mod config;
pub mod parse;
pub mod extract;
pub mod attr_parser;
pub mod doc;
pub mod markdown_index_pass;
pub mod markdown_pass;
pub mod markdown_writer;
pub mod fold;
pub mod path_pass;
pub mod attr_pass;
pub mod tystr_pass;
pub mod prune_hidden_pass;
pub mod desc_to_brief_pass;
pub mod text_pass;
pub mod unindent_pass;
pub mod trim_pass;
pub mod astsrv;
pub mod demo;
pub mod sort_pass;
pub mod sort_item_name_pass;
pub mod sort_item_type_pass;
pub mod page_pass;
pub mod sectionalize_pass;
pub mod escape_pass;
pub mod prune_private_pass;
pub mod util;
use doc::ItemUtils;
use doc::Item;
use pass::Pass;
use config::Config;
fn main() {
pub fn main() {
let args = os::args();
if args.contains(&~"-h") || args.contains(&~"--help") {
@ -144,7 +144,7 @@ fn run(config: Config) {
}
}
fn time<T>(what: ~str, f: fn() -> T) -> T {
pub fn time<T>(what: ~str, f: fn() -> T) -> T {
let start = std::time::precise_time_s();
let rv = f();
let end = std::time::precise_time_s();

View file

@ -27,14 +27,14 @@ extern mod rustc(vers = "0.6");
extern mod syntax(vers = "0.6");
use core::*;
use io::{ReaderUtil, WriterUtil};
use std::{json, semver, getopts};
use std::net::url;
use hashmap::linear::LinearMap;
use rustc::metadata::filesearch;
use core::hashmap::linear::LinearMap;
use core::io::{ReaderUtil, WriterUtil};
use rustc::driver::{driver, session};
use syntax::{ast, attr, codemap, diagnostic, parse, visit};
use rustc::metadata::filesearch;
use std::net::url;
use std::{json, semver, getopts};
use syntax::codemap::spanned;
use syntax::{ast, attr, codemap, diagnostic, parse, visit};
mod usage;
mod util;

View file

@ -8,20 +8,20 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::*;
use hashmap::linear::LinearMap;
use rustc::metadata::filesearch;
use rustc::driver::{driver, session};
use syntax::ast_util::*;
use syntax::{ast, attr, codemap, diagnostic, fold, parse, visit};
use codemap::{span, dummy_sp, spanned};
use std::semver;
use std::{json, term, sort, getopts};
use getopts::groups::getopts;
use Listener;
use core::*;
use core::hashmap::linear::LinearMap;
use rustc::driver::{driver, session};
use rustc::metadata::filesearch;
use std::getopts::groups::getopts;
use std::semver;
use std::{json, term, sort, getopts};
use syntax::ast_util::*;
use syntax::codemap::{span, dummy_sp, spanned};
use syntax::ext::base::{mk_ctxt, ext_ctxt};
use syntax::ext::build;
use syntax::{ast, attr, codemap, diagnostic, fold, parse, visit};
pub struct Package {
id: ~str,

View file

@ -865,7 +865,7 @@ pub impl BigInt {
mod biguint_tests {
use core::*;
use num::{IntConvertible, Zero, One};
use core::num::{IntConvertible, Zero, One};
use super::{BigInt, BigUint, BigDigit};
#[test]

View file

@ -771,10 +771,10 @@ fn test_some_tcp_stream<U:Unflattener<int>,F:Flattener<int>>(
writer_chan: WriterChanFactory<F>,
port: uint) {
use net::tcp;
use core::cell::Cell;
use net::ip;
use cell::Cell;
use net::tcp::TcpSocket;
use net::tcp;
use uv;
// Indicate to the client task that the server is listening

View file

@ -10,14 +10,14 @@
//! Semver parsing and logic
use io;
use io::{ReaderUtil};
use option::{Option, Some, None};
use uint;
use str;
use to_str::ToStr;
use char;
use core::char;
use core::cmp;
use core::io::{ReaderUtil};
use core::io;
use core::option::{Option, Some, None};
use core::str;
use core::to_str::ToStr;
use core::uint;
#[deriving_eq]
pub enum Identifier {

View file

@ -113,7 +113,7 @@ pub mod serialize;
// 'std' so that macro-expanded references to std::serialize and such
// can be resolved within libcore.
#[doc(hidden)] // FIXME #3538
mod std {
pub mod std {
pub use serialize;
pub use test;
}

View file

@ -594,15 +594,14 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult {
}
pub mod bench {
use rand;
use u64;
use vec;
use time::precise_time_ns;
use test::{BenchHarness, BenchSamples};
use stats::Stats;
use num;
use rand;
use core::num;
use core::rand;
use core::u64;
use core::vec;
pub impl BenchHarness {

View file

@ -221,7 +221,7 @@ pub fn test_gl_timer_sleep_stress2() {
let ch = ch.clone();
let hl_loop_clone = hl_loop.clone();
do task::spawn {
use rand::*;
use core::rand::*;
let rng = Rng();
for iter::repeat(times) {
sleep(&hl_loop_clone, rng.next() as uint % maxms);

View file

@ -12,21 +12,20 @@
use ll = uv_ll;
use iotask = uv_iotask;
use get_gl = get;
use get_gl = self::get;
use uv_iotask::{IoTask, spawn_iotask};
use core::clone::Clone;
use core::comm::{Port, Chan, SharedChan, select2i};
use core::either::{Left, Right};
use core::libc;
use core::comm::{Port, Chan, SharedChan, select2i};
use core::unstable::global::{global_data_clone_create,
global_data_clone};
use core::unstable::weak_task::weaken_task;
use core::option::{Some, None};
use core::str;
use core::task::{task, SingleThreaded, spawn};
use core::task;
use core::unstable::global::{global_data_clone_create, global_data_clone};
use core::unstable::weak_task::weaken_task;
use core::vec;
use core::clone::Clone;
use core::option::{Some, None};
/**
* Race-free helper to get access to a global task where a libuv
@ -123,7 +122,7 @@ fn spawn_loop() -> IoTask {
mod test {
use core::prelude::*;
use get_gl = get;
use get_gl = uv_global_loop::get;
use uv::iotask;
use uv::ll;
use uv_global_loop::*;

View file

@ -396,7 +396,7 @@ fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
//#[test]
fn test() {
use io::WriterUtil;
use core::io::WriterUtil;
let db = @Mut(Database { db_filename: Path("db.json"),
db_cache: LinearMap::new(),

View file

@ -24,7 +24,8 @@
use ext::base;
use ext::build;
use ext::build::*;
use unstable::extfmt::ct::*;
use core::unstable::extfmt::ct::*;
pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {

View file

@ -61,10 +61,10 @@
use ast;
use ast_util::{ident_to_path, operator_prec};
use ast_util;
use classify;
use codemap::{span,FssNone, BytePos, spanned, respan, mk_sp};
use codemap;
use parse::attr::parser_attr;
use parse::classify;
use parse::common::{seq_sep_none, token_to_str};
use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed};
use parse::lexer::reader;

View file

@ -13,9 +13,8 @@
// type, and vice versa.
use core::prelude::*;
use hashmap::linear::LinearMap;
use dvec::DVec;
use core::dvec::DVec;
use core::hashmap::linear::LinearMap;
pub struct Interner<T> {
priv map: @mut LinearMap<T, uint>,

View file

@ -10,7 +10,7 @@
#[legacy_modes];
use dvec::DVec;
use core::dvec::DVec;
pub struct Entry<A,B> {key: A, value: B}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::Eq;
use core::cmp::Eq;
pub trait MyNum : Add<Self,Self> Sub<Self,Self> Mul<Self,Self> Eq {
}

View file

@ -8,8 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: unresolved
use baz::zed::bar;
use baz::zed::bar; //~ ERROR unresolved name
//~^ ERROR failed to resolve import
mod baz {}
mod zed {
pub fn bar() { debug!("bar3"); }

View file

@ -10,7 +10,8 @@
// Testing that we don't fail abnormally after hitting the errors
use unresolved::*; //~ ERROR unresolved import
use unresolved::*; //~ ERROR unresolved name
//~^ ERROR failed to resolve import
fn main() {
}

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use dvec::DVec;
use core::dvec::DVec;
type parser = {
struct parser {
tokens: DVec<int>,
};
}
trait parse {
fn parse() -> ~[int];
@ -20,7 +20,7 @@ trait parse {
impl parse for parser {
fn parse() -> ~[int] {
dvec::unwrap(self.tokens) //~ ERROR moving out of immutable field
::core::dvec::unwrap(self.tokens) //~ ERROR moving out of immutable field
}
}

View file

@ -13,7 +13,7 @@
// we let an impl method can have more permissive bounds than the trait
// method it's implementing, the return type might be less specific than
// needed. Just punt and make it invariant.
use iter::BaseIter;
use core::iter::BaseIter;
trait A {
fn b<C:Copy + Const,D>(x: C) -> C;

View file

@ -10,7 +10,7 @@
// Tests that an impl method's bounds aren't *more* restrictive
// than the trait method it's implementing
use iter::BaseIter;
use core::iter::BaseIter;
trait A {
fn b<C:Copy,D>(x: C) -> C;

View file

@ -10,7 +10,7 @@
// Tests that ty params get matched correctly when comparing
// an impl against a trait
use iter::BaseIter;
use core::iter::BaseIter;
trait A {
fn b<C:Copy,D>(x: C) -> C;

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::Eq;
use core::cmp::Eq;
trait Hahaha: Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq //~ ERROR Duplicate supertrait in trait declaration
Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq

View file

@ -9,7 +9,7 @@
// except according to those terms.
extern mod std;
use cmp::Eq;
use core::cmp::Eq;
fn f<T:Eq>(o: &mut Option<T>) {
assert *o == option::None;

View file

@ -11,7 +11,6 @@
extern mod std;
use option::Some;
// error-pattern: mismatched types

View file

@ -10,7 +10,6 @@
// except according to those terms.
extern mod std;
use option::Some;
// error-pattern: mismatched types

View file

@ -11,7 +11,7 @@
mod argparse {
extern mod std;
use either::{Either, Left, Right};
use core::either::{Either, Left, Right};
pub struct Flag {
name: &str,

View file

@ -11,7 +11,7 @@
// error-pattern:explicit failure
// Don't double free the string
extern mod std;
use io::ReaderUtil;
use core::io::ReaderUtil;
fn main() {
do io::with_str_reader(~"") |rdr| {

View file

@ -12,7 +12,7 @@
// the assert should fail at runtime
// error-pattern:Assertion same_length(chars, ints) failed
extern mod std;
use vec::{same_length, zip};
use core::vec::{same_length, zip};
fn enum_chars(start: u8, end: u8) -> ~[char] {
assert start < end;

View file

@ -17,13 +17,13 @@
// These tests used to be separate files, but I wanted to refactor all
// the common code.
use cmp::Eq;
use std::ebml;
use EBReader = std::ebml::reader;
use EBWriter = std::ebml::writer;
use io::Writer;
use std::serialize::{Encodable, Decodable};
use core::cmp::Eq;
use core::io::Writer;
use std::ebml;
use std::prettyprint;
use std::serialize::{Encodable, Decodable};
use std::time;
fn test_prettyprint<A:Encodable<prettyprint::Serializer>>(

View file

@ -9,10 +9,10 @@
// except according to those terms.
pub fn main() {
use vec::from_fn;
log(debug, vec::len(from_fn(2, |i| i)));
use core::vec::from_fn;
log(debug, ::core::vec::len(from_fn(2, |i| i)));
{
use vec::*;
use core::vec::*;
log(debug, len(~[2]));
}
}

View file

@ -12,7 +12,7 @@
use baz::zed;
use zed::bar;
use baz::zed::bar;
mod baz {
pub mod zed {

View file

@ -18,6 +18,6 @@ pub mod zed {
}
}
mod bar {
pub use zed::baz;
pub use foo::zed::baz;
}
pub fn main() { baz(); }

View file

@ -18,7 +18,7 @@ pub mod zed {
}
}
mod bar {
pub use zed::baz;
pub use foo::zed::baz;
pub mod foo {
pub mod zed {}
}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use iter::BaseIter;
use core::iter::BaseIter;
trait FlatMapToVec<A> {
fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B];

View file

@ -11,12 +11,11 @@
// except according to those terms.
extern mod std;
use io::WriterUtil;
use core::io::WriterUtil;
use std::oldmap::HashMap;
use std::json;
enum object
{
enum object {
bool_value(bool),
int_value(i64),
}

View file

@ -12,7 +12,7 @@
/// Map representation
use io::ReaderUtil;
use core::io::ReaderUtil;
extern mod std;

View file

@ -10,7 +10,7 @@
// xfail-fast
use comm::{Select2, Selectable};
use core::comm::{Select2, Selectable};
pub fn main() {
let (p,c) = comm::stream();

View file

@ -12,7 +12,7 @@
// rustc --test ignores2.rs && ./ignores2
extern mod std;
use path::{Path};
use core::path::{Path};
type rsrc_loader = fn~ (path: &Path) -> result::Result<~str, ~str>;

View file

@ -20,7 +20,7 @@
// Extern mod controls linkage. Use controls the visibility of names to modules that are
// already linked in. Using WriterUtil allows us to use the write_line method.
use io::WriterUtil;
use core::io::WriterUtil;
// Represents a position on a canvas.
struct Point {

View file

@ -1,6 +1,6 @@
extern mod std;
use comm::Chan;
use core::comm::Chan;
type RingBuffer = ~[float];
type SamplesFn = fn~ (samples: &RingBuffer);

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use io::println;
use core::io::println;
pub fn main() {
println("Hello world!");

View file

@ -11,9 +11,9 @@
// xfail-fast
use core::bool;
use core::libc::c_void;
use core::vec::UnboxedVecRepr;
use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor};
use libc::c_void;
use vec::UnboxedVecRepr;
#[doc = "High-level interfaces to `intrinsic::visit_ty` reflection system."]

View file

@ -11,7 +11,9 @@
// except according to those terms.
extern mod std;
use libc, sys, cast;
use core::libc;
use core::sys;
use core::cast;
use std::arena::Arena;
struct Bcx {

View file

@ -10,7 +10,7 @@
// xfail-fast
use cmp::Eq;
use core::cmp::Eq;
fn iter<T>(v: ~[T], it: fn(&T) -> bool) {
let mut i = 0u, l = v.len();

View file

@ -11,7 +11,7 @@
// xfail-fast
extern mod std;
use io::WriterUtil;
use core::io::WriterUtil;
use std::tempfile;
pub fn main() {

View file

@ -13,8 +13,8 @@
extern mod std;
use comm::Chan;
use comm::Port;
use core::comm::Chan;
use core::comm::Port;
pub fn main() { test05(); }

View file

@ -10,8 +10,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::{Eq, Ord};
use num::NumCast::from;
use core::cmp::{Eq, Ord};
use core::num::NumCast::from;
extern mod std;
use std::cmp::FuzzyEq;

View file

@ -12,7 +12,7 @@
// Extending Num and using inherited static methods
use num::NumCast::from;
use core::num::NumCast::from;
trait Num {
static fn from_int(i: int) -> Self;

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::Ord;
use num::NumCast::from;
use core::cmp::Ord;
use core::num::NumCast::from;
pub trait NumExt: NumCast Ord { }

View file

@ -12,8 +12,8 @@
// A more complex example of numeric extensions
use cmp::{Eq, Ord};
use num::NumCast::from;
use core::cmp::{Eq, Ord};
use core::num::NumCast::from;
extern mod std;
use std::cmp::FuzzyEq;

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::{Eq, Ord};
use num::NumCast::from;
use core::cmp::{Eq, Ord};
use core::num::NumCast::from;
pub trait NumExt: Eq Ord NumCast {}

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::{Eq, Ord};
use num::NumCast::from;
use core::cmp::{Eq, Ord};
use core::num::NumCast::from;
pub trait NumExt: Eq NumCast {}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::Eq;
use core::cmp::Eq;
trait MyNum : Eq { }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::Eq;
use core::cmp::Eq;
trait MyNum : Add<Self,Self> Sub<Self,Self> Mul<Self,Self> Eq { }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use cmp::Eq;
use core::cmp::Eq;
fn sendable() {

View file

@ -10,7 +10,7 @@
// In this case, the code should compile and should
// succeed at runtime
use vec::{head, last, same_length, zip};
use core::vec::{head, last, same_length, zip};
fn enum_chars(start: u8, end: u8) -> ~[char] {
assert start < end;