ItemFn(Name, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
/// fn foo(&self)
- Method(Name, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
+ Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
/// |x, y| {}
Closure(&'a [Attribute]),
}
pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) {
- visitor.visit_name(trait_item.span, trait_item.name);
+ visitor.visit_ident(trait_item.ident);
walk_list!(visitor, visit_attribute, &trait_item.attrs);
visitor.visit_generics(&trait_item.generics);
match trait_item.node {
}
}
TraitItemKind::Method(ref sig, TraitMethod::Provided(body_id)) => {
- visitor.visit_fn(FnKind::Method(trait_item.name,
+ visitor.visit_fn(FnKind::Method(trait_item.ident,
sig,
None,
&trait_item.attrs),
pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref: &'v TraitItemRef) {
// NB: Deliberately force a compilation error if/when new fields are added.
- let TraitItemRef { id, name, ref kind, span, ref defaultness } = *trait_item_ref;
+ let TraitItemRef { id, ident, ref kind, span: _, ref defaultness } = *trait_item_ref;
visitor.visit_nested_trait_item(id);
- visitor.visit_name(span, name);
+ visitor.visit_ident(ident);
visitor.visit_associated_item_kind(kind);
visitor.visit_defaultness(defaultness);
}
let ImplItem {
id: _,
hir_id: _,
- name,
+ ident,
ref vis,
ref defaultness,
ref attrs,
ref generics,
ref node,
- span
+ span: _,
} = *impl_item;
- visitor.visit_name(span, name);
+ visitor.visit_ident(ident);
visitor.visit_vis(vis);
visitor.visit_defaultness(defaultness);
walk_list!(visitor, visit_attribute, attrs);
visitor.visit_nested_body(body);
}
ImplItemKind::Method(ref sig, body_id) => {
- visitor.visit_fn(FnKind::Method(impl_item.name,
+ visitor.visit_fn(FnKind::Method(impl_item.ident,
sig,
Some(&impl_item.vis),
&impl_item.attrs),
pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) {
// NB: Deliberately force a compilation error if/when new fields are added.
- let ImplItemRef { id, name, ref kind, span, ref vis, ref defaultness } = *impl_item_ref;
+ let ImplItemRef { id, ident, ref kind, span: _, ref vis, ref defaultness } = *impl_item_ref;
visitor.visit_nested_impl_item(id);
- visitor.visit_name(span, name);
+ visitor.visit_ident(ident);
visitor.visit_associated_item_kind(kind);
visitor.visit_vis(vis);
visitor.visit_defaultness(defaultness);
use rustc_data_structures::indexed_vec::IndexVec;
use session::Session;
use util::common::FN_OUTPUT_NAME;
-use util::nodemap::{DefIdMap, FxHashMap, NodeMap};
+use util::nodemap::{DefIdMap, NodeMap};
use std::collections::{BTreeMap, HashSet};
use std::fmt::Debug;
cstore: &'a CrateStore,
resolver: &'a mut Resolver,
- name_map: FxHashMap<Ident, Name>,
/// The items being lowered are collected here.
items: BTreeMap<NodeId, hir::Item>,
sess,
cstore,
resolver,
- name_map: FxHashMap(),
items: BTreeMap::new(),
trait_items: BTreeMap::new(),
impl_items: BTreeMap::new(),
}
}
- fn lower_ident(&mut self, ident: Ident) -> Name {
- let ident = ident.modern();
- if ident.span.ctxt() == SyntaxContext::empty() {
- return ident.name;
- }
- *self.name_map
- .entry(ident)
- .or_insert_with(|| Symbol::from_ident(ident))
- }
-
fn lower_label(&mut self, label: Option<Label>) -> Option<hir::Label> {
label.map(|label| hir::Label {
ident: label.ident,
hir::TraitItem {
id: node_id,
hir_id,
- name: self.lower_ident(i.ident),
+ ident: i.ident,
attrs: self.lower_attrs(&i.attrs),
generics,
node,
};
hir::TraitItemRef {
id: hir::TraitItemId { node_id: i.id },
- name: self.lower_ident(i.ident),
+ ident: i.ident,
span: i.span,
defaultness: self.lower_defaultness(Defaultness::Default, has_default),
kind,
hir::ImplItem {
id: node_id,
hir_id,
- name: self.lower_ident(i.ident),
+ ident: i.ident,
attrs: self.lower_attrs(&i.attrs),
generics,
vis: self.lower_visibility(&i.vis, None),
fn lower_impl_item_ref(&mut self, i: &ImplItem) -> hir::ImplItemRef {
hir::ImplItemRef {
id: hir::ImplItemId { node_id: i.id },
- name: self.lower_ident(i.ident),
+ ident: i.ident,
span: i.span,
vis: self.lower_visibility(&i.vis, Some(i.id)),
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
use hir::map::{self, Node};
use hir::{Expr, FnDecl};
use hir::intravisit::FnKind;
-use syntax::ast::{Attribute, Name, NodeId};
+use syntax::ast::{Attribute, Ident, Name, NodeId};
use syntax_pos::Span;
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
let closure = |c: ClosureParts<'a>| {
FnKind::Closure(c.attrs)
};
- let method = |_, name: Name, sig: &'a ast::MethodSig, vis, _, _, attrs| {
- FnKind::Method(name, sig, vis, attrs)
+ let method = |_, ident: Ident, sig: &'a ast::MethodSig, vis, _, _, attrs| {
+ FnKind::Method(ident, sig, vis, attrs)
};
self.handle(item, method, closure)
}
fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
I: FnOnce(ItemFnParts<'a>) -> A,
M: FnOnce(NodeId,
- Name,
+ Ident,
&'a ast::MethodSig,
Option<&'a ast::Visibility>,
ast::BodyId,
},
map::NodeTraitItem(ti) => match ti.node {
ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => {
- method(ti.id, ti.name, sig, None, body, ti.span, &ti.attrs)
+ method(ti.id, ti.ident, sig, None, body, ti.span, &ti.attrs)
}
_ => bug!("trait method FnLikeNode that is not fn-like"),
},
map::NodeImplItem(ii) => {
match ii.node {
ast::ImplItemKind::Method(ref sig, body) => {
- method(ii.id, ii.name, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
+ method(ii.id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
}
_ => {
bug!("impl method FnLikeNode that is not fn-like")
// map the actual nodes, not the duplicate ones in the *Ref.
let TraitItemRef {
id,
- name: _,
+ ident: _,
kind: _,
span: _,
defaultness: _,
// map the actual nodes, not the duplicate ones in the *Ref.
let ImplItemRef {
id,
- name: _,
+ ident: _,
kind: _,
span: _,
vis: _,
match self.get(id) {
NodeItem(i) => i.name,
NodeForeignItem(i) => i.name,
- NodeImplItem(ii) => ii.name,
- NodeTraitItem(ti) => ti.name,
+ NodeImplItem(ii) => ii.ident.name,
+ NodeTraitItem(ti) => ti.ident.name,
NodeVariant(v) => v.node.name,
NodeField(f) => f.ident.name,
NodeLifetime(lt) => lt.name.ident().name,
impl Named for ForeignItem { fn name(&self) -> Name { self.name } }
impl Named for Variant_ { fn name(&self) -> Name { self.name } }
impl Named for StructField { fn name(&self) -> Name { self.ident.name } }
-impl Named for TraitItem { fn name(&self) -> Name { self.name } }
-impl Named for ImplItem { fn name(&self) -> Name { self.name } }
+impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } }
+impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } }
pub fn map_crate<'hir>(sess: &::session::Session,
Some(NodeImplItem(ii)) => {
match ii.node {
ImplItemKind::Const(..) => {
- format!("assoc const {} in {}{}", ii.name, path_str(), id_str)
+ format!("assoc const {} in {}{}", ii.ident, path_str(), id_str)
}
ImplItemKind::Method(..) => {
- format!("method {} in {}{}", ii.name, path_str(), id_str)
+ format!("method {} in {}{}", ii.ident, path_str(), id_str)
}
ImplItemKind::Type(_) => {
- format!("assoc type {} in {}{}", ii.name, path_str(), id_str)
+ format!("assoc type {} in {}{}", ii.ident, path_str(), id_str)
}
}
}
TraitItemKind::Type(..) => "assoc type",
};
- format!("{} {} in {}{}", kind, ti.name, path_str(), id_str)
+ format!("{} {} in {}{}", kind, ti.ident, path_str(), id_str)
}
Some(NodeVariant(ref variant)) => {
format!("variant {} in {}{}",
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TraitItem {
pub id: NodeId,
- pub name: Name,
+ pub ident: Ident,
pub hir_id: HirId,
pub attrs: HirVec<Attribute>,
pub generics: Generics,
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct ImplItem {
pub id: NodeId,
- pub name: Name,
+ pub ident: Ident,
pub hir_id: HirId,
pub vis: Visibility,
pub defaultness: Defaultness,
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TraitItemRef {
pub id: TraitItemId,
- pub name: Name,
+ pub ident: Ident,
pub kind: AssociatedItemKind,
pub span: Span,
pub defaultness: Defaultness,
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct ImplItemRef {
pub id: ImplItemId,
- pub name: Name,
+ pub ident: Ident,
pub kind: AssociatedItemKind,
pub span: Span,
pub vis: Visibility,
}
fn print_associated_const(&mut self,
- name: ast::Name,
+ ident: ast::Ident,
ty: &hir::Ty,
default: Option<hir::BodyId>,
vis: &hir::Visibility)
-> io::Result<()> {
self.s.word(&visibility_qualified(vis, ""))?;
self.word_space("const")?;
- self.print_name(name)?;
+ self.print_ident(ident)?;
self.word_space(":")?;
self.print_type(ty)?;
if let Some(expr) = default {
}
fn print_associated_type(&mut self,
- name: ast::Name,
+ ident: ast::Ident,
bounds: Option<&hir::GenericBounds>,
ty: Option<&hir::Ty>)
-> io::Result<()> {
self.word_space("type")?;
- self.print_name(name)?;
+ self.print_ident(ident)?;
if let Some(bounds) = bounds {
self.print_bounds(":", bounds)?;
}
Ok(())
}
pub fn print_method_sig(&mut self,
- name: ast::Name,
+ ident: ast::Ident,
m: &hir::MethodSig,
generics: &hir::Generics,
vis: &hir::Visibility,
-> io::Result<()> {
self.print_fn(&m.decl,
m.header,
- Some(name),
+ Some(ident.name),
generics,
vis,
arg_names,
self.print_outer_attributes(&ti.attrs)?;
match ti.node {
hir::TraitItemKind::Const(ref ty, default) => {
- self.print_associated_const(ti.name, &ty, default, &hir::Inherited)?;
+ self.print_associated_const(ti.ident, &ty, default, &hir::Inherited)?;
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => {
- self.print_method_sig(ti.name, sig, &ti.generics, &hir::Inherited, arg_names,
+ self.print_method_sig(ti.ident, sig, &ti.generics, &hir::Inherited, arg_names,
None)?;
self.s.word(";")?;
}
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
self.head("")?;
- self.print_method_sig(ti.name, sig, &ti.generics, &hir::Inherited, &[],
+ self.print_method_sig(ti.ident, sig, &ti.generics, &hir::Inherited, &[],
Some(body))?;
self.nbsp()?;
self.end()?; // need to close a box
self.ann.nested(self, Nested::Body(body))?;
}
hir::TraitItemKind::Type(ref bounds, ref default) => {
- self.print_associated_type(ti.name,
+ self.print_associated_type(ti.ident,
Some(bounds),
default.as_ref().map(|ty| &**ty))?;
}
match ii.node {
hir::ImplItemKind::Const(ref ty, expr) => {
- self.print_associated_const(ii.name, &ty, Some(expr), &ii.vis)?;
+ self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis)?;
}
hir::ImplItemKind::Method(ref sig, body) => {
self.head("")?;
- self.print_method_sig(ii.name, sig, &ii.generics, &ii.vis, &[], Some(body))?;
+ self.print_method_sig(ii.ident, sig, &ii.generics, &ii.vis, &[], Some(body))?;
self.nbsp()?;
self.end()?; // need to close a box
self.end()?; // need to close a box
self.ann.nested(self, Nested::Body(body))?;
}
hir::ImplItemKind::Type(ref ty) => {
- self.print_associated_type(ii.name, None, Some(ty))?;
+ self.print_associated_type(ii.ident, None, Some(ty))?;
}
}
self.ann.post(self, NodeSubItem(ii.id))
}
pub fn print_name(&mut self, name: ast::Name) -> io::Result<()> {
- self.print_ident(name.to_ident())
+ self.print_ident(ast::Ident::with_empty_ctxt(name))
}
pub fn print_for_decl(&mut self, loc: &hir::Local, coll: &hir::Expr) -> io::Result<()> {
let hir::TraitItem {
id: _,
hir_id: _,
- name,
+ ident,
ref attrs,
ref generics,
ref node,
} = *self;
hcx.hash_hir_item_like(|hcx| {
- name.hash_stable(hcx, hasher);
+ ident.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
generics.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
let hir::ImplItem {
id: _,
hir_id: _,
- name,
+ ident,
ref vis,
defaultness,
ref attrs,
} = *self;
hcx.hash_hir_item_like(|hcx| {
- name.hash_stable(hcx, hasher);
+ ident.hash_stable(hcx, hasher);
vis.hash_stable(hcx, hasher);
defaultness.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
impl_stable_hash_for!(struct hir::TraitItemRef {
id,
- name,
+ ident,
kind,
span,
defaultness
impl_stable_hash_for!(struct hir::ImplItemRef {
id,
- name,
+ ident,
kind,
span,
vis,
impl_stable_hash_for!(struct ty::AssociatedItem {
def_id,
- name,
+ ident,
kind,
vis,
defaultness,
infer::LateBoundRegion(_, br, infer::AssocTypeProjection(def_id)) => format!(
" for lifetime parameter {}in trait containing associated type `{}`",
br_string(br),
- self.tcx.associated_item(def_id).name
+ self.tcx.associated_item(def_id).ident
),
infer::EarlyBoundRegion(_, name) => format!(" for lifetime parameter `{}`", name),
infer::BoundRegionInCoherence(name) => {
if !self.symbol_is_live(impl_item.id, None) {
self.warn_dead_code(impl_item.id,
impl_item.span,
- impl_item.name,
+ impl_item.ident.name,
"associated const",
"used");
}
hir::ImplItemKind::Method(_, body_id) => {
if !self.symbol_is_live(impl_item.id, None) {
let span = self.tcx.sess.codemap().def_span(impl_item.span);
- self.warn_dead_code(impl_item.id, span, impl_item.name, "method", "used");
+ self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used");
}
self.visit_nested_body(body_id)
}
for impl_item_ref in impl_item_refs {
let impl_item = self.tcx.hir.impl_item(impl_item_ref.id);
let trait_item_def_id = self.tcx.associated_items(trait_did)
- .find(|item| item.name == impl_item.name).map(|item| item.def_id);
+ .find(|item| item.ident.name == impl_item.ident.name)
+ .map(|item| item.def_id);
if let Some(def_id) = trait_item_def_id {
// Pass `None` to skip deprecation warnings.
self.tcx.check_stability(def_id, None, impl_item.span);
.filter(|item| item.kind == ty::AssociatedKind::Method)
.filter_map(|item| {
self.object_safety_violation_for_method(trait_def_id, &item)
- .map(|code| ObjectSafetyViolation::Method(item.name, code))
+ .map(|code| ObjectSafetyViolation::Method(item.ident.name, code))
}).filter(|violation| {
if let ObjectSafetyViolation::Method(_,
MethodViolationCode::WhereClauseReferencesSelf(span)) = violation {
violations.extend(self.associated_items(trait_def_id)
.filter(|item| item.kind == ty::AssociatedKind::Const)
- .map(|item| ObjectSafetyViolation::AssociatedConst(item.name)));
+ .map(|item| ObjectSafetyViolation::AssociatedConst(item.ident.name)));
debug!("object_safety_violations_for_trait(trait_def_id={:?}) = {:?}",
trait_def_id,
use mir::interpret::{GlobalId};
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
use syntax::ast::Ident;
-use syntax::symbol::Symbol;
use ty::subst::{Subst, Substs};
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder};
obligation.predicate.self_ty(),
gen_sig)
.map_bound(|(trait_ref, yield_ty, return_ty)| {
- let name = tcx.associated_item(obligation.predicate.item_def_id).name;
- let ty = if name == Symbol::intern("Return") {
+ let name = tcx.associated_item(obligation.predicate.item_def_id).ident.name;
+ let ty = if name == "Return" {
return_ty
- } else if name == Symbol::intern("Yield") {
+ } else if name == "Yield" {
yield_ty
} else {
bug!()
// checker method `check_impl_items_against_trait`, so here we
// just return TyError.
debug!("confirm_impl_candidate: no associated type {:?} for {:?}",
- assoc_ty.item.name,
+ assoc_ty.item.ident,
obligation.predicate);
tcx.types.err
} else {
-> specialization_graph::NodeItem<ty::AssociatedItem>
{
let tcx = selcx.tcx();
- let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).name;
+ let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).ident;
let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id;
let trait_def = tcx.trait_def(trait_def_id);
let impl_node = specialization_graph::Node::Impl(impl_def_id);
for item in impl_node.items(tcx) {
if item.kind == ty::AssociatedKind::Type &&
- tcx.hygienic_eq(item.name.to_ident(), assoc_ty_name.to_ident(), trait_def_id) {
+ tcx.hygienic_eq(item.ident, assoc_ty_name, trait_def_id) {
return specialization_graph::NodeItem {
node: specialization_graph::Node::Impl(impl_def_id),
item,
let trait_def = tcx.trait_def(trait_def_id);
let ancestors = trait_def.ancestors(tcx, impl_data.impl_def_id);
- match ancestors.defs(tcx, item.name, item.kind, trait_def_id).next() {
+ match ancestors.defs(tcx, item.ident, item.kind, trait_def_id).next() {
Some(node_item) => {
let substs = tcx.infer_ctxt().enter(|infcx| {
let param_env = ty::ParamEnv::reveal_all();
use ty::{self, TyCtxt, TypeFoldable};
use ty::fast_reject::{self, SimplifiedType};
use rustc_data_structures::sync::Lrc;
-use syntax::ast::Name;
+use syntax::ast::Ident;
use util::captures::Captures;
use util::nodemap::{DefIdMap, FxHashMap};
pub fn defs(
self,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
- trait_item_name: Name,
+ trait_item_name: Ident,
trait_item_kind: ty::AssociatedKind,
trait_def_id: DefId,
) -> impl Iterator<Item = NodeItem<ty::AssociatedItem>> + Captures<'gcx> + Captures<'tcx> + 'a {
self.flat_map(move |node| {
node.items(tcx).filter(move |impl_item| {
impl_item.kind == trait_item_kind &&
- tcx.hygienic_eq(impl_item.name.to_ident(), trait_item_name.to_ident(), trait_def_id)
+ tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id)
}).map(move |item| NodeItem { node: node, item: item })
})
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct AssociatedItem {
pub def_id: DefId,
- pub name: Name,
+ pub ident: Ident,
pub kind: AssociatedKind,
pub vis: Visibility,
pub defaultness: hir::Defaultness,
// regions just fine, showing `fn(&MyType)`.
format!("{}", tcx.fn_sig(self.def_id).skip_binder())
}
- ty::AssociatedKind::Type => format!("type {};", self.name.to_string()),
+ ty::AssociatedKind::Type => format!("type {};", self.ident),
ty::AssociatedKind::Const => {
- format!("const {}: {:?};", self.name.to_string(), tcx.type_of(self.def_id))
+ format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id))
}
}
}
};
AssociatedItem {
- name: trait_item_ref.name,
+ ident: trait_item_ref.ident,
kind,
// Visibility of trait items is inherited from their traits.
vis: Visibility::from_hir(parent_vis, trait_item_ref.id.node_id, self),
hir::AssociatedItemKind::Type => (ty::AssociatedKind::Type, false),
};
- ty::AssociatedItem {
- name: impl_item_ref.name,
+ AssociatedItem {
+ ident: impl_item_ref.ident,
kind,
// Visibility of trait impl items doesn't matter.
vis: ty::Visibility::from_hir(&impl_item_ref.vis, impl_item_ref.id.node_id, self),
pub fn associated_items(
self,
def_id: DefId,
- ) -> impl Iterator<Item = ty::AssociatedItem> + 'a {
+ ) -> impl Iterator<Item = AssociatedItem> + 'a {
let def_ids = self.associated_item_def_ids(def_id);
Box::new((0..def_ids.len()).map(move |i| self.associated_item(def_ids[i])))
- as Box<dyn Iterator<Item = ty::AssociatedItem> + 'a>
+ as Box<dyn Iterator<Item = AssociatedItem> + 'a>
}
/// Returns true if the impls are the same polarity and are implementing
) -> ProjectionTy<'tcx> {
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
item.kind == ty::AssociatedKind::Type &&
- tcx.hygienic_eq(item_name, item.name.to_ident(), trait_ref.def_id)
+ tcx.hygienic_eq(item_name, item.ident, trait_ref.def_id)
}).unwrap().def_id;
ProjectionTy {
ty::tls::with(|tcx|
print!(f, self,
write("{}=",
- tcx.associated_item(projection.projection_ty.item_def_id).name),
+ tcx.associated_item(projection.projection_ty.item_def_id).ident),
print_display(projection.ty))
)?;
}
// parameterized(f, self.substs, self.item_def_id, &[])
// (which currently ICEs).
let (trait_ref, item_name) = ty::tls::with(|tcx|
- (self.trait_ref(tcx), tcx.associated_item(self.item_def_id).name)
+ (self.trait_ref(tcx), tcx.associated_item(self.item_def_id).ident)
);
print!(f, cx, print_debug(trait_ref), write("::{}", item_name))
}
let mut cfgs = Vec::new();
for &(name, ref value) in sess.parse_sess.config.iter() {
let gated_cfg = GatedCfg::gate(&ast::MetaItem {
- ident: ast::Path::from_ident(name.to_ident()),
+ ident: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)),
node: ast::MetaItemKind::Word,
span: DUMMY_SP,
});
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(ref pnames)) = item.node {
self.check_snake_case(cx,
"trait method",
- &item.name.as_str(),
+ &item.ident.as_str(),
Some(item.span));
for param_name in pnames {
self.check_snake_case(cx, "variable", ¶m_name.as_str(), Some(param_name.span));
fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) {
match ti.node {
hir::TraitItemKind::Const(..) => {
- NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ti.name, ti.span);
+ NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
+ ti.ident.name, ti.span);
}
_ => {}
}
fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
match ii.node {
hir::ImplItemKind::Const(..) => {
- NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ii.name, ii.span);
+ NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
+ ii.ident.name, ii.span);
}
_ => {}
}
let container = ty::ImplContainer(vtable_impl.impl_def_id);
// It matches if it comes from the same impl,
// and has the same method name.
- container == method.container && callee_item.name == method.name
+ container == method.container &&
+ callee_item.ident.name == method.ident.name
}
// There's no way to know if this call is
};
ty::AssociatedItem {
- name: name.as_symbol(),
+ ident: Ident::from_interned_str(name),
kind,
vis: item.visibility.decode(self),
defaultness: container.defaultness(),
let method_name = Symbol::intern(method_name);
let substs = self.tcx.mk_substs_trait(self_ty, params);
for item in self.tcx.associated_items(trait_def_id) {
- if item.kind == ty::AssociatedKind::Method && item.name == method_name {
+ if item.kind == ty::AssociatedKind::Method && item.ident.name == method_name {
let method_ty = self.tcx.type_of(item.def_id);
let method_ty = method_ty.subst(self.tcx, substs);
return (method_ty,
if let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) {
let overridden_methods: FxHashSet<_> =
impl_item_refs.iter()
- .map(|iiref| iiref.name)
+ .map(|iiref| iiref.ident.modern())
.collect();
for method in tcx.provided_trait_methods(trait_ref.def_id) {
- if overridden_methods.contains(&method.name) {
+ if overridden_methods.contains(&method.ident.modern()) {
continue;
}
for projection in projections {
let projection = projection.skip_binder();
- let name = &self.tcx.associated_item(projection.item_def_id).name.as_str();
+ let name = &self.tcx.associated_item(projection.item_def_id).ident.as_str();
output.push_str(name);
output.push_str("=");
self.push_type_name(projection.ty, output);
match path.get(1) {
// If this import looks like `crate::...` it's already good
- Some(name) if name.name == keywords::Crate.name() => return,
+ Some(ident) if ident.name == keywords::Crate.name() => return,
// Otherwise go below to see if it's an extern crate
Some(_) => {}
// If the path has length one (and it's `CrateRoot` most likely)
sig: &'l ast::MethodSig,
body: Option<&'l ast::Block>,
id: ast::NodeId,
- name: ast::Ident,
+ ident: ast::Ident,
generics: &'l ast::Generics,
vis: ast::Visibility,
span: Span,
) {
- debug!("process_method: {}:{}", id, name);
+ debug!("process_method: {}:{}", id, ident);
- if let Some(mut method_data) = self.save_ctxt.get_method_data(id, name.name, span) {
+ if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident.name, span) {
let sig_str = ::make_signature(&sig.decl, &generics);
if body.is_some() {
self.nest_tables(
self.process_generic_params(&generics, span, &method_data.qualname, id);
method_data.value = sig_str;
- method_data.sig = sig::method_signature(id, name, generics, sig, &self.save_ctxt);
+ method_data.sig = sig::method_signature(id, ident, generics, sig, &self.save_ctxt);
self.dumper.dump_def(&access_from!(self.save_ctxt, vis, id), method_data);
}
qualname.push_str(&self.tcx.item_path_str(def_id));
self.tcx
.associated_items(def_id)
- .find(|item| item.name == name)
+ .find(|item| item.ident.name == name)
.map(|item| decl_id = Some(item.def_id));
}
qualname.push_str(">");
let ti = self.tcx.associated_item(decl_id);
self.tcx
.associated_items(ti.container.id())
- .find(|item| item.name == ti.name && item.defaultness.has_value())
+ .find(|item| item.ident.name == ti.ident.name &&
+ item.defaultness.has_value())
.map(|item| item.def_id)
} else {
None
let hypotheses = vec![trait_implemented];
// `<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm>`
- let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name.to_ident());
+ let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident);
// `Normalize(<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm> -> T)`
let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty });
{
self.tcx().associated_items(trait_def_id).any(|item| {
item.kind == ty::AssociatedKind::Type &&
- self.tcx().hygienic_eq(assoc_name, item.name.to_ident(), trait_def_id)
+ self.tcx().hygienic_eq(assoc_name, item.ident, trait_def_id)
})
}
let (assoc_ident, def_scope) =
tcx.adjust_ident(binding.item_name, candidate.def_id(), ref_id);
let assoc_ty = tcx.associated_items(candidate.def_id()).find(|i| {
- i.kind == ty::AssociatedKind::Type && i.name.to_ident() == assoc_ident
+ i.kind == ty::AssociatedKind::Type && i.ident.modern() == assoc_ident
}).expect("missing associated type");
if !assoc_ty.vis.is_accessible_from(def_scope, tcx) {
let trait_def_id = assoc_item.container.id();
struct_span_err!(tcx.sess, span, E0191,
"the value of the associated type `{}` (from the trait `{}`) must be specified",
- assoc_item.name,
+ assoc_item.ident,
tcx.item_path_str(trait_def_id))
.span_label(span, format!(
- "missing associated type `{}` value", assoc_item.name))
+ "missing associated type `{}` value", assoc_item.ident))
.emit();
}
for bound in bounds {
let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| {
item.kind == ty::AssociatedKind::Type &&
- self.tcx().hygienic_eq(assoc_name, item.name.to_ident(), bound.def_id())
+ self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id())
})
.and_then(|item| self.tcx().hir.span_if_local(item.def_id));
let (assoc_ident, def_scope) = tcx.adjust_ident(assoc_name, trait_did, ref_id);
let item = tcx.associated_items(trait_did).find(|i| {
Namespace::from(i.kind) == Namespace::Type &&
- i.name.to_ident() == assoc_ident
+ i.ident.modern() == assoc_ident
})
.expect("missing associated type");
use rustc::ty::{self, TyCtxt, TypeFoldable, Ty};
use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
use rustc_target::spec::abi;
-use syntax::symbol::Symbol;
+use syntax::ast::Ident;
use syntax_pos::Span;
use rustc::hir;
MethodCallee<'tcx>)> {
// Try the options that are least restrictive on the caller first.
for &(opt_trait_def_id, method_name, borrow) in
- &[(self.tcx.lang_items().fn_trait(), Symbol::intern("call"), true),
- (self.tcx.lang_items().fn_mut_trait(), Symbol::intern("call_mut"), true),
- (self.tcx.lang_items().fn_once_trait(), Symbol::intern("call_once"), false)] {
+ &[(self.tcx.lang_items().fn_trait(), Ident::from_str("call"), true),
+ (self.tcx.lang_items().fn_mut_trait(), Ident::from_str("call_mut"), true),
+ (self.tcx.lang_items().fn_once_trait(), Ident::from_str("call_once"), false)] {
let trait_def_id = match opt_trait_def_id {
Some(def_id) => def_id,
None => continue,
span: impl_m_span,
body_id: impl_m_node_id,
code: ObligationCauseCode::CompareImplMethodObligation {
- item_name: impl_m.name,
+ item_name: impl_m.ident.name,
impl_item_def_id: impl_m.def_id,
trait_item_def_id: trait_m.def_id,
},
cause.span(&tcx),
E0053,
"method `{}` has an incompatible type for trait",
- trait_m.name);
+ trait_m.ident);
infcx.note_type_err(&mut diag,
&cause,
E0195,
"lifetime parameters or bounds on method `{}` do not match \
the trait declaration",
- impl_m.name);
+ impl_m.ident);
err.span_label(span, "lifetimes do not match method in trait");
if let Some(sp) = tcx.hir.span_if_local(trait_m.def_id) {
err.span_label(tcx.sess.codemap().def_span(sp),
E0185,
"method `{}` has a `{}` declaration in the impl, but \
not in the trait",
- trait_m.name,
+ trait_m.ident,
self_descr);
err.span_label(impl_m_span, format!("`{}` used in impl", self_descr));
if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) {
err.span_label(span, format!("trait method declared without `{}`", self_descr));
} else {
- err.note_trait_signature(trait_m.name.to_string(),
+ err.note_trait_signature(trait_m.ident.to_string(),
trait_m.signature(&tcx));
}
err.emit();
E0186,
"method `{}` has a `{}` declaration in the trait, but \
not in the impl",
- trait_m.name,
+ trait_m.ident,
self_descr);
err.span_label(impl_m_span, format!("expected `{}` in impl", self_descr));
if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) {
err.span_label(span, format!("`{}` used in trait", self_descr));
} else {
- err.note_trait_signature(trait_m.name.to_string(),
+ err.note_trait_signature(trait_m.ident.to_string(),
trait_m.signature(&tcx));
}
err.emit();
E0049,
"method `{}` has {} type parameter{} but its trait \
declaration has {} type parameter{}",
- trait_m.name,
+ trait_m.ident,
num_impl_m_type_params,
if num_impl_m_type_params == 1 { "" } else { "s" },
num_trait_m_type_params,
E0050,
"method `{}` has {} parameter{} but the declaration in \
trait `{}` has {}",
- trait_m.name,
+ trait_m.ident,
impl_number_args,
if impl_number_args == 1 { "" } else { "s" },
tcx.item_path_str(trait_m.def_id),
format!("{} parameter", trait_number_args)
}));
} else {
- err.note_trait_signature(trait_m.name.to_string(),
+ err.note_trait_signature(trait_m.ident.to_string(),
trait_m.signature(&tcx));
}
err.span_label(impl_span,
impl_span,
E0643,
"method `{}` has incompatible signature for trait",
- trait_m.name);
+ trait_m.ident);
err.span_label(trait_span, "declaration in trait here");
match (impl_synthetic, trait_synthetic) {
// The case where the impl method uses `impl Trait` but the trait method uses
E0326,
"implemented const `{}` has an incompatible type for \
trait",
- trait_c.name);
+ trait_c.ident);
let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id);
let trait_c_span = trait_c_node_id.map(|trait_c_node_id| {
let methods = self.get_conversion_methods(expr.span, expected, checked_ty);
if let Ok(expr_text) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
let suggestions = iter::repeat(expr_text).zip(methods.iter())
- .map(|(receiver, method)| format!("{}.{}()", receiver, method.name))
+ .map(|(receiver, method)| format!("{}.{}()", receiver, method.ident))
.collect::<Vec<_>>();
if !suggestions.is_empty() {
err.span_suggestions(expr.span,
/// of this method is basically the same as confirmation.
pub fn lookup_method_in_trait(&self,
span: Span,
- m_name: ast::Name,
+ m_name: ast::Ident,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
opt_input_types: Option<&[Ty<'tcx>]>)
// type parameters or early-bound regions.
let tcx = self.tcx;
let method_item =
- self.associated_item(trait_def_id, m_name.to_ident(), Namespace::Value).unwrap();
+ self.associated_item(trait_def_id, m_name, Namespace::Value).unwrap();
let def_id = method_item.def_id;
let generics = tcx.generics_of(def_id);
assert_eq!(generics.params.len(), 0);
-> Option<ty::AssociatedItem> {
self.tcx.associated_items(def_id).find(|item| {
Namespace::from(item.kind) == ns &&
- self.tcx.hygienic_eq(item_name, item.name.to_ident(), def_id)
+ self.tcx.hygienic_eq(item_name, item.ident, def_id)
})
}
}
true
}
})
- .map(|candidate| candidate.item.name.to_ident())
+ .map(|candidate| candidate.item.ident)
.filter(|&name| set.insert(name))
.collect();
Ok(None)
} else {
let best_name = {
- let names = applicable_close_candidates.iter().map(|cand| &cand.name);
+ let names = applicable_close_candidates.iter().map(|cand| &cand.ident.name);
find_best_match_for_name(names,
&self.method_name.unwrap().as_str(),
None)
}.unwrap();
Ok(applicable_close_candidates
.into_iter()
- .find(|method| method.name == best_name))
+ .find(|method| method.ident.name == best_name))
}
})
}
let max_dist = max(name.as_str().len(), 3) / 3;
self.tcx.associated_items(def_id)
.filter(|x| {
- let dist = lev_distance(&*name.as_str(), &x.name.as_str());
+ let dist = lev_distance(&*name.as_str(), &x.ident.as_str());
Namespace::from(x.kind) == Namespace::Value && dist > 0
&& dist <= max_dist
})
}
if let Some(lev_candidate) = lev_candidate {
- err.help(&format!("did you mean `{}`?", lev_candidate.name));
+ err.help(&format!("did you mean `{}`?", lev_candidate.ident));
}
err.emit();
}
tcx.sess, impl_item.span, E0520,
"`{}` specializes an item from a parent `impl`, but \
that item is not marked `default`",
- impl_item.name);
+ impl_item.ident);
err.span_label(impl_item.span, format!("cannot specialize default item `{}`",
- impl_item.name));
+ impl_item.ident));
match tcx.span_of_impl(parent_impl) {
Ok(span) => {
err.span_label(span, "parent `impl` is here");
err.note(&format!("to specialize, `{}` in the parent `impl` must be marked `default`",
- impl_item.name));
+ impl_item.ident));
}
Err(cname) => {
err.note(&format!("parent implementation is in crate `{}`", cname));
hir::ImplItemKind::Type(_) => ty::AssociatedKind::Type
};
- let parent = ancestors.defs(tcx, trait_item.name, kind, trait_def.def_id).skip(1).next()
+ let parent = ancestors.defs(tcx, trait_item.ident, kind, trait_def.def_id).skip(1).next()
.map(|node_item| node_item.map(|parent| parent.defaultness));
if let Some(parent) = parent {
let ty_impl_item = tcx.associated_item(tcx.hir.local_def_id(impl_item.id));
let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
.find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) &&
- tcx.hygienic_eq(ty_impl_item.name.to_ident(), ac.name.to_ident(),
- impl_trait_ref.def_id))
+ tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
.or_else(|| {
// Not compatible, but needed for the error message
tcx.associated_items(impl_trait_ref.def_id)
- .find(|ac| tcx.hygienic_eq(ty_impl_item.name.to_ident(), ac.name.to_ident(),
- impl_trait_ref.def_id))
+ .find(|ac| tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
});
// Check that impl definition matches trait definition
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323,
"item `{}` is an associated const, \
which doesn't match its trait `{}`",
- ty_impl_item.name,
+ ty_impl_item.ident,
impl_trait_ref);
err.span_label(impl_item.span, "does not match trait");
// We can only get the spans from local trait definition
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324,
"item `{}` is an associated method, \
which doesn't match its trait `{}`",
- ty_impl_item.name,
+ ty_impl_item.ident,
impl_trait_ref);
err.span_label(impl_item.span, "does not match trait");
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325,
"item `{}` is an associated type, \
which doesn't match its trait `{}`",
- ty_impl_item.name,
+ ty_impl_item.ident,
impl_trait_ref);
err.span_label(impl_item.span, "does not match trait");
if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) {
let associated_type_overridden = overridden_associated_type.is_some();
for trait_item in tcx.associated_items(impl_trait_ref.def_id) {
let is_implemented = trait_def.ancestors(tcx, impl_id)
- .defs(tcx, trait_item.name, trait_item.kind, impl_trait_ref.def_id)
+ .defs(tcx, trait_item.ident, trait_item.kind, impl_trait_ref.def_id)
.next()
.map(|node_item| !node_item.node.is_from_trait())
.unwrap_or(false);
if !trait_item.defaultness.has_value() {
missing_items.push(trait_item);
} else if associated_type_overridden {
- invalidated_items.push(trait_item.name);
+ invalidated_items.push(trait_item.ident);
}
}
}
let mut err = struct_span_err!(tcx.sess, impl_span, E0046,
"not all trait items implemented, missing: `{}`",
missing_items.iter()
- .map(|trait_item| trait_item.name.to_string())
+ .map(|trait_item| trait_item.ident.to_string())
.collect::<Vec<_>>().join("`, `"));
err.span_label(impl_span, format!("missing `{}` in implementation",
missing_items.iter()
- .map(|trait_item| trait_item.name.to_string())
+ .map(|trait_item| trait_item.ident.to_string())
.collect::<Vec<_>>().join("`, `")));
for trait_item in missing_items {
if let Some(span) = tcx.hir.span_if_local(trait_item.def_id) {
- err.span_label(span, format!("`{}` from trait", trait_item.name));
+ err.span_label(span, format!("`{}` from trait", trait_item.ident));
} else {
- err.note_trait_signature(trait_item.name.to_string(),
+ err.note_trait_signature(trait_item.ident.to_string(),
trait_item.signature(&tcx));
}
}
span_err!(tcx.sess, invalidator.span, E0399,
"the following trait items need to be reimplemented \
as `{}` was overridden: `{}`",
- invalidator.name,
+ invalidator.ident,
invalidated_items.iter()
.map(|name| name.to_string())
.collect::<Vec<_>>().join("`, `"))
None
}
- fn resolve_place_op(&self, op: PlaceOp, is_mut: bool) -> (Option<DefId>, Symbol) {
+ fn resolve_place_op(&self, op: PlaceOp, is_mut: bool) -> (Option<DefId>, ast::Ident) {
let (tr, name) = match (op, is_mut) {
(PlaceOp::Deref, false) =>
(self.tcx.lang_items().deref_trait(), "deref"),
(PlaceOp::Index, true) =>
(self.tcx.lang_items().index_mut_trait(), "index_mut"),
};
- (tr, Symbol::intern(name))
+ (tr, ast::Ident::from_str(name))
}
fn try_overloaded_place_op(&self,
use rustc::infer::type_variable::TypeVariableOrigin;
use errors;
use syntax_pos::Span;
-use syntax::symbol::Symbol;
+use syntax::ast::Ident;
use rustc::hir;
impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
trait_did);
let method = trait_did.and_then(|trait_did| {
- let opname = Symbol::intern(opname);
+ let opname = Ident::from_str(opname);
self.lookup_method_in_trait(span, opname, trait_did, lhs_ty, Some(other_tys))
});
let name_and_namespace = |def_id| {
let item = self.tcx.associated_item(def_id);
- (item.name, Namespace::from(item.kind))
+ (item.ident, Namespace::from(item.kind))
};
let impl_items1 = self.tcx.associated_item_def_ids(impl1);
hir::ImplItemKind::Type(_) => &mut seen_type_items,
_ => &mut seen_value_items,
};
- match seen_items.entry(impl_item.name) {
+ match seen_items.entry(impl_item.ident.modern()) {
Occupied(entry) => {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201,
"duplicate definitions with name `{}`:",
- impl_item.name);
+ impl_item.ident);
err.span_label(*entry.get(),
format!("previous definition of `{}` here",
- impl_item.name));
+ impl_item.ident));
err.span_label(impl_item.span, "duplicate definition");
err.emit();
}
let provided = trait_.def_id().map(|did| {
tcx.provided_trait_methods(did)
.into_iter()
- .map(|meth| meth.name.to_string())
+ .map(|meth| meth.ident.to_string())
.collect()
}).unwrap_or(FxHashSet());
Def::Struct(did) | Def::Union(did) | Def::Enum(did) | Def::TyAlias(did) => {
let item = cx.tcx.inherent_impls(did).iter()
.flat_map(|imp| cx.tcx.associated_items(*imp))
- .find(|item| item.name == item_name);
+ .find(|item| item.ident.name == item_name);
if let Some(item) = item {
let out = match item.kind {
ty::AssociatedKind::Method if is_val => "method",
Def::Trait(did) => {
let item = cx.tcx.associated_item_def_ids(did).iter()
.map(|item| cx.tcx.associated_item(*item))
- .find(|item| item.name == item_name);
+ .find(|item| item.ident.name == item_name);
if let Some(item) = item {
let kind = match item.kind {
ty::AssociatedKind::Const if is_val => "associatedconstant",
GenericBound::Outlives(_) => panic!("cleaning a trait got a lifetime"),
};
Type::QPath {
- name: cx.tcx.associated_item(self.item_def_id).name.clean(cx),
+ name: cx.tcx.associated_item(self.item_def_id).ident.name.clean(cx),
self_type: box self.self_ty().clean(cx),
trait_: box trait_
}
}
};
Item {
- name: Some(self.name.clean(cx)),
+ name: Some(self.ident.name.clean(cx)),
attrs: self.attrs.clean(cx),
source: self.span.clean(cx),
def_id: cx.tcx.hir.local_def_id(self.id),
}, true),
};
Item {
- name: Some(self.name.clean(cx)),
+ name: Some(self.ident.name.clean(cx)),
source: self.span.clean(cx),
attrs: self.attrs.clean(cx),
def_id: cx.tcx.hir.local_def_id(self.id),
}
}
ty::AssociatedKind::Type => {
- let my_name = self.name.clean(cx);
+ let my_name = self.ident.name.clean(cx);
if let ty::TraitContainer(did) = self.container {
// When loading a cross-crate associated type, the bounds for this type
};
Item {
- name: Some(self.name.clean(cx)),
+ name: Some(self.ident.name.clean(cx)),
visibility,
stability: get_stability(cx, self.def_id),
deprecation: get_deprecation(cx, self.def_id),
let mut bindings = vec![];
for pb in obj.projection_bounds() {
bindings.push(TypeBinding {
- name: cx.tcx.associated_item(pb.item_def_id()).name.clean(cx),
+ name: cx.tcx.associated_item(pb.item_def_id()).ident.name.clean(cx),
ty: pb.skip_binder().ty.clean(cx)
});
}
if proj.projection_ty.trait_ref(cx.tcx) == *trait_ref.skip_binder() {
Some(TypeBinding {
name: cx.tcx.associated_item(proj.projection_ty.item_def_id)
- .name.clean(cx),
+ .ident.name.clean(cx),
ty: proj.ty.clean(cx),
})
} else {
let provided = trait_.def_id().map(|did| {
cx.tcx.provided_trait_methods(did)
.into_iter()
- .map(|meth| meth.name.to_string())
+ .map(|meth| meth.ident.to_string())
.collect()
}).unwrap_or(FxHashSet());
}
fn visit_trait_item(&mut self, item: &'hir hir::TraitItem) {
- self.visit_testable(item.name.to_string(), &item.attrs, |this| {
+ self.visit_testable(item.ident.to_string(), &item.attrs, |this| {
intravisit::walk_trait_item(this, item);
});
}
fn visit_impl_item(&mut self, item: &'hir hir::ImplItem) {
- self.visit_testable(item.name.to_string(), &item.attrs, |this| {
+ self.visit_testable(item.ident.to_string(), &item.attrs, |this| {
intravisit::walk_impl_item(this, item);
});
}
use GLOBALS;
use Span;
use edition::Edition;
-use symbol::{Ident, Symbol};
+use symbol::Symbol;
use serialize::{Encodable, Decodable, Encoder, Decoder};
use std::collections::HashMap;
marks: Vec<MarkData>,
syntax_contexts: Vec<SyntaxContextData>,
markings: HashMap<(SyntaxContext, Mark), SyntaxContext>,
- gensym_to_ctxt: HashMap<Symbol, Span>,
default_edition: Edition,
}
modern: SyntaxContext(0),
}],
markings: HashMap::new(),
- gensym_to_ctxt: HashMap::new(),
default_edition: Edition::Edition2015,
}
}
Ok(SyntaxContext::empty()) // FIXME(jseyfried) intercrate hygiene
}
}
-
-impl Symbol {
- pub fn from_ident(ident: Ident) -> Symbol {
- HygieneData::with(|data| {
- let gensym = ident.name.gensymed();
- data.gensym_to_ctxt.insert(gensym, ident.span);
- gensym
- })
- }
-
- pub fn to_ident(self) -> Ident {
- HygieneData::with(|data| {
- match data.gensym_to_ctxt.get(&self) {
- Some(&span) => Ident::new(self.interned(), span),
- None => Ident::with_empty_ctxt(self),
- }
- })
- }
-}