Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some pub use glob usage #14509

Merged
merged 2 commits into from
Jun 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ An example of re-exporting:
~~~~
# fn main() { }
mod quux {
pub use quux::foo::*;
pub use quux::foo::{bar, baz};

pub mod foo {
pub fn bar() { }
Expand All @@ -913,10 +913,10 @@ mod quux {
}
~~~~

In this example, the module `quux` re-exports all of the public names defined in `foo`.
In this example, the module `quux` re-exports two public names defined in `foo`.

Also note that the paths contained in `use` items are relative to the crate root.
So, in the previous example, the `use` refers to `quux::foo::*`, and not simply to `foo::*`.
So, in the previous example, the `use` refers to `quux::foo::{bar, baz}`, and not simply to `foo::{bar, baz}`.
This also means that top-level module declarations should be at the crate root if direct usage
of the declared modules within `use` items is desired. It is also possible to use `self` and `super`
at the beginning of a `use` item to refer to the current and direct parent modules respectively.
Expand Down
1 change: 1 addition & 0 deletions src/libregex_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
html_root_url = "http://doc.rust-lang.org/")]

#![feature(macro_registrar, managed_boxes, quote)]
#![allow(unused_imports)] // `quote_expr!` adds some `use` globs which may be unused

extern crate regex;
extern crate syntax;
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
// except according to those terms.

use abi;
use ast::{P, Ident};
use ast::{P, Ident, Generics, NodeId, Expr};
use ast;
use ast_util;
use attr;
use codemap::{Span, respan, Spanned, DUMMY_SP};
use ext::base::ExtCtxt;
use ext::quote::rt::*;
use fold::Folder;
use owned_slice::OwnedSlice;
use parse::token::special_idents;
use parse::token::InternedString;
use parse::token;

pub struct Field {
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use ast::{MetaItem, MetaWord, Item};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;

pub fn expand_deriving_bound(cx: &mut ExtCtxt,
span: Span,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_clone(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_eq(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_ord(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/cmp/totaleq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/cmp/totalord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

use std::cmp::{Ordering, Equal, Less, Greater};
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;
use parse::token;

Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_default(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token;

pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax/ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ use codemap::Span;
use owned_slice::OwnedSlice;
use parse::token::InternedString;

pub use self::ty::*;
mod ty;
use self::ty::*;

pub mod ty;

pub struct TraitDef<'a> {
/// The span for the current #[deriving(Foo)] header.
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_hash(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::{AstBuilder};
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;

pub fn expand_deriving_rand(cx: &mut ExtCtxt,
span: Span,
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ext::format;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token;

use collections::HashMap;
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/ext/deriving/zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codemap::Span;
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use ext::deriving::generic::ty::*;
use parse::token::InternedString;

pub fn expand_deriving_zero(cx: &mut ExtCtxt,
Expand Down
28 changes: 20 additions & 8 deletions src/libsyntax/ext/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ pub mod rt {
use parse;
use print::pprust;

pub use ast::*;
pub use parse::token::*;
#[cfg(not(stage0))]
use ast::{TokenTree, Generics, Expr};

// NOTE remove this after snapshot
// (stage0 quasiquoter needs this)
#[cfg(stage0)]
pub use ast::{Generics, TokenTree, TTTok};
#[cfg(stage0)]
pub use parse::token::{IDENT, SEMI, LBRACE, RBRACE, LIFETIME, COLON, AND, BINOP, EQ,
LBRACKET, RBRACKET, LPAREN, RPAREN, POUND, NOT, MOD_SEP, DOT, COMMA};

pub use parse::new_parser_from_tts;
pub use codemap::{BytePos, Span, dummy_spanned};

Expand Down Expand Up @@ -72,7 +81,7 @@ pub mod rt {

impl ToSource for ast::Ident {
fn to_source(&self) -> String {
get_ident(*self).get().to_string()
token::get_ident(*self).get().to_string()
}
}

Expand Down Expand Up @@ -685,11 +694,14 @@ fn expand_wrapper(cx: &ExtCtxt,
sp: Span,
cx_expr: @ast::Expr,
expr: @ast::Expr) -> @ast::Expr {
let uses = vec![ cx.view_use_glob(sp, ast::Inherited,
ids_ext(vec!["syntax".to_string(),
"ext".to_string(),
"quote".to_string(),
"rt".to_string()])) ];
let uses = [
&["syntax", "ast"],
&["syntax", "parse", "token"],
&["syntax", "ext", "quote", "rt"],
].iter().map(|path| {
let path = path.iter().map(|s| s.to_string()).collect();
cx.view_use_glob(sp, ast::Inherited, ids_ext(path))
}).collect();

let stmt_let_ext_cx = cx.stmt_let(sp, false, id_ext("ext_cx"), cx_expr);

Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub mod util {
pub mod syntax {
pub use ext;
pub use parse;
pub use ast;
}

pub mod owned_slice;
Expand Down