Skip to content

Commit 8bec116

Browse files
committed
---
yaml --- r: 172876 b: refs/heads/try c: 9871349 h: refs/heads/master v: v3
1 parent 8396b55 commit 8bec116

File tree

11 files changed

+100
-133
lines changed

11 files changed

+100
-133
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 170c4399e614fe599c3d41306b3429ca8b3b68c6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: 84df136d407db45ecd143569cf0cf84a4b8cb596
5+
refs/heads/try: 98713495562428a788736dea0544bfe402158143
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc/lint/builtin.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,17 +1203,17 @@ impl LintPass for UnusedImportBraces {
12031203
lint_array!(UNUSED_IMPORT_BRACES)
12041204
}
12051205

1206-
fn check_view_item(&mut self, cx: &Context, view_item: &ast::ViewItem) {
1207-
match view_item.node {
1208-
ast::ViewItemUse(ref view_path) => {
1206+
fn check_item(&mut self, cx: &Context, item: &ast::Item) {
1207+
match item.node {
1208+
ast::ItemUse(ref view_path) => {
12091209
match view_path.node {
1210-
ast::ViewPathList(_, ref items, _) => {
1210+
ast::ViewPathList(_, ref items) => {
12111211
if items.len() == 1 {
12121212
match items[0].node {
12131213
ast::PathListIdent {ref name, ..} => {
12141214
let m = format!("braces around {} is unnecessary",
12151215
token::get_ident(*name).get());
1216-
cx.span_lint(UNUSED_IMPORT_BRACES, view_item.span,
1216+
cx.span_lint(UNUSED_IMPORT_BRACES, item.span,
12171217
&m[]);
12181218
},
12191219
_ => ()
@@ -1710,22 +1710,6 @@ impl LintPass for Stability {
17101710
}
17111711
}
17121712

1713-
fn check_view_item(&mut self, cx: &Context, item: &ast::ViewItem) {
1714-
// compiler-generated `extern crate` statements have a dummy span.
1715-
if item.span == DUMMY_SP { return }
1716-
1717-
let id = match item.node {
1718-
ast::ViewItemExternCrate(_, _, id) => id,
1719-
ast::ViewItemUse(..) => return,
1720-
};
1721-
let cnum = match cx.tcx.sess.cstore.find_extern_mod_stmt_cnum(id) {
1722-
Some(cnum) => cnum,
1723-
None => return,
1724-
};
1725-
let id = ast::DefId { krate: cnum, node: ast::CRATE_NODE_ID };
1726-
self.lint(cx, id, item.span);
1727-
}
1728-
17291713
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
17301714
if self.is_internal(cx, e.span) { return; }
17311715

@@ -1777,6 +1761,17 @@ impl LintPass for Stability {
17771761
if self.is_internal(cx, item.span) { return }
17781762

17791763
match item.node {
1764+
ast::ItemExternCrate(_) => {
1765+
// compiler-generated `extern crate` items have a dummy span.
1766+
if item.span == DUMMY_SP { return }
1767+
1768+
let cnum = match cx.tcx.sess.cstore.find_extern_mod_stmt_cnum(item.id) {
1769+
Some(cnum) => cnum,
1770+
None => return,
1771+
};
1772+
let id = ast::DefId { krate: cnum, node: ast::CRATE_NODE_ID };
1773+
self.lint(cx, id, item.span);
1774+
}
17801775
ast::ItemTrait(_, _, ref supertraits, _) => {
17811776
for t in supertraits.iter() {
17821777
if let ast::TraitTyParamBound(ref t, _) = *t {

branches/try/src/librustc/lint/context.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
603603
})
604604
}
605605

606-
fn visit_view_item(&mut self, i: &ast::ViewItem) {
607-
self.with_lint_attrs(&i.attrs[], |cx| {
608-
run_lints!(cx, check_view_item, i);
609-
cx.visit_ids(|v| v.visit_view_item(i));
610-
visit::walk_view_item(cx, i);
611-
})
612-
}
613-
614606
fn visit_pat(&mut self, p: &ast::Pat) {
615607
run_lints!(self, check_pat, p);
616608
visit::walk_pat(self, p);

branches/try/src/librustc/lint/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ pub trait LintPass {
128128
fn check_crate(&mut self, _: &Context, _: &ast::Crate) { }
129129
fn check_ident(&mut self, _: &Context, _: Span, _: ast::Ident) { }
130130
fn check_mod(&mut self, _: &Context, _: &ast::Mod, _: Span, _: ast::NodeId) { }
131-
fn check_view_item(&mut self, _: &Context, _: &ast::ViewItem) { }
132131
fn check_foreign_item(&mut self, _: &Context, _: &ast::ForeignItem) { }
133132
fn check_item(&mut self, _: &Context, _: &ast::Item) { }
134133
fn check_local(&mut self, _: &Context, _: &ast::Local) { }

branches/try/src/librustc/metadata/creader.rs

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ pub struct CrateReader<'a> {
4040
}
4141

4242
impl<'a, 'v> visit::Visitor<'v> for CrateReader<'a> {
43-
fn visit_view_item(&mut self, a: &ast::ViewItem) {
44-
self.process_view_item(a);
45-
visit::walk_view_item(self, a);
46-
}
4743
fn visit_item(&mut self, a: &ast::Item) {
4844
self.process_item(a);
4945
visit::walk_item(self, a);
@@ -64,9 +60,8 @@ fn dump_crates(cstore: &CStore) {
6460
})
6561
}
6662

67-
fn should_link(i: &ast::ViewItem) -> bool {
63+
fn should_link(i: &ast::Item) -> bool {
6864
!attr::contains_name(&i.attrs[], "no_link")
69-
7065
}
7166

7267
struct CrateInfo {
@@ -181,29 +176,10 @@ impl<'a> CrateReader<'a> {
181176
}
182177
}
183178

184-
fn process_view_item(&mut self, i: &ast::ViewItem) {
185-
if !should_link(i) {
186-
return;
187-
}
188-
189-
match self.extract_crate_info(i) {
190-
Some(info) => {
191-
let (cnum, _, _) = self.resolve_crate(&None,
192-
&info.ident[],
193-
&info.name[],
194-
None,
195-
i.span,
196-
PathKind::Crate);
197-
self.sess.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
198-
}
199-
None => ()
200-
}
201-
}
202-
203-
fn extract_crate_info(&self, i: &ast::ViewItem) -> Option<CrateInfo> {
179+
fn extract_crate_info(&self, i: &ast::Item) -> Option<CrateInfo> {
204180
match i.node {
205-
ast::ViewItemExternCrate(ident, ref path_opt, id) => {
206-
let ident = token::get_ident(ident);
181+
ast::ItemExternCrate(ref path_opt) => {
182+
let ident = token::get_ident(i.ident);
207183
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
208184
ident, path_opt);
209185
let name = match *path_opt {
@@ -218,16 +194,34 @@ impl<'a> CrateReader<'a> {
218194
Some(CrateInfo {
219195
ident: ident.get().to_string(),
220196
name: name,
221-
id: id,
197+
id: i.id,
222198
should_link: should_link(i),
223199
})
224200
}
225201
_ => None
226202
}
227203
}
228204

229-
fn process_item(&self, i: &ast::Item) {
205+
fn process_item(&mut self, i: &ast::Item) {
230206
match i.node {
207+
ast::ItemExternCrate(_) => {
208+
if !should_link(i) {
209+
return;
210+
}
211+
212+
match self.extract_crate_info(i) {
213+
Some(info) => {
214+
let (cnum, _, _) = self.resolve_crate(&None,
215+
&info.ident[],
216+
&info.name[],
217+
None,
218+
i.span,
219+
PathKind::Crate);
220+
self.sess.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
221+
}
222+
None => ()
223+
}
224+
}
231225
ast::ItemForeignMod(ref fm) => {
232226
if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic {
233227
return;
@@ -521,7 +515,7 @@ impl<'a> CrateReader<'a> {
521515

522516
#[derive(Copy)]
523517
pub enum CrateOrString<'a> {
524-
Krate(&'a ast::ViewItem),
518+
Krate(&'a ast::Item),
525519
Str(&'a str)
526520
}
527521

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
14561456
rbml_w.end_tag();
14571457
}
14581458
}
1459-
ast::ItemMac(..) => {
1460-
// macros are encoded separately
1459+
ast::ItemExternCrate(_) | ast::ItemUse(_) |ast::ItemMac(..) => {
1460+
// these are encoded separately
14611461
}
14621462
}
14631463
}

branches/try/src/librustc/middle/astencode.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ impl Folder for NestedItemsDropper {
332332
}
333333
}).collect();
334334
let blk_sans_items = P(ast::Block {
335-
view_items: Vec::new(), // I don't know if we need the view_items
336-
// here, but it doesn't break tests!
337335
stmts: stmts_sans_items,
338336
expr: expr,
339337
id: id,

branches/try/src/librustc/middle/privacy.rs

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,38 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
861861

862862
impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
863863
fn visit_item(&mut self, item: &ast::Item) {
864+
match item.node {
865+
ast::ItemUse(ref vpath) => {
866+
match vpath.node {
867+
ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {}
868+
ast::ViewPathList(ref prefix, ref list) => {
869+
for pid in list.iter() {
870+
match pid.node {
871+
ast::PathListIdent { id, name } => {
872+
debug!("privacy - ident item {}", id);
873+
let seg = ast::PathSegment {
874+
identifier: name,
875+
parameters: ast::PathParameters::none(),
876+
};
877+
let segs = vec![seg];
878+
let path = ast::Path {
879+
global: false,
880+
span: pid.span,
881+
segments: segs,
882+
};
883+
self.check_path(pid.span, id, &path);
884+
}
885+
ast::PathListMod { id } => {
886+
debug!("privacy - mod item {}", id);
887+
self.check_path(pid.span, id, prefix);
888+
}
889+
}
890+
}
891+
}
892+
}
893+
}
894+
_ => {}
895+
}
864896
let orig_curitem = replace(&mut self.curitem, item.id);
865897
visit::walk_item(self, item);
866898
self.curitem = orig_curitem;
@@ -957,42 +989,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
957989
visit::walk_expr(self, expr);
958990
}
959991

960-
fn visit_view_item(&mut self, a: &ast::ViewItem) {
961-
match a.node {
962-
ast::ViewItemExternCrate(..) => {}
963-
ast::ViewItemUse(ref vpath) => {
964-
match vpath.node {
965-
ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {}
966-
ast::ViewPathList(ref prefix, ref list, _) => {
967-
for pid in list.iter() {
968-
match pid.node {
969-
ast::PathListIdent { id, name } => {
970-
debug!("privacy - ident item {}", id);
971-
let seg = ast::PathSegment {
972-
identifier: name,
973-
parameters: ast::PathParameters::none(),
974-
};
975-
let segs = vec![seg];
976-
let path = ast::Path {
977-
global: false,
978-
span: pid.span,
979-
segments: segs,
980-
};
981-
self.check_path(pid.span, id, &path);
982-
}
983-
ast::PathListMod { id } => {
984-
debug!("privacy - mod item {}", id);
985-
self.check_path(pid.span, id, prefix);
986-
}
987-
}
988-
}
989-
}
990-
}
991-
}
992-
}
993-
visit::walk_view_item(self, a);
994-
}
995-
996992
fn visit_pat(&mut self, pattern: &ast::Pat) {
997993
// Foreign functions do not have their patterns mapped in the def_map,
998994
// and there's nothing really relevant there anyway, so don't bother
@@ -1100,23 +1096,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for SanePrivacyVisitor<'a, 'tcx> {
11001096
visit::walk_fn(self, fk, fd, b, s);
11011097
self.in_fn = orig_in_fn;
11021098
}
1103-
1104-
fn visit_view_item(&mut self, i: &ast::ViewItem) {
1105-
match i.vis {
1106-
ast::Inherited => {}
1107-
ast::Public => {
1108-
if self.in_fn {
1109-
self.tcx.sess.span_err(i.span, "unnecessary `pub`, imports \
1110-
in functions are never \
1111-
reachable");
1112-
} else if let ast::ViewItemExternCrate(..) = i.node {
1113-
self.tcx.sess.span_err(i.span, "`pub` visibility \
1114-
is not allowed");
1115-
}
1116-
}
1117-
}
1118-
visit::walk_view_item(self, i);
1119-
}
11201099
}
11211100

11221101
impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
@@ -1193,7 +1172,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
11931172

11941173
ast::ItemConst(..) | ast::ItemStatic(..) | ast::ItemStruct(..) |
11951174
ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) |
1196-
ast::ItemMac(..) => {}
1175+
ast::ItemExternCrate(_) | ast::ItemUse(_) | ast::ItemMac(..) => {}
11971176
}
11981177
}
11991178

@@ -1250,6 +1229,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
12501229
}
12511230
}
12521231

1232+
ast::ItemExternCrate(_) | ast::ItemUse(_) |
12531233
ast::ItemStatic(..) | ast::ItemConst(..) |
12541234
ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) |
12551235
ast::ItemMac(..) => {}
@@ -1552,11 +1532,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
15521532

15531533

15541534
// we don't need to introspect into these at all: an
1555-
// expression/block context can't possibly contain exported
1556-
// things, and neither do view_items. (Making them no-ops stops us
1557-
// from traversing the whole AST without having to be super
1558-
// careful about our `walk_...` calls above.)
1559-
fn visit_view_item(&mut self, _: &ast::ViewItem) {}
1535+
// expression/block context can't possibly contain exported things.
1536+
// (Making them no-ops stops us from traversing the whole AST without
1537+
// having to be super careful about our `walk_...` calls above.)
15601538
fn visit_block(&mut self, _: &ast::Block) {}
15611539
fn visit_expr(&mut self, _: &ast::Expr) {}
15621540
}

branches/try/src/librustc/middle/reachable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
297297
// These are normal, nothing reachable about these
298298
// inherently and their children are already in the
299299
// worklist, as determined by the privacy pass
300+
ast::ItemExternCrate(_) | ast::ItemUse(_) |
300301
ast::ItemTy(..) | ast::ItemStatic(_, _, _) |
301302
ast::ItemMod(..) | ast::ItemForeignMod(..) |
302303
ast::ItemImpl(..) | ast::ItemTrait(..) |

branches/try/src/librustc/middle/resolve_lifetime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
9494
// Fn lifetimes get added in visit_fn below:
9595
visit::walk_item(this, item);
9696
}
97+
ast::ItemExternCrate(_) |
98+
ast::ItemUse(_) |
9799
ast::ItemMod(..) |
98100
ast::ItemMac(..) |
99101
ast::ItemForeignMod(..) |

0 commit comments

Comments
 (0)