Skip to content

Commit 98ec85f

Browse files
committed
auto merge of #16575 : pcwalton/rust/import-foo-as-bar, r=aturon
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
2 parents fcbf012 + 67deb2e commit 98ec85f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+140
-136
lines changed

src/doc/rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ module through the rules above. It essentially allows public access into the
18011801
re-exported item. For example, this program is valid:
18021802

18031803
~~~~
1804-
pub use api = self::implementation;
1804+
pub use self::implementation as api;
18051805
18061806
mod implementation {
18071807
pub fn f() {}

src/doc/tutorial.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,7 @@ use farm::*;
31123112
However, that's not all. You can also rename an item while you're bringing it into scope:
31133113

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

33373337
~~~
3338-
use iter_range = std::iter::range;
3338+
use std::iter::range as iter_range;
33393339
33403340
fn main() {
33413341
// `range` is imported by default

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extern crate libc;
8686

8787
#[deprecated = "use boxed instead"]
8888
#[cfg(not(test))]
89-
pub use owned = boxed;
89+
pub use boxed as owned;
9090

9191
// Heaps provided for low-level allocation strategies
9292

src/libcollections/hash/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use core::mem;
7373
use vec::Vec;
7474

7575
/// Reexport the `sip::hash` function as our default hasher.
76-
pub use hash = self::sip::hash;
76+
pub use self::sip::hash as hash;
7777

7878
pub mod sip;
7979

src/libcollections/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ use core::fmt;
1919
use core::mem;
2020
use core::ptr;
2121
// FIXME: ICE's abound if you import the `Slice` type while importing `Slice` trait
22-
use RawSlice = core::raw::Slice;
22+
use core::raw::Slice as RawSlice;
2323

2424
use {Mutable, MutableSeq};
2525
use hash;
2626
use str;
2727
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
28-
use MaybeOwnedSlice = str::Slice; // So many `Slice`s...
28+
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
2929
use vec::Vec;
3030

3131
/// A growable string stored as a UTF-8 encoded buffer.

src/libcollections/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
use core::prelude::*;
1414

1515
use alloc::heap::{allocate, reallocate, deallocate};
16-
use RawSlice = core::raw::Slice;
1716
use core::cmp::max;
1817
use core::default::Default;
1918
use core::fmt;
2019
use core::mem;
2120
use core::num;
2221
use core::ptr;
22+
use core::raw::Slice as RawSlice;
2323
use core::uint;
2424

2525
use {Mutable, MutableSeq};

src/libcore/kinds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ by the compiler automatically for the types to which they apply.
2121
*/
2222

2323
#[deprecated = "This has been renamed to Sync"]
24-
pub use Share = self::Sync;
24+
pub use self::Sync as Share;
2525

2626
/// Types able to be transferred across task boundaries.
2727
#[lang="send"]

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub mod collections;
107107
/// Deprecated module in favor of `std::cell`
108108
pub mod ty {
109109
#[deprecated = "this type has been renamed to `UnsafeCell`"]
110-
pub use Unsafe = cell::UnsafeCell;
110+
pub use cell::UnsafeCell as Unsafe;
111111
}
112112

113113
/* Core types and methods on primitives */

src/libcore/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use mem::size_of;
5050
use kinds::marker;
5151
use raw::Repr;
5252
// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
53-
use RawSlice = raw::Slice;
53+
use raw::Slice as RawSlice;
5454

5555

5656
//

src/libgraphviz/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ forming a diamond-shaped acyclic graph and then pointing to the fifth
4747
which is cyclic.
4848
4949
```rust
50-
use dot = graphviz;
50+
use graphviz as dot;
5151
use graphviz::maybe_owned_vec::IntoMaybeOwnedVector;
5252
5353
type Nd = int;
@@ -147,7 +147,7 @@ labelled with the ⊆ character (specified using the HTML character
147147
entity `&sube`).
148148
149149
```rust
150-
use dot = graphviz;
150+
use graphviz as dot;
151151
use std::str;
152152
153153
type Nd = uint;
@@ -203,7 +203,7 @@ The output from this example is the same as the second example: the
203203
Hasse-diagram for the subsets of the set `{x, y}`.
204204
205205
```rust
206-
use dot = graphviz;
206+
use graphviz as dot;
207207
use std::str;
208208
209209
type Nd<'a> = (uint, &'a str);

src/libgreen/message_queue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use alloc::arc::Arc;
12-
use mpsc = std::sync::mpsc_queue;
12+
use std::sync::mpsc_queue as mpsc;
1313
use std::kinds::marker;
1414

1515
pub enum PopResult<T> {

src/libgreen/sched.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use coroutine::Coroutine;
2525
use sleeper_list::SleeperList;
2626
use stack::StackPool;
2727
use task::{TypeSched, GreenTask, HomeSched, AnySched};
28-
use msgq = message_queue;
28+
use message_queue as msgq;
2929

3030
/// A scheduler is responsible for coordinating the execution of Tasks
3131
/// on a single thread. The scheduler runs inside a slightly modified

src/libnative/io/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ mod tty;
7979
#[cfg(windows)] #[path = "c_win32.rs"] mod c;
8080

8181
fn unimpl() -> IoError {
82-
#[cfg(unix)] use ERROR = libc::ENOSYS;
83-
#[cfg(windows)] use ERROR = libc::ERROR_CALL_NOT_IMPLEMENTED;
82+
#[cfg(unix)] use libc::ENOSYS as ERROR;
83+
#[cfg(windows)] use libc::ERROR_CALL_NOT_IMPLEMENTED as ERROR;
8484
IoError {
8585
code: ERROR as uint,
8686
extra: 0,

src/libnative/io/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
210210
})
211211
}
212212
_ => {
213-
#[cfg(unix)] use ERROR = libc::EINVAL;
214-
#[cfg(windows)] use ERROR = libc::WSAEINVAL;
213+
#[cfg(unix)] use libc::EINVAL as ERROR;
214+
#[cfg(windows)] use libc::WSAEINVAL as ERROR;
215215
Err(IoError {
216216
code: ERROR as uint,
217217
extra: 0,

src/libnative/io/pipe_unix.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ fn addr_to_sockaddr_un(addr: &CString,
3939

4040
let len = addr.len();
4141
if len > s.sun_path.len() - 1 {
42-
#[cfg(unix)] use ERROR = libc::EINVAL;
43-
#[cfg(windows)] use ERROR = libc::WSAEINVAL;
42+
#[cfg(unix)] use libc::EINVAL as ERROR;
43+
#[cfg(windows)] use libc::WSAEINVAL as ERROR;
4444
return Err(IoError {
4545
code: ERROR as uint,
4646
extra: 0,

src/libnative/io/process.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ impl rtio::RtioProcess for Process {
148148
}
149149

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

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

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

199199
let os::Pipe { reader, writer } = match unsafe { os::pipe() } {

src/libnative/io/util.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub enum SocketStatus {
2525
}
2626

2727
pub fn timeout(desc: &'static str) -> IoError {
28-
#[cfg(unix)] use ERROR = libc::ETIMEDOUT;
29-
#[cfg(windows)] use ERROR = libc::ERROR_OPERATION_ABORTED;
28+
#[cfg(unix)] use libc::ETIMEDOUT as ERROR;
29+
#[cfg(windows)] use libc::ERROR_OPERATION_ABORTED as ERROR;
3030
IoError {
3131
code: ERROR as uint,
3232
extra: 0,
@@ -35,8 +35,8 @@ pub fn timeout(desc: &'static str) -> IoError {
3535
}
3636

3737
pub fn short_write(n: uint, desc: &'static str) -> IoError {
38-
#[cfg(unix)] use ERROR = libc::EAGAIN;
39-
#[cfg(windows)] use ERROR = libc::ERROR_OPERATION_ABORTED;
38+
#[cfg(unix)] use libc::EAGAIN as ERROR;
39+
#[cfg(windows)] use libc::ERROR_OPERATION_ABORTED as ERROR;
4040
IoError {
4141
code: ERROR as uint,
4242
extra: n,
@@ -102,10 +102,10 @@ pub fn connect_timeout(fd: net::sock_t,
102102
len: libc::socklen_t,
103103
timeout_ms: u64) -> IoResult<()> {
104104
use std::os;
105-
#[cfg(unix)] use INPROGRESS = libc::EINPROGRESS;
106-
#[cfg(windows)] use INPROGRESS = libc::WSAEINPROGRESS;
107-
#[cfg(unix)] use WOULDBLOCK = libc::EWOULDBLOCK;
108-
#[cfg(windows)] use WOULDBLOCK = libc::WSAEWOULDBLOCK;
105+
#[cfg(unix)] use libc::EINPROGRESS as INPROGRESS;
106+
#[cfg(windows)] use libc::WSAEINPROGRESS as INPROGRESS;
107+
#[cfg(unix)] use libc::EWOULDBLOCK as WOULDBLOCK;
108+
#[cfg(windows)] use libc::WSAEWOULDBLOCK as WOULDBLOCK;
109109

110110
// Make sure the call to connect() doesn't block
111111
try!(set_nonblocking(fd, true));

src/librustc/driver/driver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use metadata::common::LinkMeta;
2121
use metadata::creader;
2222
use middle::borrowck::{FnPartsWithCFG};
2323
use middle::borrowck;
24-
use borrowck_dot = middle::borrowck::graphviz;
24+
use middle::borrowck::graphviz as borrowck_dot;
2525
use middle::cfg;
2626
use middle::cfg::graphviz::LabelledCFG;
2727
use middle::{trans, freevars, stability, kind, ty, typeck, reachable};
@@ -35,7 +35,7 @@ use util::common::time;
3535
use util::ppaux;
3636
use util::nodemap::{NodeSet};
3737

38-
use dot = graphviz;
38+
use graphviz as dot;
3939

4040
use serialize::{json, Encodable};
4141

src/librustc/metadata/filesearch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::io::fs;
1616
use std::dynamic_lib::DynamicLibrary;
1717
use std::collections::HashSet;
1818

19-
use myfs = util::fs;
19+
use util::fs as myfs;
2020

2121
pub enum FileMatch { FileMatches, FileDoesntMatch }
2222

src/librustc/middle/astencode.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
// FIXME: remove this after snapshot, and Results are handled
1313
#![allow(unused_must_use)]
1414

15-
use c = metadata::common;
16-
use cstore = metadata::cstore;
15+
use metadata::common as c;
16+
use metadata::cstore as cstore;
1717
use driver::session::Session;
1818
use metadata::decoder;
1919
use middle::def;
20-
use e = metadata::encoder;
20+
use metadata::encoder as e;
2121
use middle::freevars::{CaptureMode, freevar_entry};
2222
use middle::freevars;
2323
use middle::region;
2424
use metadata::tydecode;
25-
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter,
26-
RegionParameter};
25+
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter};
26+
use metadata::tydecode::{RegionParameter};
2727
use metadata::tyencode;
2828
use middle::subst;
2929
use middle::subst::VecPerParamSpace;

src/librustc/middle/borrowck/check_loans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
use middle::borrowck::*;
22-
use euv = middle::expr_use_visitor;
23-
use mc = middle::mem_categorization;
22+
use middle::expr_use_visitor as euv;
23+
use middle::mem_categorization as mc;
2424
use middle::ty;
2525
use syntax::ast;
2626
use syntax::codemap::Span;

src/librustc/middle/borrowck/gather_loans/gather_moves.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
* Computes moves.
1313
*/
1414

15-
use mc = middle::mem_categorization;
1615
use middle::borrowck::*;
17-
use middle::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
1816
use middle::borrowck::gather_loans::move_error::MoveSpanAndPath;
17+
use middle::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
1918
use middle::borrowck::move_data::*;
20-
use euv = middle::expr_use_visitor;
19+
use middle::expr_use_visitor as euv;
20+
use middle::mem_categorization as mc;
2121
use middle::ty;
2222
use syntax::ast;
2323
use syntax::codemap::Span;

src/librustc/middle/borrowck/gather_loans/lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515

1616
use middle::borrowck::*;
17-
use euv = middle::expr_use_visitor;
18-
use mc = middle::mem_categorization;
17+
use middle::expr_use_visitor as euv;
18+
use middle::mem_categorization as mc;
1919
use middle::ty;
2020
use util::ppaux::Repr;
2121
use syntax::ast;

src/librustc/middle/borrowck/gather_loans/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
use middle::borrowck::*;
2020
use middle::borrowck::move_data::MoveData;
21-
use euv = middle::expr_use_visitor;
22-
use mc = middle::mem_categorization;
21+
use middle::expr_use_visitor as euv;
22+
use middle::mem_categorization as mc;
2323
use middle::ty;
2424
use util::ppaux::{Repr};
2525

src/librustc/middle/borrowck/gather_loans/move_error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use mc = middle::mem_categorization;
11+
use middle::mem_categorization as mc;
1212
use middle::borrowck::BorrowckCtxt;
1313
use middle::ty;
1414

src/librustc/middle/borrowck/gather_loans/restrictions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*/
1414

1515
use middle::borrowck::*;
16-
use euv = middle::expr_use_visitor;
17-
use mc = middle::mem_categorization;
16+
use middle::expr_use_visitor as euv;
17+
use middle::mem_categorization as mc;
1818
use middle::ty;
1919
use syntax::codemap::Span;
2020
use util::ppaux::Repr;

src/librustc/middle/borrowck/graphviz.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
//! data to rendered labels.
1414
1515
/// For clarity, rename the graphviz crate locally to dot.
16-
use dot = graphviz;
16+
use graphviz as dot;
1717
pub use middle::cfg::graphviz::{Node, Edge};
18-
use cfg_dot = middle::cfg::graphviz;
18+
use middle::cfg::graphviz as cfg_dot;
1919

2020
use middle::borrowck;
2121
use middle::borrowck::{BorrowckCtxt, LoanPath};

src/librustc/middle/borrowck/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use middle::dataflow::DataFlowContext;
1717
use middle::dataflow::BitwiseOperator;
1818
use middle::dataflow::DataFlowOperator;
1919
use middle::def;
20-
use euv = middle::expr_use_visitor;
21-
use mc = middle::mem_categorization;
20+
use middle::expr_use_visitor as euv;
21+
use middle::mem_categorization as mc;
2222
use middle::ty;
2323
use util::ppaux::{note_and_explain_region, Repr, UserString};
2424

src/librustc/middle/borrowck/move_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use middle::cfg;
2424
use middle::dataflow::DataFlowContext;
2525
use middle::dataflow::BitwiseOperator;
2626
use middle::dataflow::DataFlowOperator;
27-
use euv = middle::expr_use_visitor;
28-
use mc = middle::mem_categorization;
27+
use middle::expr_use_visitor as euv;
28+
use middle::mem_categorization as mc;
2929
use middle::ty;
3030
use syntax::ast;
3131
use syntax::ast_util;

0 commit comments

Comments
 (0)