mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 12:18:33 +00:00
In librustc*, convert many uses of ast::Ident to ast::Name, fixing much of #6993.
This commit is contained in:
parent
c1b8eb5ad4
commit
3cbc345cf7
@ -763,7 +763,7 @@ pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::Nod
|
|||||||
let arg_tys = get_struct_fields(intr.clone(), cdata, did.node)
|
let arg_tys = get_struct_fields(intr.clone(), cdata, did.node)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|field_ty| {
|
.map(|field_ty| {
|
||||||
arg_names.push(ast::Ident::new(field_ty.name));
|
arg_names.push(field_ty.name);
|
||||||
get_type(cdata, field_ty.id.node, tcx).ty
|
get_type(cdata, field_ty.id.node, tcx).ty
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -87,8 +87,8 @@ fn encode_name(rbml_w: &mut Encoder, name: ast::Name) {
|
|||||||
rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name));
|
rbml_w.wr_tagged_str(tag_paths_data_name, &token::get_name(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Ident) {
|
fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Name) {
|
||||||
rbml_w.wr_tagged_str(tag_item_impl_type_basename, &token::get_ident(name));
|
rbml_w.wr_tagged_str(tag_item_impl_type_basename, &token::get_name(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
|
pub fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
|
||||||
@ -519,12 +519,12 @@ fn encode_info_for_mod(ecx: &EncodeContext,
|
|||||||
attrs: &[ast::Attribute],
|
attrs: &[ast::Attribute],
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
path: PathElems,
|
path: PathElems,
|
||||||
name: ast::Ident,
|
name: ast::Name,
|
||||||
vis: ast::Visibility) {
|
vis: ast::Visibility) {
|
||||||
rbml_w.start_tag(tag_items_data_item);
|
rbml_w.start_tag(tag_items_data_item);
|
||||||
encode_def_id(rbml_w, local_def(id));
|
encode_def_id(rbml_w, local_def(id));
|
||||||
encode_family(rbml_w, 'm');
|
encode_family(rbml_w, 'm');
|
||||||
encode_name(rbml_w, name.name);
|
encode_name(rbml_w, name);
|
||||||
debug!("(encoding info for module) encoding info for module ID {}", id);
|
debug!("(encoding info for module) encoding info for module ID {}", id);
|
||||||
|
|
||||||
// Encode info about all the module children.
|
// Encode info about all the module children.
|
||||||
@ -666,7 +666,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
|
|||||||
|
|
||||||
fn encode_info_for_struct_ctor(ecx: &EncodeContext,
|
fn encode_info_for_struct_ctor(ecx: &EncodeContext,
|
||||||
rbml_w: &mut Encoder,
|
rbml_w: &mut Encoder,
|
||||||
name: ast::Ident,
|
name: ast::Name,
|
||||||
ctor_id: NodeId,
|
ctor_id: NodeId,
|
||||||
index: &mut Vec<entry<i64>>,
|
index: &mut Vec<entry<i64>>,
|
||||||
struct_id: NodeId) {
|
struct_id: NodeId) {
|
||||||
@ -679,7 +679,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
|
|||||||
encode_def_id(rbml_w, local_def(ctor_id));
|
encode_def_id(rbml_w, local_def(ctor_id));
|
||||||
encode_family(rbml_w, 'o');
|
encode_family(rbml_w, 'o');
|
||||||
encode_bounds_and_type_for_item(rbml_w, ecx, ctor_id);
|
encode_bounds_and_type_for_item(rbml_w, ecx, ctor_id);
|
||||||
encode_name(rbml_w, name.name);
|
encode_name(rbml_w, name);
|
||||||
ecx.tcx.map.with_path(ctor_id, |path| encode_path(rbml_w, path));
|
ecx.tcx.map.with_path(ctor_id, |path| encode_path(rbml_w, path));
|
||||||
encode_parent_item(rbml_w, local_def(struct_id));
|
encode_parent_item(rbml_w, local_def(struct_id));
|
||||||
|
|
||||||
@ -886,7 +886,7 @@ fn encode_method_argument_names(rbml_w: &mut Encoder,
|
|||||||
for arg in &decl.inputs {
|
for arg in &decl.inputs {
|
||||||
let tag = tag_method_argument_name;
|
let tag = tag_method_argument_name;
|
||||||
if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
|
if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
|
||||||
let name = token::get_ident(path1.node);
|
let name = token::get_name(path1.node.name);
|
||||||
rbml_w.wr_tagged_bytes(tag, name.as_bytes());
|
rbml_w.wr_tagged_bytes(tag, name.as_bytes());
|
||||||
} else {
|
} else {
|
||||||
rbml_w.wr_tagged_bytes(tag, &[]);
|
rbml_w.wr_tagged_bytes(tag, &[]);
|
||||||
@ -1044,7 +1044,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||||||
&item.attrs,
|
&item.attrs,
|
||||||
item.id,
|
item.id,
|
||||||
path,
|
path,
|
||||||
item.ident,
|
item.ident.name,
|
||||||
item.vis);
|
item.vis);
|
||||||
}
|
}
|
||||||
ast::ItemForeignMod(ref fm) => {
|
ast::ItemForeignMod(ref fm) => {
|
||||||
@ -1152,7 +1152,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||||||
// If this is a tuple-like struct, encode the type of the constructor.
|
// If this is a tuple-like struct, encode the type of the constructor.
|
||||||
match struct_def.ctor_id {
|
match struct_def.ctor_id {
|
||||||
Some(ctor_id) => {
|
Some(ctor_id) => {
|
||||||
encode_info_for_struct_ctor(ecx, rbml_w, item.ident,
|
encode_info_for_struct_ctor(ecx, rbml_w, item.ident.name,
|
||||||
ctor_id, index, def_id.node);
|
ctor_id, index, def_id.node);
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
@ -1187,8 +1187,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
|||||||
encode_polarity(rbml_w, polarity);
|
encode_polarity(rbml_w, polarity);
|
||||||
match ty.node {
|
match ty.node {
|
||||||
ast::TyPath(None, ref path) if path.segments.len() == 1 => {
|
ast::TyPath(None, ref path) if path.segments.len() == 1 => {
|
||||||
let ident = path.segments.last().unwrap().identifier;
|
let name = path.segments.last().unwrap().identifier.name;
|
||||||
encode_impl_type_basename(rbml_w, ident);
|
encode_impl_type_basename(rbml_w, name);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -1513,7 +1513,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
|
|||||||
&[],
|
&[],
|
||||||
ast::CRATE_NODE_ID,
|
ast::CRATE_NODE_ID,
|
||||||
[].iter().cloned().chain(LinkedPath::empty()),
|
[].iter().cloned().chain(LinkedPath::empty()),
|
||||||
syntax::parse::token::special_idents::invalid,
|
syntax::parse::token::special_idents::invalid.name,
|
||||||
ast::Public);
|
ast::Public);
|
||||||
|
|
||||||
visit::walk_crate(&mut EncodeVisitor {
|
visit::walk_crate(&mut EncodeVisitor {
|
||||||
|
@ -101,10 +101,6 @@ fn scan<R, F, G>(st: &mut PState, mut is_last: F, op: G) -> R where
|
|||||||
return op(&st.data[start_pos..end_pos]);
|
return op(&st.data[start_pos..end_pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
|
|
||||||
ast::Ident::new(parse_name(st, last))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse_name(st: &mut PState, last: char) -> ast::Name {
|
pub fn parse_name(st: &mut PState, last: char) -> ast::Name {
|
||||||
fn is_last(b: char, c: char) -> bool { return c == b; }
|
fn is_last(b: char, c: char) -> bool { return c == b; }
|
||||||
parse_name_(st, |a| is_last(last, a) )
|
parse_name_(st, |a| is_last(last, a) )
|
||||||
|
@ -133,12 +133,12 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_field_access(&mut self, lhs: &ast::Expr, name: &ast::Ident) {
|
fn handle_field_access(&mut self, lhs: &ast::Expr, name: ast::Name) {
|
||||||
match ty::expr_ty_adjusted(self.tcx, lhs).sty {
|
match ty::expr_ty_adjusted(self.tcx, lhs).sty {
|
||||||
ty::ty_struct(id, _) => {
|
ty::ty_struct(id, _) => {
|
||||||
let fields = ty::lookup_struct_fields(self.tcx, id);
|
let fields = ty::lookup_struct_fields(self.tcx, id);
|
||||||
let field_id = fields.iter()
|
let field_id = fields.iter()
|
||||||
.find(|field| field.name == name.name).unwrap().id;
|
.find(|field| field.name == name).unwrap().id;
|
||||||
self.live_symbols.insert(field_id.node);
|
self.live_symbols.insert(field_id.node);
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
@ -267,7 +267,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
|||||||
self.lookup_and_handle_method(expr.id, expr.span);
|
self.lookup_and_handle_method(expr.id, expr.span);
|
||||||
}
|
}
|
||||||
ast::ExprField(ref lhs, ref ident) => {
|
ast::ExprField(ref lhs, ref ident) => {
|
||||||
self.handle_field_access(&**lhs, &ident.node);
|
self.handle_field_access(&**lhs, ident.node.name);
|
||||||
}
|
}
|
||||||
ast::ExprTupField(ref lhs, idx) => {
|
ast::ExprTupField(ref lhs, idx) => {
|
||||||
self.handle_tup_field_access(&**lhs, idx.node);
|
self.handle_tup_field_access(&**lhs, idx.node);
|
||||||
@ -511,9 +511,9 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
|||||||
fn warn_dead_code(&mut self,
|
fn warn_dead_code(&mut self,
|
||||||
id: ast::NodeId,
|
id: ast::NodeId,
|
||||||
span: codemap::Span,
|
span: codemap::Span,
|
||||||
ident: ast::Ident,
|
name: ast::Name,
|
||||||
node_type: &str) {
|
node_type: &str) {
|
||||||
let name = ident.as_str();
|
let name = name.as_str();
|
||||||
if !name.starts_with("_") {
|
if !name.starts_with("_") {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
@ -528,14 +528,19 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
|||||||
impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
||||||
fn visit_item(&mut self, item: &ast::Item) {
|
fn visit_item(&mut self, item: &ast::Item) {
|
||||||
if self.should_warn_about_item(item) {
|
if self.should_warn_about_item(item) {
|
||||||
self.warn_dead_code(item.id, item.span, item.ident, item.node.descriptive_variant());
|
self.warn_dead_code(
|
||||||
|
item.id,
|
||||||
|
item.span,
|
||||||
|
item.ident.name,
|
||||||
|
item.node.descriptive_variant()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::ItemEnum(ref enum_def, _) => {
|
ast::ItemEnum(ref enum_def, _) => {
|
||||||
for variant in &enum_def.variants {
|
for variant in &enum_def.variants {
|
||||||
if self.should_warn_about_variant(&variant.node) {
|
if self.should_warn_about_variant(&variant.node) {
|
||||||
self.warn_dead_code(variant.node.id, variant.span,
|
self.warn_dead_code(variant.node.id, variant.span,
|
||||||
variant.node.name, "variant");
|
variant.node.name.name, "variant");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -547,7 +552,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
|||||||
|
|
||||||
fn visit_foreign_item(&mut self, fi: &ast::ForeignItem) {
|
fn visit_foreign_item(&mut self, fi: &ast::ForeignItem) {
|
||||||
if !self.symbol_is_live(fi.id, None) {
|
if !self.symbol_is_live(fi.id, None) {
|
||||||
self.warn_dead_code(fi.id, fi.span, fi.ident, fi.node.descriptive_variant());
|
self.warn_dead_code(fi.id, fi.span, fi.ident.name, fi.node.descriptive_variant());
|
||||||
}
|
}
|
||||||
visit::walk_foreign_item(self, fi);
|
visit::walk_foreign_item(self, fi);
|
||||||
}
|
}
|
||||||
@ -559,7 +564,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
|||||||
match fk {
|
match fk {
|
||||||
visit::FkMethod(name, _) => {
|
visit::FkMethod(name, _) => {
|
||||||
if !self.symbol_is_live(id, None) {
|
if !self.symbol_is_live(id, None) {
|
||||||
self.warn_dead_code(id, span, name, "method");
|
self.warn_dead_code(id, span, name.name, "method");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
@ -570,7 +575,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
|||||||
fn visit_struct_field(&mut self, field: &ast::StructField) {
|
fn visit_struct_field(&mut self, field: &ast::StructField) {
|
||||||
if self.should_warn_about_field(&field.node) {
|
if self.should_warn_about_field(&field.node) {
|
||||||
self.warn_dead_code(field.node.id, field.span,
|
self.warn_dead_code(field.node.id, field.span,
|
||||||
field.node.ident().unwrap(), "struct field");
|
field.node.ident().unwrap().name, "struct field");
|
||||||
}
|
}
|
||||||
|
|
||||||
visit::walk_struct_field(self, field);
|
visit::walk_struct_field(self, field);
|
||||||
|
@ -248,12 +248,12 @@ struct CaptureInfo {
|
|||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
struct LocalInfo {
|
struct LocalInfo {
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
ident: ast::Ident
|
name: ast::Name
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
enum VarKind {
|
enum VarKind {
|
||||||
Arg(NodeId, ast::Ident),
|
Arg(NodeId, ast::Name),
|
||||||
Local(LocalInfo),
|
Local(LocalInfo),
|
||||||
ImplicitRet,
|
ImplicitRet,
|
||||||
CleanExit
|
CleanExit
|
||||||
@ -334,8 +334,8 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
|||||||
|
|
||||||
fn variable_name(&self, var: Variable) -> String {
|
fn variable_name(&self, var: Variable) -> String {
|
||||||
match self.var_kinds[var.get()] {
|
match self.var_kinds[var.get()] {
|
||||||
Local(LocalInfo { ident: nm, .. }) | Arg(_, nm) => {
|
Local(LocalInfo { name, .. }) | Arg(_, name) => {
|
||||||
token::get_ident(nm).to_string()
|
token::get_name(name).to_string()
|
||||||
},
|
},
|
||||||
ImplicitRet => "<implicit-ret>".to_string(),
|
ImplicitRet => "<implicit-ret>".to_string(),
|
||||||
CleanExit => "<clean-exit>".to_string()
|
CleanExit => "<clean-exit>".to_string()
|
||||||
@ -385,8 +385,8 @@ fn visit_fn(ir: &mut IrMaps,
|
|||||||
&*arg.pat,
|
&*arg.pat,
|
||||||
|_bm, arg_id, _x, path1| {
|
|_bm, arg_id, _x, path1| {
|
||||||
debug!("adding argument {}", arg_id);
|
debug!("adding argument {}", arg_id);
|
||||||
let ident = path1.node;
|
let name = path1.node.name;
|
||||||
fn_maps.add_variable(Arg(arg_id, ident));
|
fn_maps.add_variable(Arg(arg_id, name));
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -418,11 +418,11 @@ fn visit_fn(ir: &mut IrMaps,
|
|||||||
fn visit_local(ir: &mut IrMaps, local: &ast::Local) {
|
fn visit_local(ir: &mut IrMaps, local: &ast::Local) {
|
||||||
pat_util::pat_bindings(&ir.tcx.def_map, &*local.pat, |_, p_id, sp, path1| {
|
pat_util::pat_bindings(&ir.tcx.def_map, &*local.pat, |_, p_id, sp, path1| {
|
||||||
debug!("adding local variable {}", p_id);
|
debug!("adding local variable {}", p_id);
|
||||||
let name = path1.node;
|
let name = path1.node.name;
|
||||||
ir.add_live_node_for_node(p_id, VarDefNode(sp));
|
ir.add_live_node_for_node(p_id, VarDefNode(sp));
|
||||||
ir.add_variable(Local(LocalInfo {
|
ir.add_variable(Local(LocalInfo {
|
||||||
id: p_id,
|
id: p_id,
|
||||||
ident: name
|
name: name
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
visit::walk_local(ir, local);
|
visit::walk_local(ir, local);
|
||||||
@ -433,11 +433,11 @@ fn visit_arm(ir: &mut IrMaps, arm: &ast::Arm) {
|
|||||||
pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
|
pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
|
||||||
debug!("adding local variable {} from match with bm {:?}",
|
debug!("adding local variable {} from match with bm {:?}",
|
||||||
p_id, bm);
|
p_id, bm);
|
||||||
let name = path1.node;
|
let name = path1.node.name;
|
||||||
ir.add_live_node_for_node(p_id, VarDefNode(sp));
|
ir.add_live_node_for_node(p_id, VarDefNode(sp));
|
||||||
ir.add_variable(Local(LocalInfo {
|
ir.add_variable(Local(LocalInfo {
|
||||||
id: p_id,
|
id: p_id,
|
||||||
ident: name
|
name: name
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ use std::vec::IntoIter;
|
|||||||
use collections::enum_set::{EnumSet, CLike};
|
use collections::enum_set::{EnumSet, CLike};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use syntax::abi;
|
use syntax::abi;
|
||||||
use syntax::ast::{CrateNum, DefId, Ident, ItemTrait, LOCAL_CRATE};
|
use syntax::ast::{CrateNum, DefId, ItemTrait, LOCAL_CRATE};
|
||||||
use syntax::ast::{MutImmutable, MutMutable, Name, NamedField, NodeId};
|
use syntax::ast::{MutImmutable, MutMutable, Name, NamedField, NodeId};
|
||||||
use syntax::ast::{StmtExpr, StmtSemi, StructField, UnnamedField, Visibility};
|
use syntax::ast::{StmtExpr, StmtSemi, StructField, UnnamedField, Visibility};
|
||||||
use syntax::ast_util::{self, is_local, lit_is_str, local_def};
|
use syntax::ast_util::{self, is_local, lit_is_str, local_def};
|
||||||
@ -4361,8 +4361,8 @@ pub fn named_element_ty<'tcx>(cx: &ctxt<'tcx>,
|
|||||||
variant_info.arg_names.as_ref()
|
variant_info.arg_names.as_ref()
|
||||||
.expect("must have struct enum variant if accessing a named fields")
|
.expect("must have struct enum variant if accessing a named fields")
|
||||||
.iter().zip(variant_info.args.iter())
|
.iter().zip(variant_info.args.iter())
|
||||||
.find(|&(ident, _)| ident.name == n)
|
.find(|&(&name, _)| name == n)
|
||||||
.map(|(_ident, arg_t)| arg_t.subst(cx, substs))
|
.map(|(_name, arg_t)| arg_t.subst(cx, substs))
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
@ -5341,7 +5341,7 @@ pub fn ty_to_def_id(ty: Ty) -> Option<ast::DefId> {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct VariantInfo<'tcx> {
|
pub struct VariantInfo<'tcx> {
|
||||||
pub args: Vec<Ty<'tcx>>,
|
pub args: Vec<Ty<'tcx>>,
|
||||||
pub arg_names: Option<Vec<ast::Ident>>,
|
pub arg_names: Option<Vec<ast::Name>>,
|
||||||
pub ctor_ty: Option<Ty<'tcx>>,
|
pub ctor_ty: Option<Ty<'tcx>>,
|
||||||
pub name: ast::Name,
|
pub name: ast::Name,
|
||||||
pub id: ast::DefId,
|
pub id: ast::DefId,
|
||||||
@ -5388,7 +5388,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
|||||||
.map(|field| node_id_to_type(cx, field.node.id)).collect();
|
.map(|field| node_id_to_type(cx, field.node.id)).collect();
|
||||||
let arg_names = fields.iter().map(|field| {
|
let arg_names = fields.iter().map(|field| {
|
||||||
match field.node.kind {
|
match field.node.kind {
|
||||||
NamedField(ident, _) => ident,
|
NamedField(ident, _) => ident.name,
|
||||||
UnnamedField(..) => cx.sess.bug(
|
UnnamedField(..) => cx.sess.bug(
|
||||||
"enum_variants: all fields in struct must have a name")
|
"enum_variants: all fields in struct must have a name")
|
||||||
}
|
}
|
||||||
|
@ -396,11 +396,11 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
|||||||
match *origin_field_name {
|
match *origin_field_name {
|
||||||
mc::NamedField(ast_name) => {
|
mc::NamedField(ast_name) => {
|
||||||
let variant_arg_names = variant_info.arg_names.as_ref().unwrap();
|
let variant_arg_names = variant_info.arg_names.as_ref().unwrap();
|
||||||
for variant_arg_ident in variant_arg_names {
|
for &variant_arg_name in variant_arg_names {
|
||||||
if variant_arg_ident.name == ast_name {
|
if variant_arg_name == ast_name {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let field_name = mc::NamedField(variant_arg_ident.name);
|
let field_name = mc::NamedField(variant_arg_name);
|
||||||
add_fragment_sibling_local(field_name, Some(variant_info.id));
|
add_fragment_sibling_local(field_name, Some(variant_info.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,7 +686,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||||||
fn check_static_method(&mut self,
|
fn check_static_method(&mut self,
|
||||||
span: Span,
|
span: Span,
|
||||||
method_id: ast::DefId,
|
method_id: ast::DefId,
|
||||||
name: ast::Ident) {
|
name: ast::Name) {
|
||||||
// If the method is a default method, we need to use the def_id of
|
// If the method is a default method, we need to use the def_id of
|
||||||
// the default implementation.
|
// the default implementation.
|
||||||
let method_id = match ty::impl_or_trait_item(self.tcx, method_id) {
|
let method_id = match ty::impl_or_trait_item(self.tcx, method_id) {
|
||||||
@ -696,7 +696,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||||||
ty::TypeTraitItem(_) => method_id,
|
ty::TypeTraitItem(_) => method_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
let string = token::get_ident(name);
|
let string = token::get_name(name);
|
||||||
self.report_error(self.ensure_public(span,
|
self.report_error(self.ensure_public(span,
|
||||||
method_id,
|
method_id,
|
||||||
None,
|
None,
|
||||||
@ -705,13 +705,13 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks that a path is in scope.
|
// Checks that a path is in scope.
|
||||||
fn check_path(&mut self, span: Span, path_id: ast::NodeId, last: ast::Ident) {
|
fn check_path(&mut self, span: Span, path_id: ast::NodeId, last: ast::Name) {
|
||||||
debug!("privacy - path {}", self.nodestr(path_id));
|
debug!("privacy - path {}", self.nodestr(path_id));
|
||||||
let path_res = *self.tcx.def_map.borrow().get(&path_id).unwrap();
|
let path_res = *self.tcx.def_map.borrow().get(&path_id).unwrap();
|
||||||
let ck = |tyname: &str| {
|
let ck = |tyname: &str| {
|
||||||
let ck_public = |def: ast::DefId| {
|
let ck_public = |def: ast::DefId| {
|
||||||
debug!("privacy - ck_public {:?}", def);
|
debug!("privacy - ck_public {:?}", def);
|
||||||
let name = token::get_ident(last);
|
let name = token::get_name(last);
|
||||||
let origdid = path_res.def_id();
|
let origdid = path_res.def_id();
|
||||||
self.ensure_public(span,
|
self.ensure_public(span,
|
||||||
def,
|
def,
|
||||||
@ -800,10 +800,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||||||
|
|
||||||
// Checks that a method is in scope.
|
// Checks that a method is in scope.
|
||||||
fn check_method(&mut self, span: Span, origin: &MethodOrigin,
|
fn check_method(&mut self, span: Span, origin: &MethodOrigin,
|
||||||
ident: ast::Ident) {
|
name: ast::Name) {
|
||||||
match *origin {
|
match *origin {
|
||||||
MethodStatic(method_id) => {
|
MethodStatic(method_id) => {
|
||||||
self.check_static_method(span, method_id, ident)
|
self.check_static_method(span, method_id, name)
|
||||||
}
|
}
|
||||||
MethodStaticClosure(_) => {}
|
MethodStaticClosure(_) => {}
|
||||||
// Trait methods are always all public. The only controlling factor
|
// Trait methods are always all public. The only controlling factor
|
||||||
@ -825,11 +825,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
|
|||||||
match pid.node {
|
match pid.node {
|
||||||
ast::PathListIdent { id, name } => {
|
ast::PathListIdent { id, name } => {
|
||||||
debug!("privacy - ident item {}", id);
|
debug!("privacy - ident item {}", id);
|
||||||
self.check_path(pid.span, id, name);
|
self.check_path(pid.span, id, name.name);
|
||||||
}
|
}
|
||||||
ast::PathListMod { id } => {
|
ast::PathListMod { id } => {
|
||||||
debug!("privacy - mod item {}", id);
|
debug!("privacy - mod item {}", id);
|
||||||
let name = prefix.segments.last().unwrap().identifier;
|
let name = prefix.segments.last().unwrap().identifier.name;
|
||||||
self.check_path(pid.span, id, name);
|
self.check_path(pid.span, id, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -863,7 +863,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
Some(method) => {
|
Some(method) => {
|
||||||
debug!("(privacy checking) checking impl method");
|
debug!("(privacy checking) checking impl method");
|
||||||
self.check_method(expr.span, &method.origin, ident.node);
|
self.check_method(expr.span, &method.origin, ident.node.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId) {
|
fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId) {
|
||||||
self.check_path(path.span, id, path.segments.last().unwrap().identifier);
|
self.check_path(path.span, id, path.segments.last().unwrap().identifier.name);
|
||||||
visit::walk_path(self, path);
|
visit::walk_path(self, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||||||
|
|
||||||
fn process_method(&mut self, sig: &ast::MethodSig,
|
fn process_method(&mut self, sig: &ast::MethodSig,
|
||||||
body: Option<&ast::Block>,
|
body: Option<&ast::Block>,
|
||||||
id: ast::NodeId, ident: ast::Ident,
|
id: ast::NodeId, name: ast::Name,
|
||||||
span: Span) {
|
span: Span) {
|
||||||
if generated_code(span) {
|
if generated_code(span) {
|
||||||
return;
|
return;
|
||||||
@ -354,7 +354,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let qualname = &format!("{}::{}", qualname, &get_ident(ident));
|
let qualname = &format!("{}::{}", qualname, &token::get_name(name));
|
||||||
|
|
||||||
// record the decl for this def (if it has one)
|
// record the decl for this def (if it has one)
|
||||||
let decl_id = ty::trait_item_of_item(&self.analysis.ty_cx,
|
let decl_id = ty::trait_item_of_item(&self.analysis.ty_cx,
|
||||||
@ -1238,7 +1238,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||||||
match trait_item.node {
|
match trait_item.node {
|
||||||
ast::MethodTraitItem(ref sig, ref body) => {
|
ast::MethodTraitItem(ref sig, ref body) => {
|
||||||
self.process_method(sig, body.as_ref().map(|x| &**x),
|
self.process_method(sig, body.as_ref().map(|x| &**x),
|
||||||
trait_item.id, trait_item.ident, trait_item.span);
|
trait_item.id, trait_item.ident.name, trait_item.span);
|
||||||
}
|
}
|
||||||
ast::TypeTraitItem(..) => {}
|
ast::TypeTraitItem(..) => {}
|
||||||
}
|
}
|
||||||
@ -1248,7 +1248,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||||||
match impl_item.node {
|
match impl_item.node {
|
||||||
ast::MethodImplItem(ref sig, ref body) => {
|
ast::MethodImplItem(ref sig, ref body) => {
|
||||||
self.process_method(sig, Some(body), impl_item.id,
|
self.process_method(sig, Some(body), impl_item.id,
|
||||||
impl_item.ident, impl_item.span);
|
impl_item.ident.name, impl_item.span);
|
||||||
}
|
}
|
||||||
ast::TypeImplItem(_) |
|
ast::TypeImplItem(_) |
|
||||||
ast::MacImplItem(_) => {}
|
ast::MacImplItem(_) => {}
|
||||||
|
@ -223,7 +223,7 @@ use std::cmp::Ordering;
|
|||||||
use std::iter::AdditiveIterator;
|
use std::iter::AdditiveIterator;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::{DUMMY_NODE_ID, Ident, NodeId};
|
use syntax::ast::{DUMMY_NODE_ID, NodeId};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::fold::Folder;
|
use syntax::fold::Folder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
@ -349,7 +349,7 @@ pub struct BindingInfo<'tcx> {
|
|||||||
pub ty: Ty<'tcx>,
|
pub ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type BindingsMap<'tcx> = FnvHashMap<Ident, BindingInfo<'tcx>>;
|
type BindingsMap<'tcx> = FnvHashMap<ast::Ident, BindingInfo<'tcx>>;
|
||||||
|
|
||||||
struct ArmData<'p, 'blk, 'tcx: 'blk> {
|
struct ArmData<'p, 'blk, 'tcx: 'blk> {
|
||||||
bodycx: Block<'blk, 'tcx>,
|
bodycx: Block<'blk, 'tcx>,
|
||||||
@ -364,7 +364,7 @@ struct ArmData<'p, 'blk, 'tcx: 'blk> {
|
|||||||
struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
|
struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
|
||||||
pats: Vec<&'p ast::Pat>,
|
pats: Vec<&'p ast::Pat>,
|
||||||
data: &'a ArmData<'p, 'blk, 'tcx>,
|
data: &'a ArmData<'p, 'blk, 'tcx>,
|
||||||
bound_ptrs: Vec<(Ident, ValueRef)>,
|
bound_ptrs: Vec<(ast::Ident, ValueRef)>,
|
||||||
// Thread along renamings done by the check_match::StaticInliner, so we can
|
// Thread along renamings done by the check_match::StaticInliner, so we can
|
||||||
// map back to original NodeIds
|
// map back to original NodeIds
|
||||||
pat_renaming_map: Option<&'a FnvHashMap<(NodeId, Span), NodeId>>
|
pat_renaming_map: Option<&'a FnvHashMap<(NodeId, Span), NodeId>>
|
||||||
@ -923,7 +923,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));
|
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));
|
||||||
bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum);
|
bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum);
|
||||||
debuginfo::create_match_binding_metadata(bcx, ident, binding_info);
|
debuginfo::create_match_binding_metadata(bcx, ident.name, binding_info);
|
||||||
}
|
}
|
||||||
bcx
|
bcx
|
||||||
}
|
}
|
||||||
@ -1380,6 +1380,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||||||
let mut bindings_map = FnvHashMap();
|
let mut bindings_map = FnvHashMap();
|
||||||
pat_bindings(&tcx.def_map, &*pat, |bm, p_id, span, path1| {
|
pat_bindings(&tcx.def_map, &*pat, |bm, p_id, span, path1| {
|
||||||
let ident = path1.node;
|
let ident = path1.node;
|
||||||
|
let name = ident.name;
|
||||||
let variable_ty = node_id_type(bcx, p_id);
|
let variable_ty = node_id_type(bcx, p_id);
|
||||||
let llvariable_ty = type_of::type_of(ccx, variable_ty);
|
let llvariable_ty = type_of::type_of(ccx, variable_ty);
|
||||||
let tcx = bcx.tcx();
|
let tcx = bcx.tcx();
|
||||||
@ -1396,7 +1397,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||||||
"__llmatch");
|
"__llmatch");
|
||||||
trmode = TrByCopy(alloca_no_lifetime(bcx,
|
trmode = TrByCopy(alloca_no_lifetime(bcx,
|
||||||
llvariable_ty,
|
llvariable_ty,
|
||||||
&bcx.ident(ident)));
|
&bcx.name(name)));
|
||||||
}
|
}
|
||||||
ast::BindByValue(_) => {
|
ast::BindByValue(_) => {
|
||||||
// in this case, the final type of the variable will be T,
|
// in this case, the final type of the variable will be T,
|
||||||
@ -1404,13 +1405,13 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||||||
// above
|
// above
|
||||||
llmatch = alloca_no_lifetime(bcx,
|
llmatch = alloca_no_lifetime(bcx,
|
||||||
llvariable_ty.ptr_to(),
|
llvariable_ty.ptr_to(),
|
||||||
&bcx.ident(ident));
|
&bcx.name(name));
|
||||||
trmode = TrByMove;
|
trmode = TrByMove;
|
||||||
}
|
}
|
||||||
ast::BindByRef(_) => {
|
ast::BindByRef(_) => {
|
||||||
llmatch = alloca_no_lifetime(bcx,
|
llmatch = alloca_no_lifetime(bcx,
|
||||||
llvariable_ty,
|
llvariable_ty,
|
||||||
&bcx.ident(ident));
|
&bcx.name(name));
|
||||||
trmode = TrByRef;
|
trmode = TrByRef;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1527,7 +1528,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
pat_bindings(&tcx.def_map, pat, |_, p_id, _, path1| {
|
pat_bindings(&tcx.def_map, pat, |_, p_id, _, path1| {
|
||||||
let scope = cleanup::var_scope(tcx, p_id);
|
let scope = cleanup::var_scope(tcx, p_id);
|
||||||
bcx = mk_binding_alloca(
|
bcx = mk_binding_alloca(
|
||||||
bcx, p_id, &path1.node, scope, (),
|
bcx, p_id, path1.node.name, scope, (),
|
||||||
|(), bcx, llval, ty| { drop_done_fill_mem(bcx, llval, ty); bcx });
|
|(), bcx, llval, ty| { drop_done_fill_mem(bcx, llval, ty); bcx });
|
||||||
});
|
});
|
||||||
bcx
|
bcx
|
||||||
@ -1549,7 +1550,7 @@ pub fn store_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
Some(ident) => {
|
Some(ident) => {
|
||||||
let var_scope = cleanup::var_scope(tcx, local.id);
|
let var_scope = cleanup::var_scope(tcx, local.id);
|
||||||
return mk_binding_alloca(
|
return mk_binding_alloca(
|
||||||
bcx, pat.id, ident, var_scope, (),
|
bcx, pat.id, ident.name, var_scope, (),
|
||||||
|(), bcx, v, _| expr::trans_into(bcx, &**init_expr,
|
|(), bcx, v, _| expr::trans_into(bcx, &**init_expr,
|
||||||
expr::SaveIn(v)));
|
expr::SaveIn(v)));
|
||||||
}
|
}
|
||||||
@ -1605,7 +1606,7 @@ pub fn store_arg<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||||||
bcx
|
bcx
|
||||||
} else {
|
} else {
|
||||||
mk_binding_alloca(
|
mk_binding_alloca(
|
||||||
bcx, pat.id, ident, arg_scope, arg,
|
bcx, pat.id, ident.name, arg_scope, arg,
|
||||||
|arg, bcx, llval, _| arg.store_to(bcx, llval))
|
|arg, bcx, llval, _| arg.store_to(bcx, llval))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1622,7 +1623,7 @@ pub fn store_arg<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
|
fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
|
||||||
p_id: ast::NodeId,
|
p_id: ast::NodeId,
|
||||||
ident: &ast::Ident,
|
name: ast::Name,
|
||||||
cleanup_scope: cleanup::ScopeId,
|
cleanup_scope: cleanup::ScopeId,
|
||||||
arg: A,
|
arg: A,
|
||||||
populate: F)
|
populate: F)
|
||||||
@ -1632,7 +1633,7 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
|
|||||||
let var_ty = node_id_type(bcx, p_id);
|
let var_ty = node_id_type(bcx, p_id);
|
||||||
|
|
||||||
// Allocate memory on stack for the binding.
|
// Allocate memory on stack for the binding.
|
||||||
let llval = alloc_ty(bcx, var_ty, &bcx.ident(*ident));
|
let llval = alloc_ty(bcx, var_ty, &bcx.name(name));
|
||||||
|
|
||||||
// Subtle: be sure that we *populate* the memory *before*
|
// Subtle: be sure that we *populate* the memory *before*
|
||||||
// we schedule the cleanup.
|
// we schedule the cleanup.
|
||||||
@ -1686,7 +1687,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
// binding will live and place it into the appropriate
|
// binding will live and place it into the appropriate
|
||||||
// map.
|
// map.
|
||||||
bcx = mk_binding_alloca(
|
bcx = mk_binding_alloca(
|
||||||
bcx, pat.id, &path1.node, cleanup_scope, (),
|
bcx, pat.id, path1.node.name, cleanup_scope, (),
|
||||||
|(), bcx, llval, ty| {
|
|(), bcx, llval, ty| {
|
||||||
match pat_binding_mode {
|
match pat_binding_mode {
|
||||||
ast::BindByValue(_) => {
|
ast::BindByValue(_) => {
|
||||||
|
@ -48,7 +48,6 @@ use std::ffi::CString;
|
|||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::result::Result as StdResult;
|
use std::result::Result as StdResult;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use syntax::ast::Ident;
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast_map::{PathElem, PathName};
|
use syntax::ast_map::{PathElem, PathName};
|
||||||
use syntax::codemap::{DUMMY_SP, Span};
|
use syntax::codemap::{DUMMY_SP, Span};
|
||||||
@ -622,8 +621,8 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
|||||||
}
|
}
|
||||||
pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() }
|
pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() }
|
||||||
|
|
||||||
pub fn ident(&self, ident: Ident) -> String {
|
pub fn name(&self, name: ast::Name) -> String {
|
||||||
token::get_ident(ident).to_string()
|
token::get_name(name).to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn node_id_to_string(&self, id: ast::NodeId) -> String {
|
pub fn node_id_to_string(&self, id: ast::NodeId) -> String {
|
||||||
|
@ -27,7 +27,6 @@ use middle::ty;
|
|||||||
use util::ppaux::Repr;
|
use util::ppaux::Repr;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::Ident;
|
|
||||||
use syntax::ast_util;
|
use syntax::ast_util;
|
||||||
use syntax::parse::token::InternedString;
|
use syntax::parse::token::InternedString;
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
@ -321,7 +320,7 @@ pub fn trans_loop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
expr: &ast::Expr,
|
expr: &ast::Expr,
|
||||||
opt_label: Option<Ident>,
|
opt_label: Option<ast::Ident>,
|
||||||
exit: usize)
|
exit: usize)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> {
|
||||||
let _icx = push_ctxt("trans_break_cont");
|
let _icx = push_ctxt("trans_break_cont");
|
||||||
@ -354,14 +353,14 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
pub fn trans_break<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
pub fn trans_break<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
expr: &ast::Expr,
|
expr: &ast::Expr,
|
||||||
label_opt: Option<Ident>)
|
label_opt: Option<ast::Ident>)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> {
|
||||||
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_BREAK);
|
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_BREAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trans_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
pub fn trans_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
expr: &ast::Expr,
|
expr: &ast::Expr,
|
||||||
label_opt: Option<Ident>)
|
label_opt: Option<ast::Ident>)
|
||||||
-> Block<'blk, 'tcx> {
|
-> Block<'blk, 'tcx> {
|
||||||
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_LOOP);
|
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_LOOP);
|
||||||
}
|
}
|
||||||
|
@ -773,11 +773,11 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
|||||||
|
|
||||||
let var_item = cx.tcx().map.get(node_id);
|
let var_item = cx.tcx().map.get(node_id);
|
||||||
|
|
||||||
let (ident, span) = match var_item {
|
let (name, span) = match var_item {
|
||||||
ast_map::NodeItem(item) => {
|
ast_map::NodeItem(item) => {
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::ItemStatic(..) => (item.ident, item.span),
|
ast::ItemStatic(..) => (item.ident.name, item.span),
|
||||||
ast::ItemConst(..) => (item.ident, item.span),
|
ast::ItemConst(..) => (item.ident.name, item.span),
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess()
|
cx.sess()
|
||||||
.span_bug(item.span,
|
.span_bug(item.span,
|
||||||
@ -806,7 +806,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
|||||||
let variable_type = ty::node_id_to_type(cx.tcx(), node_id);
|
let variable_type = ty::node_id_to_type(cx.tcx(), node_id);
|
||||||
let type_metadata = type_metadata(cx, variable_type, span);
|
let type_metadata = type_metadata(cx, variable_type, span);
|
||||||
let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
|
let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
|
||||||
let var_name = token::get_ident(ident).to_string();
|
let var_name = token::get_name(name).to_string();
|
||||||
let linkage_name =
|
let linkage_name =
|
||||||
namespace_node.mangled_name_of_contained_item(&var_name[..]);
|
namespace_node.mangled_name_of_contained_item(&var_name[..]);
|
||||||
let var_scope = namespace_node.scope;
|
let var_scope = namespace_node.scope;
|
||||||
@ -861,7 +861,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
|
|||||||
let scope_metadata = scope_metadata(bcx.fcx, node_id, span);
|
let scope_metadata = scope_metadata(bcx.fcx, node_id, span);
|
||||||
|
|
||||||
declare_local(bcx,
|
declare_local(bcx,
|
||||||
var_ident.node,
|
var_ident.node.name,
|
||||||
datum.ty,
|
datum.ty,
|
||||||
scope_metadata,
|
scope_metadata,
|
||||||
DirectVariable { alloca: datum.val },
|
DirectVariable { alloca: datum.val },
|
||||||
@ -889,14 +889,14 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
|
|
||||||
let ast_item = cx.tcx().map.find(node_id);
|
let ast_item = cx.tcx().map.find(node_id);
|
||||||
|
|
||||||
let variable_ident = match ast_item {
|
let variable_name = match ast_item {
|
||||||
None => {
|
None => {
|
||||||
cx.sess().span_bug(span, "debuginfo::create_captured_var_metadata: node not found");
|
cx.sess().span_bug(span, "debuginfo::create_captured_var_metadata: node not found");
|
||||||
}
|
}
|
||||||
Some(ast_map::NodeLocal(pat)) | Some(ast_map::NodeArg(pat)) => {
|
Some(ast_map::NodeLocal(pat)) | Some(ast_map::NodeArg(pat)) => {
|
||||||
match pat.node {
|
match pat.node {
|
||||||
ast::PatIdent(_, ref path1, _) => {
|
ast::PatIdent(_, ref path1, _) => {
|
||||||
path1.node
|
path1.node.name
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess()
|
cx.sess()
|
||||||
@ -950,7 +950,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare_local(bcx,
|
declare_local(bcx,
|
||||||
variable_ident,
|
variable_name,
|
||||||
variable_type,
|
variable_type,
|
||||||
scope_metadata,
|
scope_metadata,
|
||||||
variable_access,
|
variable_access,
|
||||||
@ -963,7 +963,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
///
|
///
|
||||||
/// Adds the created metadata nodes directly to the crate's IR.
|
/// Adds the created metadata nodes directly to the crate's IR.
|
||||||
pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
variable_ident: ast::Ident,
|
variable_name: ast::Name,
|
||||||
binding: BindingInfo<'tcx>) {
|
binding: BindingInfo<'tcx>) {
|
||||||
if bcx.unreachable.get() ||
|
if bcx.unreachable.get() ||
|
||||||
fn_should_be_ignored(bcx.fcx) ||
|
fn_should_be_ignored(bcx.fcx) ||
|
||||||
@ -993,7 +993,7 @@ pub fn create_match_binding_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare_local(bcx,
|
declare_local(bcx,
|
||||||
variable_ident,
|
variable_name,
|
||||||
binding.ty,
|
binding.ty,
|
||||||
scope_metadata,
|
scope_metadata,
|
||||||
var_access,
|
var_access,
|
||||||
@ -1048,7 +1048,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
declare_local(bcx,
|
declare_local(bcx,
|
||||||
var_ident.node,
|
var_ident.node.name,
|
||||||
datum.ty,
|
datum.ty,
|
||||||
scope_metadata,
|
scope_metadata,
|
||||||
DirectVariable { alloca: datum.val },
|
DirectVariable { alloca: datum.val },
|
||||||
@ -1283,7 +1283,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
|
|
||||||
let fnitem = cx.tcx().map.get(fn_ast_id);
|
let fnitem = cx.tcx().map.get(fn_ast_id);
|
||||||
|
|
||||||
let (ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
|
let (name, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
|
||||||
ast_map::NodeItem(ref item) => {
|
ast_map::NodeItem(ref item) => {
|
||||||
if contains_nodebug_attribute(&item.attrs) {
|
if contains_nodebug_attribute(&item.attrs) {
|
||||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||||
@ -1291,7 +1291,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
|
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::ItemFn(ref fn_decl, _, _, ref generics, ref top_level_block) => {
|
ast::ItemFn(ref fn_decl, _, _, ref generics, ref top_level_block) => {
|
||||||
(item.ident, fn_decl, generics, top_level_block, item.span, true)
|
(item.ident.name, fn_decl, generics, top_level_block, item.span, true)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
cx.sess().span_bug(item.span,
|
cx.sess().span_bug(item.span,
|
||||||
@ -1306,7 +1306,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
(impl_item.ident,
|
(impl_item.ident.name,
|
||||||
&sig.decl,
|
&sig.decl,
|
||||||
&sig.generics,
|
&sig.generics,
|
||||||
body,
|
body,
|
||||||
@ -1329,7 +1329,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
match expr.node {
|
match expr.node {
|
||||||
ast::ExprClosure(_, ref fn_decl, ref top_level_block) => {
|
ast::ExprClosure(_, ref fn_decl, ref top_level_block) => {
|
||||||
let name = format!("fn{}", token::gensym("fn"));
|
let name = format!("fn{}", token::gensym("fn"));
|
||||||
let name = token::str_to_ident(&name[..]);
|
let name = token::intern(&name[..]);
|
||||||
(name, fn_decl,
|
(name, fn_decl,
|
||||||
// This is not quite right. It should actually inherit
|
// This is not quite right. It should actually inherit
|
||||||
// the generics of the enclosing function.
|
// the generics of the enclosing function.
|
||||||
@ -1350,7 +1350,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
(trait_item.ident,
|
(trait_item.ident.name,
|
||||||
&sig.decl,
|
&sig.decl,
|
||||||
&sig.generics,
|
&sig.generics,
|
||||||
body,
|
body,
|
||||||
@ -1394,7 +1394,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
|
|
||||||
// Get_template_parameters() will append a `<...>` clause to the function
|
// Get_template_parameters() will append a `<...>` clause to the function
|
||||||
// name if necessary.
|
// name if necessary.
|
||||||
let mut function_name = String::from_str(&token::get_ident(ident));
|
let mut function_name = String::from_str(&token::get_name(name));
|
||||||
let template_parameters = get_template_parameters(cx,
|
let template_parameters = get_template_parameters(cx,
|
||||||
generics,
|
generics,
|
||||||
param_substs,
|
param_substs,
|
||||||
@ -1541,10 +1541,9 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
actual_self_type,
|
actual_self_type,
|
||||||
codemap::DUMMY_SP);
|
codemap::DUMMY_SP);
|
||||||
|
|
||||||
let ident = special_idents::type_self;
|
let name = token::get_name(special_idents::type_self.name);
|
||||||
|
|
||||||
let ident = token::get_ident(ident);
|
let name = CString::new(name.as_bytes()).unwrap();
|
||||||
let name = CString::new(ident.as_bytes()).unwrap();
|
|
||||||
let param_metadata = unsafe {
|
let param_metadata = unsafe {
|
||||||
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
|
llvm::LLVMDIBuilderCreateTemplateTypeParameter(
|
||||||
DIB(cx),
|
DIB(cx),
|
||||||
@ -1673,7 +1672,7 @@ fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
variable_ident: ast::Ident,
|
variable_name: ast::Name,
|
||||||
variable_type: Ty<'tcx>,
|
variable_type: Ty<'tcx>,
|
||||||
scope_metadata: DIScope,
|
scope_metadata: DIScope,
|
||||||
variable_access: VariableAccess,
|
variable_access: VariableAccess,
|
||||||
@ -1684,7 +1683,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
let filename = span_start(cx, span).file.name.clone();
|
let filename = span_start(cx, span).file.name.clone();
|
||||||
let file_metadata = file_metadata(cx, &filename[..]);
|
let file_metadata = file_metadata(cx, &filename[..]);
|
||||||
|
|
||||||
let name = token::get_ident(variable_ident);
|
let name = token::get_name(variable_name);
|
||||||
let loc = span_start(cx, span);
|
let loc = span_start(cx, span);
|
||||||
let type_metadata = type_metadata(cx, variable_type, span);
|
let type_metadata = type_metadata(cx, variable_type, span);
|
||||||
|
|
||||||
@ -2261,7 +2260,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
|
|||||||
// MemberDescription of the struct's single field.
|
// MemberDescription of the struct's single field.
|
||||||
let sole_struct_member_description = MemberDescription {
|
let sole_struct_member_description = MemberDescription {
|
||||||
name: match non_null_variant.arg_names {
|
name: match non_null_variant.arg_names {
|
||||||
Some(ref names) => token::get_ident(names[0]).to_string(),
|
Some(ref names) => token::get_name(names[0]).to_string(),
|
||||||
None => "".to_string()
|
None => "".to_string()
|
||||||
},
|
},
|
||||||
llvm_type: non_null_llvm_type,
|
llvm_type: non_null_llvm_type,
|
||||||
@ -2429,9 +2428,8 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
let mut arg_names: Vec<_> = match variant_info.arg_names {
|
let mut arg_names: Vec<_> = match variant_info.arg_names {
|
||||||
Some(ref names) => {
|
Some(ref names) => {
|
||||||
names.iter()
|
names.iter()
|
||||||
.map(|ident| {
|
.map(|&name| token::get_name(name).to_string())
|
||||||
token::get_ident(*ident).to_string()
|
.collect()
|
||||||
}).collect()
|
|
||||||
}
|
}
|
||||||
None => variant_info.args.iter().map(|_| "".to_string()).collect()
|
None => variant_info.args.iter().map(|_| "".to_string()).collect()
|
||||||
};
|
};
|
||||||
@ -3245,11 +3243,10 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
|
|
||||||
struct ScopeStackEntry {
|
struct ScopeStackEntry {
|
||||||
scope_metadata: DIScope,
|
scope_metadata: DIScope,
|
||||||
ident: Option<ast::Ident>
|
name: Option<ast::Name>
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut scope_stack = vec!(ScopeStackEntry { scope_metadata: fn_metadata,
|
let mut scope_stack = vec!(ScopeStackEntry { scope_metadata: fn_metadata, name: None });
|
||||||
ident: None });
|
|
||||||
scope_map.insert(fn_ast_id, fn_metadata);
|
scope_map.insert(fn_ast_id, fn_metadata);
|
||||||
|
|
||||||
// Push argument identifiers onto the stack so arguments integrate nicely
|
// Push argument identifiers onto the stack so arguments integrate nicely
|
||||||
@ -3257,7 +3254,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
for arg in args {
|
for arg in args {
|
||||||
pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, _, path1| {
|
pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, _, path1| {
|
||||||
scope_stack.push(ScopeStackEntry { scope_metadata: fn_metadata,
|
scope_stack.push(ScopeStackEntry { scope_metadata: fn_metadata,
|
||||||
ident: Some(path1.node) });
|
name: Some(path1.node.name) });
|
||||||
scope_map.insert(node_id, fn_metadata);
|
scope_map.insert(node_id, fn_metadata);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -3296,13 +3293,12 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
loc.col.to_usize() as c_uint)
|
loc.col.to_usize() as c_uint)
|
||||||
};
|
};
|
||||||
|
|
||||||
scope_stack.push(ScopeStackEntry { scope_metadata: scope_metadata,
|
scope_stack.push(ScopeStackEntry { scope_metadata: scope_metadata, name: None });
|
||||||
ident: None });
|
|
||||||
|
|
||||||
inner_walk(cx, scope_stack, scope_map);
|
inner_walk(cx, scope_stack, scope_map);
|
||||||
|
|
||||||
// pop artificial scopes
|
// pop artificial scopes
|
||||||
while scope_stack.last().unwrap().ident.is_some() {
|
while scope_stack.last().unwrap().name.is_some() {
|
||||||
scope_stack.pop();
|
scope_stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3374,7 +3370,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
// scope stack and maybe introduce an artificial scope
|
// scope stack and maybe introduce an artificial scope
|
||||||
if pat_util::pat_is_binding(def_map, &*pat) {
|
if pat_util::pat_is_binding(def_map, &*pat) {
|
||||||
|
|
||||||
let ident = path1.node;
|
let name = path1.node.name;
|
||||||
|
|
||||||
// LLVM does not properly generate 'DW_AT_start_scope' fields
|
// LLVM does not properly generate 'DW_AT_start_scope' fields
|
||||||
// for variable DIEs. For this reason we have to introduce
|
// for variable DIEs. For this reason we have to introduce
|
||||||
@ -3401,7 +3397,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
// variables with the same name will cause the problem.
|
// variables with the same name will cause the problem.
|
||||||
let need_new_scope = scope_stack
|
let need_new_scope = scope_stack
|
||||||
.iter()
|
.iter()
|
||||||
.any(|entry| entry.ident.iter().any(|i| i.name == ident.name));
|
.any(|entry| entry.name == Some(name));
|
||||||
|
|
||||||
if need_new_scope {
|
if need_new_scope {
|
||||||
// Create a new lexical scope and push it onto the stack
|
// Create a new lexical scope and push it onto the stack
|
||||||
@ -3420,7 +3416,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
|
|
||||||
scope_stack.push(ScopeStackEntry {
|
scope_stack.push(ScopeStackEntry {
|
||||||
scope_metadata: scope_metadata,
|
scope_metadata: scope_metadata,
|
||||||
ident: Some(ident)
|
name: Some(name)
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -3428,7 +3424,7 @@ fn create_scope_map(cx: &CrateContext,
|
|||||||
let prev_metadata = scope_stack.last().unwrap().scope_metadata;
|
let prev_metadata = scope_stack.last().unwrap().scope_metadata;
|
||||||
scope_stack.push(ScopeStackEntry {
|
scope_stack.push(ScopeStackEntry {
|
||||||
scope_metadata: prev_metadata,
|
scope_metadata: prev_metadata,
|
||||||
ident: Some(ident)
|
name: Some(name)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3970,8 +3966,8 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
|
|||||||
ty::with_path(cx.tcx(), def_id, |path| {
|
ty::with_path(cx.tcx(), def_id, |path| {
|
||||||
// prepend crate name if not already present
|
// prepend crate name if not already present
|
||||||
let krate = if def_id.krate == ast::LOCAL_CRATE {
|
let krate = if def_id.krate == ast::LOCAL_CRATE {
|
||||||
let crate_namespace_ident = token::str_to_ident(crate_root_namespace(cx));
|
let crate_namespace_name = token::intern(crate_root_namespace(cx));
|
||||||
Some(ast_map::PathMod(crate_namespace_ident.name))
|
Some(ast_map::PathMod(crate_namespace_name))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -678,7 +678,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
trans_def(bcx, expr, bcx.def(expr.id))
|
trans_def(bcx, expr, bcx.def(expr.id))
|
||||||
}
|
}
|
||||||
ast::ExprField(ref base, ident) => {
|
ast::ExprField(ref base, ident) => {
|
||||||
trans_rec_field(bcx, &**base, ident.node)
|
trans_rec_field(bcx, &**base, ident.node.name)
|
||||||
}
|
}
|
||||||
ast::ExprTupField(ref base, idx) => {
|
ast::ExprTupField(ref base, idx) => {
|
||||||
trans_rec_tup_field(bcx, &**base, idx.node)
|
trans_rec_tup_field(bcx, &**base, idx.node)
|
||||||
@ -777,9 +777,9 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
|||||||
/// Translates `base.field`.
|
/// Translates `base.field`.
|
||||||
fn trans_rec_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
fn trans_rec_field<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
base: &ast::Expr,
|
base: &ast::Expr,
|
||||||
field: ast::Ident)
|
field: ast::Name)
|
||||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||||
trans_field(bcx, base, |tcx, field_tys| ty::field_idx_strict(tcx, field.name, field_tys))
|
trans_field(bcx, base, |tcx, field_tys| ty::field_idx_strict(tcx, field, field_tys))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translates `base.<idx>`.
|
/// Translates `base.<idx>`.
|
||||||
|
Loading…
Reference in New Issue
Block a user