Skip to content

Commit 21da750

Browse files
committed
rustc: avoid use-ing syntax::ast::*.
1 parent e09d986 commit 21da750

File tree

8 files changed

+459
-450
lines changed

8 files changed

+459
-450
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 77 additions & 76 deletions
Large diffs are not rendered by default.

src/librustc/metadata/tydecode.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::str;
2727
use std::string::String;
2828
use syntax::abi;
2929
use syntax::ast;
30-
use syntax::ast::*;
3130
use syntax::parse::token;
3231

3332
// Compact string representation for ty::t values. API ty_str &
@@ -525,10 +524,10 @@ fn parse_hex(st: &mut PState) -> uint {
525524
};
526525
}
527526

528-
fn parse_fn_style(c: char) -> FnStyle {
527+
fn parse_fn_style(c: char) -> ast::FnStyle {
529528
match c {
530-
'u' => UnsafeFn,
531-
'n' => NormalFn,
529+
'u' => ast::UnsafeFn,
530+
'n' => ast::NormalFn,
532531
_ => panic!("parse_fn_style: bad fn_style {}", c)
533532
}
534533
}

src/librustc/metadata/tyencode.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use util::nodemap::FnvHashMap;
2323

2424
use syntax::abi::Abi;
2525
use syntax::ast;
26-
use syntax::ast::*;
2726
use syntax::diagnostic::SpanHandler;
2827
use syntax::parse::token;
2928

@@ -34,7 +33,7 @@ macro_rules! mywrite( ($($arg:tt)*) => ({ write!($($arg)*); }) )
3433
pub struct ctxt<'a, 'tcx: 'a> {
3534
pub diag: &'a SpanHandler,
3635
// Def -> str Callback:
37-
pub ds: fn(DefId) -> String,
36+
pub ds: fn(ast::DefId) -> String,
3837
// The type context.
3938
pub tcx: &'a ty::ctxt<'tcx>,
4039
pub abbrevs: &'a abbrev_map
@@ -75,8 +74,8 @@ pub fn enc_ty(w: &mut SeekableMemWriter, cx: &ctxt, t: ty::t) {
7574

7675
fn enc_mutability(w: &mut SeekableMemWriter, mt: ast::Mutability) {
7776
match mt {
78-
MutImmutable => (),
79-
MutMutable => mywrite!(w, "m"),
77+
ast::MutImmutable => (),
78+
ast::MutMutable => mywrite!(w, "m"),
8079
}
8180
}
8281

@@ -203,26 +202,26 @@ fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) {
203202
ty::ty_char => mywrite!(w, "c"),
204203
ty::ty_int(t) => {
205204
match t {
206-
TyI => mywrite!(w, "i"),
207-
TyI8 => mywrite!(w, "MB"),
208-
TyI16 => mywrite!(w, "MW"),
209-
TyI32 => mywrite!(w, "ML"),
210-
TyI64 => mywrite!(w, "MD")
205+
ast::TyI => mywrite!(w, "i"),
206+
ast::TyI8 => mywrite!(w, "MB"),
207+
ast::TyI16 => mywrite!(w, "MW"),
208+
ast::TyI32 => mywrite!(w, "ML"),
209+
ast::TyI64 => mywrite!(w, "MD")
211210
}
212211
}
213212
ty::ty_uint(t) => {
214213
match t {
215-
TyU => mywrite!(w, "u"),
216-
TyU8 => mywrite!(w, "Mb"),
217-
TyU16 => mywrite!(w, "Mw"),
218-
TyU32 => mywrite!(w, "Ml"),
219-
TyU64 => mywrite!(w, "Md")
214+
ast::TyU => mywrite!(w, "u"),
215+
ast::TyU8 => mywrite!(w, "Mb"),
216+
ast::TyU16 => mywrite!(w, "Mw"),
217+
ast::TyU32 => mywrite!(w, "Ml"),
218+
ast::TyU64 => mywrite!(w, "Md")
220219
}
221220
}
222221
ty::ty_float(t) => {
223222
match t {
224-
TyF32 => mywrite!(w, "Mf"),
225-
TyF64 => mywrite!(w, "MF"),
223+
ast::TyF32 => mywrite!(w, "Mf"),
224+
ast::TyF64 => mywrite!(w, "MF"),
226225
}
227226
}
228227
ty::ty_enum(def, ref substs) => {
@@ -295,10 +294,10 @@ fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) {
295294
}
296295
}
297296

298-
fn enc_fn_style(w: &mut SeekableMemWriter, p: FnStyle) {
297+
fn enc_fn_style(w: &mut SeekableMemWriter, p: ast::FnStyle) {
299298
match p {
300-
NormalFn => mywrite!(w, "n"),
301-
UnsafeFn => mywrite!(w, "u"),
299+
ast::NormalFn => mywrite!(w, "n"),
300+
ast::UnsafeFn => mywrite!(w, "u"),
302301
}
303302
}
304303

@@ -308,10 +307,10 @@ fn enc_abi(w: &mut SeekableMemWriter, abi: Abi) {
308307
mywrite!(w, "]")
309308
}
310309

311-
fn enc_onceness(w: &mut SeekableMemWriter, o: Onceness) {
310+
fn enc_onceness(w: &mut SeekableMemWriter, o: ast::Onceness) {
312311
match o {
313-
Once => mywrite!(w, "o"),
314-
Many => mywrite!(w, "m")
312+
ast::Once => mywrite!(w, "o"),
313+
ast::Many => mywrite!(w, "m")
315314
}
316315
}
317316

src/librustc/middle/check_const.rs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use middle::ty;
1414
use middle::typeck;
1515
use util::ppaux;
1616

17-
use syntax::ast::*;
17+
use syntax::ast;
1818
use syntax::ast_util;
1919
use syntax::visit::Visitor;
2020
use syntax::visit;
@@ -40,13 +40,13 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
4040
}
4141

4242
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
43-
fn visit_item(&mut self, i: &Item) {
43+
fn visit_item(&mut self, i: &ast::Item) {
4444
check_item(self, i);
4545
}
46-
fn visit_pat(&mut self, p: &Pat) {
46+
fn visit_pat(&mut self, p: &ast::Pat) {
4747
check_pat(self, p);
4848
}
49-
fn visit_expr(&mut self, ex: &Expr) {
49+
fn visit_expr(&mut self, ex: &ast::Expr) {
5050
if check_expr(self, ex) {
5151
visit::walk_expr(self, ex);
5252
}
@@ -59,13 +59,13 @@ pub fn check_crate(tcx: &ty::ctxt) {
5959
tcx.sess.abort_if_errors();
6060
}
6161

62-
fn check_item(v: &mut CheckCrateVisitor, it: &Item) {
62+
fn check_item(v: &mut CheckCrateVisitor, it: &ast::Item) {
6363
match it.node {
64-
ItemStatic(_, _, ref ex) |
65-
ItemConst(_, ref ex) => {
64+
ast::ItemStatic(_, _, ref ex) |
65+
ast::ItemConst(_, ref ex) => {
6666
v.inside_const(|v| v.visit_expr(&**ex));
6767
}
68-
ItemEnum(ref enum_definition, _) => {
68+
ast::ItemEnum(ref enum_definition, _) => {
6969
for var in (*enum_definition).variants.iter() {
7070
for ex in var.node.disr_expr.iter() {
7171
v.inside_const(|v| v.visit_expr(&**ex));
@@ -76,12 +76,12 @@ fn check_item(v: &mut CheckCrateVisitor, it: &Item) {
7676
}
7777
}
7878

79-
fn check_pat(v: &mut CheckCrateVisitor, p: &Pat) {
80-
fn is_str(e: &Expr) -> bool {
79+
fn check_pat(v: &mut CheckCrateVisitor, p: &ast::Pat) {
80+
fn is_str(e: &ast::Expr) -> bool {
8181
match e.node {
82-
ExprBox(_, ref expr) => {
82+
ast::ExprBox(_, ref expr) => {
8383
match expr.node {
84-
ExprLit(ref lit) => ast_util::lit_is_str(&**lit),
84+
ast::ExprLit(ref lit) => ast_util::lit_is_str(&**lit),
8585
_ => false,
8686
}
8787
}
@@ -90,36 +90,36 @@ fn check_pat(v: &mut CheckCrateVisitor, p: &Pat) {
9090
}
9191
match p.node {
9292
// Let through plain ~-string literals here
93-
PatLit(ref a) => if !is_str(&**a) { v.inside_const(|v| v.visit_expr(&**a)); },
94-
PatRange(ref a, ref b) => {
93+
ast::PatLit(ref a) => if !is_str(&**a) { v.inside_const(|v| v.visit_expr(&**a)); },
94+
ast::PatRange(ref a, ref b) => {
9595
if !is_str(&**a) { v.inside_const(|v| v.visit_expr(&**a)); }
9696
if !is_str(&**b) { v.inside_const(|v| v.visit_expr(&**b)); }
9797
}
9898
_ => v.outside_const(|v| visit::walk_pat(v, p))
9999
}
100100
}
101101

102-
fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
102+
fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) -> bool {
103103
if !v.in_const { return true }
104104

105105
match e.node {
106-
ExprUnary(UnDeref, _) => {}
107-
ExprUnary(UnUniq, _) => {
106+
ast::ExprUnary(ast::UnDeref, _) => {}
107+
ast::ExprUnary(ast::UnUniq, _) => {
108108
span_err!(v.tcx.sess, e.span, E0010,
109109
"cannot do allocations in constant expressions");
110110
return false;
111111
}
112-
ExprLit(ref lit) if ast_util::lit_is_str(&**lit) => {}
113-
ExprBinary(..) | ExprUnary(..) => {
112+
ast::ExprLit(ref lit) if ast_util::lit_is_str(&**lit) => {}
113+
ast::ExprBinary(..) | ast::ExprUnary(..) => {
114114
let method_call = typeck::MethodCall::expr(e.id);
115115
if v.tcx.method_map.borrow().contains_key(&method_call) {
116116
span_err!(v.tcx.sess, e.span, E0011,
117117
"user-defined operators are not allowed in constant \
118118
expressions");
119119
}
120120
}
121-
ExprLit(_) => (),
122-
ExprCast(ref from, _) => {
121+
ast::ExprLit(_) => (),
122+
ast::ExprCast(ref from, _) => {
123123
let toty = ty::expr_ty(v.tcx, e);
124124
let fromty = ty::expr_ty(v.tcx, &**from);
125125
if !ty::type_is_numeric(toty) && !ty::type_is_unsafe_ptr(toty) {
@@ -133,7 +133,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
133133
expression");
134134
}
135135
}
136-
ExprPath(ref pth) => {
136+
ast::ExprPath(ref pth) => {
137137
// NB: In the future you might wish to relax this slightly
138138
// to handle on-demand instantiation of functions via
139139
// foo::<bar> in a const. Currently that is only done on
@@ -161,7 +161,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
161161
}
162162
}
163163
}
164-
ExprCall(ref callee, _) => {
164+
ast::ExprCall(ref callee, _) => {
165165
match v.tcx.def_map.borrow().get(&callee.id) {
166166
Some(&DefStruct(..)) |
167167
Some(&DefVariant(..)) => {} // OK.
@@ -173,25 +173,25 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
173173
}
174174
}
175175
}
176-
ExprBlock(ref block) => {
176+
ast::ExprBlock(ref block) => {
177177
// Check all statements in the block
178178
for stmt in block.stmts.iter() {
179179
let block_span_err = |span|
180180
span_err!(v.tcx.sess, span, E0016,
181181
"blocks in constants are limited to items and \
182182
tail expressions");
183183
match stmt.node {
184-
StmtDecl(ref span, _) => {
184+
ast::StmtDecl(ref span, _) => {
185185
match span.node {
186-
DeclLocal(_) => block_span_err(span.span),
186+
ast::DeclLocal(_) => block_span_err(span.span),
187187

188188
// Item statements are allowed
189-
DeclItem(_) => {}
189+
ast::DeclItem(_) => {}
190190
}
191191
}
192-
StmtExpr(ref expr, _) => block_span_err(expr.span),
193-
StmtSemi(ref semi, _) => block_span_err(semi.span),
194-
StmtMac(..) => {
192+
ast::StmtExpr(ref expr, _) => block_span_err(expr.span),
193+
ast::StmtSemi(ref semi, _) => block_span_err(semi.span),
194+
ast::StmtMac(..) => {
195195
v.tcx.sess.span_bug(e.span, "unexpanded statement \
196196
macro in const?!")
197197
}
@@ -202,20 +202,20 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool {
202202
None => {}
203203
}
204204
}
205-
ExprVec(_) |
206-
ExprAddrOf(MutImmutable, _) |
207-
ExprParen(..) |
208-
ExprField(..) |
209-
ExprTupField(..) |
210-
ExprIndex(..) |
211-
ExprTup(..) |
212-
ExprRepeat(..) |
213-
ExprStruct(..) => {}
214-
215-
ExprAddrOf(_, ref inner) => {
205+
ast::ExprVec(_) |
206+
ast::ExprAddrOf(ast::MutImmutable, _) |
207+
ast::ExprParen(..) |
208+
ast::ExprField(..) |
209+
ast::ExprTupField(..) |
210+
ast::ExprIndex(..) |
211+
ast::ExprTup(..) |
212+
ast::ExprRepeat(..) |
213+
ast::ExprStruct(..) => {}
214+
215+
ast::ExprAddrOf(_, ref inner) => {
216216
match inner.node {
217217
// Mutable slices are allowed.
218-
ExprVec(_) => {}
218+
ast::ExprVec(_) => {}
219219
_ => span_err!(v.tcx.sess, e.span, E0017,
220220
"references in constants may only refer \
221221
to immutable values")

0 commit comments

Comments
 (0)