Skip to content

Commit 406b2c1

Browse files
committed
rustc_trans: fix fallout of merging ast::ViewItem into ast::Item.
1 parent f35c643 commit 406b2c1

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
@@ -1037,6 +1037,110 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
10371037
}
10381038

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

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