Skip to content

Commit 8370137

Browse files
committed
auto merge of #14509 : klutzy/rust/de-pub-use-glob, r=alexcrichton
This patchset removes `pub use` usage except for `test/`. cc #11870
2 parents 46dad76 + 976c832 commit 8370137

20 files changed

+44
-15
lines changed

src/doc/rust.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ An example of re-exporting:
904904
~~~~
905905
# fn main() { }
906906
mod quux {
907-
pub use quux::foo::*;
907+
pub use quux::foo::{bar, baz};
908908
909909
pub mod foo {
910910
pub fn bar() { }
@@ -913,10 +913,10 @@ mod quux {
913913
}
914914
~~~~
915915

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

918918
Also note that the paths contained in `use` items are relative to the crate root.
919-
So, in the previous example, the `use` refers to `quux::foo::*`, and not simply to `foo::*`.
919+
So, in the previous example, the `use` refers to `quux::foo::{bar, baz}`, and not simply to `foo::{bar, baz}`.
920920
This also means that top-level module declarations should be at the crate root if direct usage
921921
of the declared modules within `use` items is desired. It is also possible to use `self` and `super`
922922
at the beginning of a `use` item to refer to the current and direct parent modules respectively.

src/libregex_macros/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
html_root_url = "http://doc.rust-lang.org/")]
2121

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

2425
extern crate regex;
2526
extern crate syntax;

src/libsyntax/ext/build.rs

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

1111
use abi;
12-
use ast::{P, Ident};
12+
use ast::{P, Ident, Generics, NodeId, Expr};
1313
use ast;
1414
use ast_util;
1515
use attr;
1616
use codemap::{Span, respan, Spanned, DUMMY_SP};
1717
use ext::base::ExtCtxt;
18-
use ext::quote::rt::*;
1918
use fold::Folder;
2019
use owned_slice::OwnedSlice;
2120
use parse::token::special_idents;
21+
use parse::token::InternedString;
2222
use parse::token;
2323

2424
pub struct Field {

src/libsyntax/ext/deriving/bounds.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use ast::{MetaItem, MetaWord, Item};
1212
use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::deriving::generic::*;
15+
use ext::deriving::generic::ty::*;
1516

1617
pub fn expand_deriving_bound(cx: &mut ExtCtxt,
1718
span: Span,

src/libsyntax/ext/deriving/clone.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_clone(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/cmp/eq.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_eq(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/cmp/ord.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
pub fn expand_deriving_ord(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/cmp/totaleq.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_totaleq(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/cmp/totalord.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
use std::cmp::{Ordering, Equal, Less, Greater};

src/libsyntax/ext/deriving/decodable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use codemap::Span;
1919
use ext::base::ExtCtxt;
2020
use ext::build::AstBuilder;
2121
use ext::deriving::generic::*;
22+
use ext::deriving::generic::ty::*;
2223
use parse::token::InternedString;
2324
use parse::token;
2425

src/libsyntax/ext/deriving/default.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_default(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/encodable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ use codemap::Span;
8888
use ext::base::ExtCtxt;
8989
use ext::build::AstBuilder;
9090
use ext::deriving::generic::*;
91+
use ext::deriving::generic::ty::*;
9192
use parse::token;
9293

9394
pub fn expand_deriving_encodable(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/generic/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ use codemap::Span;
191191
use owned_slice::OwnedSlice;
192192
use parse::token::InternedString;
193193

194-
pub use self::ty::*;
195-
mod ty;
194+
use self::ty::*;
195+
196+
pub mod ty;
196197

197198
pub struct TraitDef<'a> {
198199
/// The span for the current #[deriving(Foo)] header.

src/libsyntax/ext/deriving/hash.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
pub fn expand_deriving_hash(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/primitive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718
use parse::token::InternedString;
1819

1920
pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,

src/libsyntax/ext/deriving/rand.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use codemap::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::build::{AstBuilder};
1616
use ext::deriving::generic::*;
17+
use ext::deriving::generic::ty::*;
1718

1819
pub fn expand_deriving_rand(cx: &mut ExtCtxt,
1920
span: Span,

src/libsyntax/ext/deriving/show.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use ext::format;
1515
use ext::base::ExtCtxt;
1616
use ext::build::AstBuilder;
1717
use ext::deriving::generic::*;
18+
use ext::deriving::generic::ty::*;
1819
use parse::token;
1920

2021
use collections::HashMap;

src/libsyntax/ext/deriving/zero.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use codemap::Span;
1313
use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
16+
use ext::deriving::generic::ty::*;
1617
use parse::token::InternedString;
1718

1819
pub fn expand_deriving_zero(cx: &mut ExtCtxt,

src/libsyntax/ext/quote.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ pub mod rt {
3636
use parse;
3737
use print::pprust;
3838

39-
pub use ast::*;
40-
pub use parse::token::*;
39+
#[cfg(not(stage0))]
40+
use ast::{TokenTree, Generics, Expr};
41+
42+
// NOTE remove this after snapshot
43+
// (stage0 quasiquoter needs this)
44+
#[cfg(stage0)]
45+
pub use ast::{Generics, TokenTree, TTTok};
46+
#[cfg(stage0)]
47+
pub use parse::token::{IDENT, SEMI, LBRACE, RBRACE, LIFETIME, COLON, AND, BINOP, EQ,
48+
LBRACKET, RBRACKET, LPAREN, RPAREN, POUND, NOT, MOD_SEP, DOT, COMMA};
49+
4150
pub use parse::new_parser_from_tts;
4251
pub use codemap::{BytePos, Span, dummy_spanned};
4352

@@ -72,7 +81,7 @@ pub mod rt {
7281

7382
impl ToSource for ast::Ident {
7483
fn to_source(&self) -> String {
75-
get_ident(*self).get().to_string()
84+
token::get_ident(*self).get().to_string()
7685
}
7786
}
7887

@@ -685,11 +694,14 @@ fn expand_wrapper(cx: &ExtCtxt,
685694
sp: Span,
686695
cx_expr: @ast::Expr,
687696
expr: @ast::Expr) -> @ast::Expr {
688-
let uses = vec![ cx.view_use_glob(sp, ast::Inherited,
689-
ids_ext(vec!["syntax".to_string(),
690-
"ext".to_string(),
691-
"quote".to_string(),
692-
"rt".to_string()])) ];
697+
let uses = [
698+
&["syntax", "ast"],
699+
&["syntax", "parse", "token"],
700+
&["syntax", "ext", "quote", "rt"],
701+
].iter().map(|path| {
702+
let path = path.iter().map(|s| s.to_string()).collect();
703+
cx.view_use_glob(sp, ast::Inherited, ids_ext(path))
704+
}).collect();
693705

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

src/libsyntax/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub mod util {
4848
pub mod syntax {
4949
pub use ext;
5050
pub use parse;
51+
pub use ast;
5152
}
5253

5354
pub mod owned_slice;

0 commit comments

Comments
 (0)