Skip to content

Commit

Permalink
auto merge of #16575 : pcwalton/rust/import-foo-as-bar, r=aturon
Browse files Browse the repository at this point in the history
of `use bar as foo`.

Change all uses of `use foo = bar` to `use bar as foo`.

Implements RFC #47.

Closes #16461.

[breaking-change]

r? @aturon
  • Loading branch information
bors committed Aug 18, 2014
2 parents fcbf012 + 67deb2e commit 98ec85f
Show file tree
Hide file tree
Showing 62 changed files with 140 additions and 136 deletions.
2 changes: 1 addition & 1 deletion src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ module through the rules above. It essentially allows public access into the
re-exported item. For example, this program is valid:

~~~~
pub use api = self::implementation;
pub use self::implementation as api;

mod implementation {
pub fn f() {}
Expand Down
4 changes: 2 additions & 2 deletions src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -3112,7 +3112,7 @@ use farm::*;
However, that's not all. You can also rename an item while you're bringing it into scope:

~~~
use egg_layer = farm::chicken;
use farm::chicken as egg_layer;
# mod farm { pub fn chicken() { println!("Laying eggs is fun!") } }
// ...
Expand Down Expand Up @@ -3335,7 +3335,7 @@ you just have to import it with an `use` statement.
For example, it re-exports `range` which is defined in `std::iter::range`:

~~~
use iter_range = std::iter::range;
use std::iter::range as iter_range;
fn main() {
// `range` is imported by default
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern crate libc;

#[deprecated = "use boxed instead"]
#[cfg(not(test))]
pub use owned = boxed;
pub use boxed as owned;

// Heaps provided for low-level allocation strategies

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use core::mem;
use vec::Vec;

/// Reexport the `sip::hash` function as our default hasher.
pub use hash = self::sip::hash;
pub use self::sip::hash as hash;

pub mod sip;

Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use core::fmt;
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::raw::Slice as RawSlice;

use {Mutable, MutableSeq};
use hash;
use str;
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
use MaybeOwnedSlice = str::Slice; // So many `Slice`s...
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
use vec::Vec;

/// A growable string stored as a UTF-8 encoded buffer.
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
use core::prelude::*;

use alloc::heap::{allocate, reallocate, deallocate};
use RawSlice = core::raw::Slice;
use core::cmp::max;
use core::default::Default;
use core::fmt;
use core::mem;
use core::num;
use core::ptr;
use core::raw::Slice as RawSlice;
use core::uint;

use {Mutable, MutableSeq};
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/kinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ by the compiler automatically for the types to which they apply.
*/

#[deprecated = "This has been renamed to Sync"]
pub use Share = self::Sync;
pub use self::Sync as Share;

/// Types able to be transferred across task boundaries.
#[lang="send"]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub mod collections;
/// Deprecated module in favor of `std::cell`
pub mod ty {
#[deprecated = "this type has been renamed to `UnsafeCell`"]
pub use Unsafe = cell::UnsafeCell;
pub use cell::UnsafeCell as Unsafe;
}

/* Core types and methods on primitives */
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use mem::size_of;
use kinds::marker;
use raw::Repr;
// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
use RawSlice = raw::Slice;
use raw::Slice as RawSlice;


//
Expand Down
6 changes: 3 additions & 3 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ forming a diamond-shaped acyclic graph and then pointing to the fifth
which is cyclic.
```rust
use dot = graphviz;
use graphviz as dot;
use graphviz::maybe_owned_vec::IntoMaybeOwnedVector;
type Nd = int;
Expand Down Expand Up @@ -147,7 +147,7 @@ labelled with the ⊆ character (specified using the HTML character
entity `&sube`).
```rust
use dot = graphviz;
use graphviz as dot;
use std::str;
type Nd = uint;
Expand Down Expand Up @@ -203,7 +203,7 @@ The output from this example is the same as the second example: the
Hasse-diagram for the subsets of the set `{x, y}`.
```rust
use dot = graphviz;
use graphviz as dot;
use std::str;
type Nd<'a> = (uint, &'a str);
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/message_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

use alloc::arc::Arc;
use mpsc = std::sync::mpsc_queue;
use std::sync::mpsc_queue as mpsc;
use std::kinds::marker;

pub enum PopResult<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/libgreen/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use coroutine::Coroutine;
use sleeper_list::SleeperList;
use stack::StackPool;
use task::{TypeSched, GreenTask, HomeSched, AnySched};
use msgq = message_queue;
use message_queue as msgq;

/// A scheduler is responsible for coordinating the execution of Tasks
/// on a single thread. The scheduler runs inside a slightly modified
Expand Down
4 changes: 2 additions & 2 deletions src/libnative/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ mod tty;
#[cfg(windows)] #[path = "c_win32.rs"] mod c;

fn unimpl() -> IoError {
#[cfg(unix)] use ERROR = libc::ENOSYS;
#[cfg(windows)] use ERROR = libc::ERROR_CALL_NOT_IMPLEMENTED;
#[cfg(unix)] use libc::ENOSYS as ERROR;
#[cfg(windows)] use libc::ERROR_CALL_NOT_IMPLEMENTED as ERROR;
IoError {
code: ERROR as uint,
extra: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/libnative/io/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
})
}
_ => {
#[cfg(unix)] use ERROR = libc::EINVAL;
#[cfg(windows)] use ERROR = libc::WSAEINVAL;
#[cfg(unix)] use libc::EINVAL as ERROR;
#[cfg(windows)] use libc::WSAEINVAL as ERROR;
Err(IoError {
code: ERROR as uint,
extra: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/libnative/io/pipe_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ fn addr_to_sockaddr_un(addr: &CString,

let len = addr.len();
if len > s.sun_path.len() - 1 {
#[cfg(unix)] use ERROR = libc::EINVAL;
#[cfg(windows)] use ERROR = libc::WSAEINVAL;
#[cfg(unix)] use libc::EINVAL as ERROR;
#[cfg(windows)] use libc::WSAEINVAL as ERROR;
return Err(IoError {
code: ERROR as uint,
extra: 0,
Expand Down
8 changes: 4 additions & 4 deletions src/libnative/io/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ impl rtio::RtioProcess for Process {
}

fn kill(&mut self, signum: int) -> IoResult<()> {
#[cfg(unix)] use ERROR = libc::EINVAL;
#[cfg(windows)] use ERROR = libc::ERROR_NOTHING_TO_TERMINATE;
#[cfg(unix)] use libc::EINVAL as ERROR;
#[cfg(windows)] use libc::ERROR_NOTHING_TO_TERMINATE as ERROR;

// On linux (and possibly other unices), a process that has exited will
// continue to accept signals because it is "defunct". The delivery of
Expand Down Expand Up @@ -192,8 +192,8 @@ impl Drop for Process {
}

fn pipe() -> IoResult<(file::FileDesc, file::FileDesc)> {
#[cfg(unix)] use ERROR = libc::EMFILE;
#[cfg(windows)] use ERROR = libc::WSAEMFILE;
#[cfg(unix)] use libc::EMFILE as ERROR;
#[cfg(windows)] use libc::WSAEMFILE as ERROR;
struct Closer { fd: libc::c_int }

let os::Pipe { reader, writer } = match unsafe { os::pipe() } {
Expand Down
16 changes: 8 additions & 8 deletions src/libnative/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub enum SocketStatus {
}

pub fn timeout(desc: &'static str) -> IoError {
#[cfg(unix)] use ERROR = libc::ETIMEDOUT;
#[cfg(windows)] use ERROR = libc::ERROR_OPERATION_ABORTED;
#[cfg(unix)] use libc::ETIMEDOUT as ERROR;
#[cfg(windows)] use libc::ERROR_OPERATION_ABORTED as ERROR;
IoError {
code: ERROR as uint,
extra: 0,
Expand All @@ -35,8 +35,8 @@ pub fn timeout(desc: &'static str) -> IoError {
}

pub fn short_write(n: uint, desc: &'static str) -> IoError {
#[cfg(unix)] use ERROR = libc::EAGAIN;
#[cfg(windows)] use ERROR = libc::ERROR_OPERATION_ABORTED;
#[cfg(unix)] use libc::EAGAIN as ERROR;
#[cfg(windows)] use libc::ERROR_OPERATION_ABORTED as ERROR;
IoError {
code: ERROR as uint,
extra: n,
Expand Down Expand Up @@ -102,10 +102,10 @@ pub fn connect_timeout(fd: net::sock_t,
len: libc::socklen_t,
timeout_ms: u64) -> IoResult<()> {
use std::os;
#[cfg(unix)] use INPROGRESS = libc::EINPROGRESS;
#[cfg(windows)] use INPROGRESS = libc::WSAEINPROGRESS;
#[cfg(unix)] use WOULDBLOCK = libc::EWOULDBLOCK;
#[cfg(windows)] use WOULDBLOCK = libc::WSAEWOULDBLOCK;
#[cfg(unix)] use libc::EINPROGRESS as INPROGRESS;
#[cfg(windows)] use libc::WSAEINPROGRESS as INPROGRESS;
#[cfg(unix)] use libc::EWOULDBLOCK as WOULDBLOCK;
#[cfg(windows)] use libc::WSAEWOULDBLOCK as WOULDBLOCK;

// Make sure the call to connect() doesn't block
try!(set_nonblocking(fd, true));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use metadata::common::LinkMeta;
use metadata::creader;
use middle::borrowck::{FnPartsWithCFG};
use middle::borrowck;
use borrowck_dot = middle::borrowck::graphviz;
use middle::borrowck::graphviz as borrowck_dot;
use middle::cfg;
use middle::cfg::graphviz::LabelledCFG;
use middle::{trans, freevars, stability, kind, ty, typeck, reachable};
Expand All @@ -35,7 +35,7 @@ use util::common::time;
use util::ppaux;
use util::nodemap::{NodeSet};

use dot = graphviz;
use graphviz as dot;

use serialize::{json, Encodable};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::io::fs;
use std::dynamic_lib::DynamicLibrary;
use std::collections::HashSet;

use myfs = util::fs;
use util::fs as myfs;

pub enum FileMatch { FileMatches, FileDoesntMatch }

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
// FIXME: remove this after snapshot, and Results are handled
#![allow(unused_must_use)]

use c = metadata::common;
use cstore = metadata::cstore;
use metadata::common as c;
use metadata::cstore as cstore;
use driver::session::Session;
use metadata::decoder;
use middle::def;
use e = metadata::encoder;
use metadata::encoder as e;
use middle::freevars::{CaptureMode, freevar_entry};
use middle::freevars;
use middle::region;
use metadata::tydecode;
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter,
RegionParameter};
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter};
use metadata::tydecode::{RegionParameter};
use metadata::tyencode;
use middle::subst;
use middle::subst::VecPerParamSpace;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@


use middle::borrowck::*;
use euv = middle::expr_use_visitor;
use mc = middle::mem_categorization;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use syntax::ast;
use syntax::codemap::Span;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/borrowck/gather_loans/gather_moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* Computes moves.
*/

use mc = middle::mem_categorization;
use middle::borrowck::*;
use middle::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
use middle::borrowck::gather_loans::move_error::MoveSpanAndPath;
use middle::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
use middle::borrowck::move_data::*;
use euv = middle::expr_use_visitor;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use syntax::ast;
use syntax::codemap::Span;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/gather_loans/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/

use middle::borrowck::*;
use euv = middle::expr_use_visitor;
use mc = middle::mem_categorization;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use util::ppaux::Repr;
use syntax::ast;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/gather_loans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

use middle::borrowck::*;
use middle::borrowck::move_data::MoveData;
use euv = middle::expr_use_visitor;
use mc = middle::mem_categorization;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use util::ppaux::{Repr};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/borrowck/gather_loans/move_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use mc = middle::mem_categorization;
use middle::mem_categorization as mc;
use middle::borrowck::BorrowckCtxt;
use middle::ty;

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/gather_loans/restrictions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

use middle::borrowck::*;
use euv = middle::expr_use_visitor;
use mc = middle::mem_categorization;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use syntax::codemap::Span;
use util::ppaux::Repr;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
//! data to rendered labels.

/// For clarity, rename the graphviz crate locally to dot.
use dot = graphviz;
use graphviz as dot;
pub use middle::cfg::graphviz::{Node, Edge};
use cfg_dot = middle::cfg::graphviz;
use middle::cfg::graphviz as cfg_dot;

use middle::borrowck;
use middle::borrowck::{BorrowckCtxt, LoanPath};
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use middle::dataflow::DataFlowContext;
use middle::dataflow::BitwiseOperator;
use middle::dataflow::DataFlowOperator;
use middle::def;
use euv = middle::expr_use_visitor;
use mc = middle::mem_categorization;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use util::ppaux::{note_and_explain_region, Repr, UserString};

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use middle::cfg;
use middle::dataflow::DataFlowContext;
use middle::dataflow::BitwiseOperator;
use middle::dataflow::DataFlowOperator;
use euv = middle::expr_use_visitor;
use mc = middle::mem_categorization;
use middle::expr_use_visitor as euv;
use middle::mem_categorization as mc;
use middle::ty;
use syntax::ast;
use syntax::ast_util;
Expand Down
Loading

0 comments on commit 98ec85f

Please sign in to comment.