Skip to content

Commit f952e1b

Browse files
committed
rustc_trans: fix fallout of merging ast::ViewItem into ast::Item.
1 parent dc41625 commit f952e1b

File tree

2 files changed

+104
-114
lines changed

2 files changed

+104
-114
lines changed

src/librustc_trans/save/mod.rs

Lines changed: 104 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,110 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
10321032
}
10331033

10341034
match item.node {
1035+
ast::ItemUse(ref use_item) => {
1036+
match use_item.node {
1037+
ast::ViewPathSimple(ident, ref path) => {
1038+
let sub_span = self.span.span_for_last_ident(path.span);
1039+
let mod_id = match self.lookup_type_ref(item.id) {
1040+
Some(def_id) => {
1041+
match self.lookup_def_kind(item.id, path.span) {
1042+
Some(kind) => self.fmt.ref_str(kind,
1043+
path.span,
1044+
sub_span,
1045+
def_id,
1046+
self.cur_scope),
1047+
None => {},
1048+
}
1049+
Some(def_id)
1050+
},
1051+
None => None,
1052+
};
1053+
1054+
// 'use' always introduces an alias, if there is not an explicit
1055+
// one, there is an implicit one.
1056+
let sub_span =
1057+
match self.span.sub_span_after_keyword(use_item.span, keywords::As) {
1058+
Some(sub_span) => Some(sub_span),
1059+
None => sub_span,
1060+
};
1061+
1062+
self.fmt.use_alias_str(path.span,
1063+
sub_span,
1064+
item.id,
1065+
mod_id,
1066+
get_ident(ident).get(),
1067+
self.cur_scope);
1068+
self.write_sub_paths_truncated(path);
1069+
}
1070+
ast::ViewPathGlob(ref path) => {
1071+
// Make a comma-separated list of names of imported modules.
1072+
let mut name_string = String::new();
1073+
let glob_map = &self.analysis.glob_map;
1074+
let glob_map = glob_map.as_ref().unwrap();
1075+
if glob_map.contains_key(&item.id) {
1076+
for n in glob_map[item.id].iter() {
1077+
if name_string.len() > 0 {
1078+
name_string.push_str(", ");
1079+
}
1080+
name_string.push_str(n.as_str());
1081+
}
1082+
}
1083+
1084+
let sub_span = self.span.sub_span_of_token(path.span,
1085+
token::BinOp(token::Star));
1086+
self.fmt.use_glob_str(path.span,
1087+
sub_span,
1088+
item.id,
1089+
name_string.as_slice(),
1090+
self.cur_scope);
1091+
self.write_sub_paths(path);
1092+
}
1093+
ast::ViewPathList(ref path, ref list) => {
1094+
for plid in list.iter() {
1095+
match plid.node {
1096+
ast::PathListIdent { id, .. } => {
1097+
match self.lookup_type_ref(id) {
1098+
Some(def_id) =>
1099+
match self.lookup_def_kind(id, plid.span) {
1100+
Some(kind) => {
1101+
self.fmt.ref_str(
1102+
kind, plid.span,
1103+
Some(plid.span),
1104+
def_id, self.cur_scope);
1105+
}
1106+
None => ()
1107+
},
1108+
None => ()
1109+
}
1110+
},
1111+
ast::PathListMod { .. } => ()
1112+
}
1113+
}
1114+
1115+
self.write_sub_paths(path);
1116+
}
1117+
}
1118+
}
1119+
ast::ItemExternCrate(ref s) => {
1120+
let name = get_ident(item.ident);
1121+
let name = name.get();
1122+
let s = match *s {
1123+
Some((ref s, _)) => s.get().to_string(),
1124+
None => name.to_string(),
1125+
};
1126+
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Crate);
1127+
let cnum = match self.sess.cstore.find_extern_mod_stmt_cnum(item.id) {
1128+
Some(cnum) => cnum,
1129+
None => 0,
1130+
};
1131+
self.fmt.extern_crate_str(item.span,
1132+
sub_span,
1133+
item.id,
1134+
cnum,
1135+
name,
1136+
&s[],
1137+
self.cur_scope);
1138+
}
10351139
ast::ItemFn(ref decl, _, _, ref ty_params, ref body) =>
10361140
self.process_fn(item, &**decl, ty_params, &**body),
10371141
ast::ItemStatic(ref typ, mt, ref expr) =>
@@ -1155,119 +1259,6 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
11551259
}
11561260
}
11571261

1158-
fn visit_view_item(&mut self, i: &ast::ViewItem) {
1159-
if generated_code(i.span) {
1160-
return
1161-
}
1162-
1163-
match i.node {
1164-
ast::ViewItemUse(ref item) => {
1165-
match item.node {
1166-
ast::ViewPathSimple(ident, ref path, id) => {
1167-
let sub_span = self.span.span_for_last_ident(path.span);
1168-
let mod_id = match self.lookup_type_ref(id) {
1169-
Some(def_id) => {
1170-
match self.lookup_def_kind(id, path.span) {
1171-
Some(kind) => self.fmt.ref_str(kind,
1172-
path.span,
1173-
sub_span,
1174-
def_id,
1175-
self.cur_scope),
1176-
None => {},
1177-
}
1178-
Some(def_id)
1179-
},
1180-
None => None,
1181-
};
1182-
1183-
// 'use' always introduces an alias, if there is not an explicit
1184-
// one, there is an implicit one.
1185-
let sub_span =
1186-
match self.span.sub_span_after_keyword(item.span, keywords::As) {
1187-
Some(sub_span) => Some(sub_span),
1188-
None => sub_span,
1189-
};
1190-
1191-
self.fmt.use_alias_str(path.span,
1192-
sub_span,
1193-
id,
1194-
mod_id,
1195-
get_ident(ident).get(),
1196-
self.cur_scope);
1197-
self.write_sub_paths_truncated(path);
1198-
}
1199-
ast::ViewPathGlob(ref path, id) => {
1200-
// Make a comma-separated list of names of imported modules.
1201-
let mut name_string = String::new();
1202-
let glob_map = &self.analysis.glob_map;
1203-
let glob_map = glob_map.as_ref().unwrap();
1204-
if glob_map.contains_key(&id) {
1205-
for n in glob_map[id].iter() {
1206-
if name_string.len() > 0 {
1207-
name_string.push_str(", ");
1208-
}
1209-
name_string.push_str(n.as_str());
1210-
}
1211-
}
1212-
1213-
let sub_span = self.span.sub_span_of_token(path.span,
1214-
token::BinOp(token::Star));
1215-
self.fmt.use_glob_str(path.span,
1216-
sub_span,
1217-
id,
1218-
name_string.as_slice(),
1219-
self.cur_scope);
1220-
self.write_sub_paths(path);
1221-
}
1222-
ast::ViewPathList(ref path, ref list, _) => {
1223-
for plid in list.iter() {
1224-
match plid.node {
1225-
ast::PathListIdent { id, .. } => {
1226-
match self.lookup_type_ref(id) {
1227-
Some(def_id) =>
1228-
match self.lookup_def_kind(id, plid.span) {
1229-
Some(kind) => {
1230-
self.fmt.ref_str(
1231-
kind, plid.span,
1232-
Some(plid.span),
1233-
def_id, self.cur_scope);
1234-
}
1235-
None => ()
1236-
},
1237-
None => ()
1238-
}
1239-
},
1240-
ast::PathListMod { .. } => ()
1241-
}
1242-
}
1243-
1244-
self.write_sub_paths(path);
1245-
}
1246-
}
1247-
},
1248-
ast::ViewItemExternCrate(ident, ref s, id) => {
1249-
let name = get_ident(ident);
1250-
let name = name.get();
1251-
let s = match *s {
1252-
Some((ref s, _)) => s.get().to_string(),
1253-
None => name.to_string(),
1254-
};
1255-
let sub_span = self.span.sub_span_after_keyword(i.span, keywords::Crate);
1256-
let cnum = match self.sess.cstore.find_extern_mod_stmt_cnum(id) {
1257-
Some(cnum) => cnum,
1258-
None => 0,
1259-
};
1260-
self.fmt.extern_crate_str(i.span,
1261-
sub_span,
1262-
id,
1263-
cnum,
1264-
name,
1265-
&s[],
1266-
self.cur_scope);
1267-
},
1268-
}
1269-
}
1270-
12711262
fn visit_ty(&mut self, t: &ast::Ty) {
12721263
if generated_code(t.span) {
12731264
return

src/librustc_trans/trans/monomorphize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
274274
ast_map::NodeArg(..) |
275275
ast_map::NodeBlock(..) |
276276
ast_map::NodePat(..) |
277-
ast_map::NodeViewItem(..) |
278277
ast_map::NodeLocal(..) => {
279278
ccx.sess().bug(&format!("can't monomorphize a {:?}",
280279
map_node)[])

0 commit comments

Comments
 (0)