});
if let hir::ItemImpl(..) = item.node {
- let (ident, did) = (item.name, item.id);
+ let (name, did) = (item.name, item.id);
debug!("(encoding info for module) ... encoding impl {} ({}/{})",
- ident,
+ name,
did, ecx.tcx.map.node_to_string(did));
rbml_w.wr_tagged_u64(tag_mod_impl, def_to_u64(DefId::local(did)));
}
'[' => {
let def = self.parse_def(RegionParameter);
- let ident = token::str_to_ident(&self.parse_str(']'));
- ty::BrNamed(def, ident.name)
+ let name = token::intern(&self.parse_str(']'));
+ ty::BrNamed(def, name)
}
'f' => {
let id = self.parse_u32();
assert_eq!(self.next(), '|');
let index = self.parse_u32();
assert_eq!(self.next(), '|');
- let nm = token::str_to_ident(&self.parse_str(']'));
+ let name = token::intern(&self.parse_str(']'));
ty::ReEarlyBound(ty::EarlyBoundRegion {
param_id: node_id,
space: space,
index: index,
- name: nm.name
+ name: name
})
}
'f' => {
ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy {
trait_ref: self.parse_trait_ref(),
- item_name: token::str_to_ident(&self.parse_str('|')).name,
+ item_name: token::intern(&self.parse_str('|')),
},
ty: self.parse_ty(),
}
}
hir::ExprBreak(label) => {
- let loop_scope = self.find_scope(expr, label.map(|l| l.node));
+ let loop_scope = self.find_scope(expr, label.map(|l| l.node.name));
let b = self.add_ast_node(expr.id, &[pred]);
self.add_exiting_edge(expr, b,
loop_scope, loop_scope.break_index);
}
hir::ExprAgain(label) => {
- let loop_scope = self.find_scope(expr, label.map(|l| l.node));
+ let loop_scope = self.find_scope(expr, label.map(|l| l.node.name));
let a = self.add_ast_node(expr.id, &[pred]);
self.add_exiting_edge(expr, a,
loop_scope, loop_scope.continue_index);
fn find_scope(&self,
expr: &hir::Expr,
- label: Option<ast::Ident>) -> LoopScope {
+ label: Option<ast::Name>) -> LoopScope {
if label.is_none() {
return *self.loop_scopes.last().unwrap();
}
ps: &mut pprust::State,
node: pprust::AnnNode) -> io::Result<()> {
let id = match node {
- pprust::NodeIdent(_) | pprust::NodeName(_) => 0,
+ pprust::NodeName(_) => 0,
pprust::NodeExpr(expr) => expr.id,
pprust::NodeBlock(blk) => blk.id,
pprust::NodeItem(_) | pprust::NodeSubItem(_) => 0,
},
None => None
};
- let (fn_decl, generics, unsafety, constness, ident, expl_self, span)
+ let (fn_decl, generics, unsafety, constness, name, expl_self, span)
= node_inner.expect("expect item fn");
let rebuilder = Rebuilder::new(self.tcx, fn_decl, expl_self,
generics, same_regions, &life_giver);
let (fn_decl, expl_self, generics) = rebuilder.rebuild();
- self.give_expl_lifetime_param(&fn_decl, unsafety, constness, ident,
+ self.give_expl_lifetime_param(&fn_decl, unsafety, constness, name,
expl_self.as_ref(), &generics, span);
}
}
names.push(lt_name);
}
names.sort();
- let name = token::str_to_ident(&names[0]).name;
+ let name = token::intern(&names[0]);
return (name_to_dummy_lifetime(name), Kept);
}
return (self.life_giver.give_lifetime(), Fresh);
let mut s = String::from("'");
s.push_str(&num_to_string(self.counter.get()));
if !self.taken.contains(&s) {
- lifetime = name_to_dummy_lifetime(
- token::str_to_ident(&s[..]).name);
+ lifetime = name_to_dummy_lifetime(token::intern(&s[..]));
self.generated.borrow_mut().push(lifetime);
break;
}
&*arg.pat,
|_bm, arg_id, _x, path1| {
debug!("adding argument {}", arg_id);
- let name = path1.node.name;
+ let name = path1.node;
fn_maps.add_variable(Arg(arg_id, name));
})
};
fn visit_local(ir: &mut IrMaps, local: &hir::Local) {
pat_util::pat_bindings(&ir.tcx.def_map, &*local.pat, |_, p_id, sp, path1| {
debug!("adding local variable {}", p_id);
- let name = path1.node.name;
+ let name = path1.node;
ir.add_live_node_for_node(p_id, VarDefNode(sp));
ir.add_variable(Local(LocalInfo {
id: p_id,
pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
debug!("adding local variable {} from match with bm {:?}",
p_id, bm);
- let name = path1.node.name;
+ let name = path1.node;
ir.add_live_node_for_node(p_id, VarDefNode(sp));
ir.add_variable(Local(LocalInfo {
id: p_id,
}
fn find_loop_scope(&self,
- opt_label: Option<ast::Ident>,
+ opt_label: Option<ast::Name>,
id: NodeId,
sp: Span)
-> NodeId {
hir::ExprBreak(opt_label) => {
// Find which label this break jumps to
- let sc = self.find_loop_scope(opt_label.map(|l| l.node), expr.id, expr.span);
+ let sc = self.find_loop_scope(opt_label.map(|l| l.node.name), expr.id, expr.span);
// Now that we know the label we're going to,
// look it up in the break loop nodes table
hir::ExprAgain(opt_label) => {
// Find which label this expr continues to
- let sc = self.find_loop_scope(opt_label.map(|l| l.node), expr.id, expr.span);
+ let sc = self.find_loop_scope(opt_label.map(|l| l.node.name), expr.id, expr.span);
// Now that we know the label we're going to,
// look it up in the continue loop nodes table
|_bm, p_id, sp, path1| {
let var = self.variable(p_id, sp);
// Ignore unused self.
- let ident = path1.node;
- if ident.name != special_idents::self_.name {
+ let name = path1.node;
+ if name != special_idents::self_.name {
self.warn_about_unused(sp, p_id, entry_ln, var);
}
})
use syntax::ast;
use rustc_front::hir;
use rustc_front::util::walk_pat;
-use syntax::codemap::{Span, Spanned, DUMMY_SP};
+use syntax::codemap::{respan, Span, Spanned, DUMMY_SP};
-pub type PatIdMap = FnvHashMap<ast::Ident, ast::NodeId>;
+pub type PatIdMap = FnvHashMap<ast::Name, ast::NodeId>;
// This is used because same-named variables in alternative patterns need to
// use the NodeId of their namesake in the first pattern.
/// Call `it` on every "binding" in a pattern, e.g., on `a` in
/// `match foo() { Some(a) => (), None => () }`
pub fn pat_bindings<I>(dm: &DefMap, pat: &hir::Pat, mut it: I) where
+ I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<ast::Name>),
+{
+ walk_pat(pat, |p| {
+ match p.node {
+ hir::PatIdent(binding_mode, ref pth, _) if pat_is_binding(dm, p) => {
+ it(binding_mode, p.id, p.span, &respan(pth.span, pth.node.name));
+ }
+ _ => {}
+ }
+ true
+ });
+}
+
+pub fn pat_bindings_hygienic<I>(dm: &DefMap, pat: &hir::Pat, mut it: I) where
I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<ast::Ident>),
{
walk_pat(pat, |p| {
match p.node {
hir::PatIdent(binding_mode, ref pth, _) if pat_is_binding(dm, p) => {
- it(binding_mode, p.id, p.span, pth);
+ it(binding_mode, p.id, p.span, &respan(pth.span, pth.node));
}
_ => {}
}
contains_bindings
}
-pub fn simple_identifier<'a>(pat: &'a hir::Pat) -> Option<&'a ast::Ident> {
+pub fn simple_name<'a>(pat: &'a hir::Pat) -> Option<ast::Name> {
match pat.node {
hir::PatIdent(hir::BindByValue(_), ref path1, None) => {
- Some(&path1.node)
+ Some(path1.node.name)
}
_ => {
None
trait_ref_hack: bool,
// List of labels in the function/method currently under analysis.
- labels_in_fn: Vec<(ast::Ident, Span)>,
+ labels_in_fn: Vec<(ast::Name, Span)>,
}
enum ScopeChain<'a> {
struct GatherLabels<'a> {
sess: &'a Session,
scope: Scope<'a>,
- labels_in_fn: &'a mut Vec<(ast::Ident, Span)>,
+ labels_in_fn: &'a mut Vec<(ast::Name, Span)>,
}
let mut gather = GatherLabels {
if let Some(label) = expression_label(ex) {
for &(prior, prior_span) in &self.labels_in_fn[..] {
// FIXME (#24278): non-hygienic comparison
- if label.name == prior.name {
+ if label == prior {
signal_shadowing_problem(self.sess,
- label.name,
+ label,
original_label(prior_span),
shadower_label(ex.span));
}
}
}
- fn expression_label(ex: &hir::Expr) -> Option<ast::Ident> {
+ fn expression_label(ex: &hir::Expr) -> Option<ast::Name> {
match ex.node {
hir::ExprWhile(_, _, Some(label)) |
- hir::ExprLoop(_, Some(label)) => Some(label),
+ hir::ExprLoop(_, Some(label)) => Some(label.name),
_ => None,
}
}
fn check_if_label_shadows_lifetime<'a>(sess: &'a Session,
mut scope: Scope<'a>,
- label: ast::Ident,
+ label: ast::Name,
label_span: Span) {
loop {
match *scope {
LateScope(lifetimes, s) => {
for lifetime_def in lifetimes {
// FIXME (#24278): non-hygienic comparison
- if label.name == lifetime_def.lifetime.name {
+ if label == lifetime_def.lifetime.name {
signal_shadowing_problem(
sess,
- label.name,
+ label,
original_lifetime(&lifetime_def.lifetime),
shadower_label(label_span));
return;
{
for &(label, label_span) in &self.labels_in_fn {
// FIXME (#24278): non-hygienic comparison
- if lifetime.name == label.name {
+ if lifetime.name == label {
signal_shadowing_problem(self.sess,
lifetime.name,
original_label(label_span),
let pat_span_path_opt = match move_pat.node {
hir::PatIdent(_, ref path1, _) => {
Some(MoveSpanAndPath{span: move_pat.span,
- ident: path1.node})
+ name: path1.node.name})
},
_ => None,
};
#[derive(Clone)]
pub struct MoveSpanAndPath {
pub span: codemap::Span,
- pub ident: ast::Ident
+ pub name: ast::Name,
}
pub struct GroupedMoveErrors<'tcx> {
let mut is_first_note = true;
for move_to in &error.move_to_places {
note_move_destination(bccx, move_to.span,
- &move_to.ident, is_first_note);
+ move_to.name, is_first_note);
is_first_note = false;
}
}
fn note_move_destination(bccx: &BorrowckCtxt,
move_to_span: codemap::Span,
- pat_ident: &ast::Ident,
+ pat_name: ast::Name,
is_first_note: bool) {
- let pat_name = pprust::ident_to_string(pat_ident);
+ let pat_name = pprust::name_to_string(pat_name);
if is_first_note {
bccx.span_note(
move_to_span,
s: &mut pprust_hir::State,
node: pprust_hir::AnnNode) -> io::Result<()> {
match node {
- pprust_hir::NodeIdent(_) | pprust_hir::NodeName(_) => Ok(()),
-
+ pprust_hir::NodeName(_) => Ok(()),
pprust_hir::NodeItem(item) => {
try!(pp::space(&mut s.s));
s.synth_comment(item.id.to_string())
pub fn noop_fold_view_path<T: Folder>(view_path: P<ViewPath>, fld: &mut T) -> P<ViewPath> {
view_path.map(|Spanned {node, span}| Spanned {
node: match node {
- ViewPathSimple(ident, path) => {
- ViewPathSimple(ident, fld.fold_path(path))
+ ViewPathSimple(name, path) => {
+ ViewPathSimple(name, fld.fold_path(path))
}
ViewPathGlob(path) => {
ViewPathGlob(fld.fold_path(path))
-> ExplicitSelf_ {
match es {
SelfStatic | SelfValue(_) => es,
- SelfRegion(lifetime, m, ident) => {
- SelfRegion(fld.fold_opt_lifetime(lifetime), m, ident)
+ SelfRegion(lifetime, m, name) => {
+ SelfRegion(fld.fold_opt_lifetime(lifetime), m, name)
}
- SelfExplicit(typ, ident) => {
- SelfExplicit(fld.fold_ty(typ), ident)
+ SelfExplicit(typ, name) => {
+ SelfExplicit(fld.fold_ty(typ), name)
}
}
}
respan(folder.new_span(name.span),
folder.fold_name(name.node)))
}
- ExprTupField(el, ident) => {
+ ExprTupField(el, index) => {
ExprTupField(folder.fold_expr(el),
- respan(folder.new_span(ident.span),
- folder.fold_usize(ident.node)))
+ respan(folder.new_span(index.span),
+ folder.fold_usize(index.node)))
}
ExprIndex(el, er) => {
ExprIndex(folder.fold_expr(el), folder.fold_expr(er))
use std::io::{self, Write, Read};
pub enum AnnNode<'a> {
- NodeIdent(&'a ast::Ident),
NodeName(&'a ast::Name),
NodeBlock(&'a hir::Block),
NodeItem(&'a hir::Item),
to_string(|s| s.print_path(p, false, 0))
}
-pub fn ident_to_string(id: &ast::Ident) -> String {
- to_string(|s| s.print_ident(*id))
+pub fn name_to_string(name: ast::Name) -> String {
+ to_string(|s| s.print_name(name))
}
pub fn fun_to_string(decl: &hir::FnDecl,
}
hir::ExprWhile(ref test, ref blk, opt_ident) => {
if let Some(ident) = opt_ident {
- try!(self.print_ident(ident));
+ try!(self.print_name(ident.name));
try!(self.word_space(":"));
}
try!(self.head("while"));
}
hir::ExprLoop(ref blk, opt_ident) => {
if let Some(ident) = opt_ident {
- try!(self.print_ident(ident));
+ try!(self.print_name(ident.name));
try!(self.word_space(":"));
}
try!(self.head("loop"));
try!(word(&mut self.s, "break"));
try!(space(&mut self.s));
if let Some(ident) = opt_ident {
- try!(self.print_ident(ident.node));
+ try!(self.print_name(ident.node.name));
try!(space(&mut self.s));
}
}
try!(word(&mut self.s, "continue"));
try!(space(&mut self.s));
if let Some(ident) = opt_ident {
- try!(self.print_ident(ident.node));
+ try!(self.print_name(ident.node.name));
try!(space(&mut self.s))
}
}
}
}
- pub fn print_ident(&mut self, ident: ast::Ident) -> io::Result<()> {
- try!(word(&mut self.s, &ident.name.as_str()));
- self.ann.post(self, NodeIdent(&ident))
- }
-
pub fn print_usize(&mut self, i: usize) -> io::Result<()> {
word(&mut self.s, &i.to_string())
}
try!(word(&mut self.s, "::"))
}
- try!(self.print_ident(segment.identifier));
+ try!(self.print_name(segment.identifier.name));
try!(self.print_path_parameters(&segment.parameters, colons_before_params));
}
try!(word(&mut self.s, ">"));
try!(word(&mut self.s, "::"));
let item_segment = path.segments.last().unwrap();
- try!(self.print_ident(item_segment.identifier));
+ try!(self.print_name(item_segment.identifier.name));
self.print_path_parameters(&item_segment.parameters, colons_before_params)
}
try!(self.word_nbsp("mut"));
}
}
- try!(self.print_ident(path1.node));
+ try!(self.print_name(path1.node.name));
match *sub {
Some(ref p) => {
try!(word(&mut self.s, "@"));
word(&mut self.s, "::*")
}
- hir::ViewPathList(ref path, ref idents) => {
+ hir::ViewPathList(ref path, ref segments) => {
if path.segments.is_empty() {
try!(word(&mut self.s, "{"));
} else {
try!(self.print_path(path, false, 0));
try!(word(&mut self.s, "::{"));
}
- try!(self.commasep(Inconsistent, &idents[..], |s, w| {
+ try!(self.commasep(Inconsistent, &segments[..], |s, w| {
match w.node {
hir::PathListIdent { name, .. } => {
s.print_name(name)
abi: abi::Abi,
unsafety: hir::Unsafety,
decl: &hir::FnDecl,
- name: Option<ast::Ident>,
+ name: Option<ast::Name>,
generics: &hir::Generics,
opt_explicit_self: Option<&hir::ExplicitSelf_>)
-> io::Result<()> {
unsafety,
hir::Constness::NotConst,
abi,
- name.map(|x| x.name),
+ name,
&generics,
opt_explicit_self,
hir::Inherited));
// convert a span and an identifier to the corresponding
// 1-segment path
-pub fn ident_to_path(s: Span, identifier: Ident) -> Path {
+pub fn ident_to_path(s: Span, ident: Ident) -> Path {
hir::Path {
span: s,
global: false,
segments: vec!(
hir::PathSegment {
- identifier: identifier,
+ identifier: ident,
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
lifetimes: Vec::new(),
types: OwnedSlice::empty(),
impl LateLintPass for UnconditionalRecursion {
fn check_fn(&mut self, cx: &LateContext, fn_kind: FnKind, _: &hir::FnDecl,
blk: &hir::Block, sp: Span, id: ast::NodeId) {
- type F = for<'tcx> fn(&ty::ctxt<'tcx>,
- ast::NodeId, ast::NodeId, ast::Ident, ast::NodeId) -> bool;
-
let method = match fn_kind {
FnKind::ItemFn(..) => None,
FnKind::Method(..) => {
let mut mutables = FnvHashMap();
for p in pats {
pat_util::pat_bindings(&cx.tcx.def_map, p, |mode, id, _, path1| {
- let ident = path1.node;
+ let name = path1.node;
if let hir::BindByValue(hir::MutMutable) = mode {
- if !ident.name.as_str().starts_with("_") {
- match mutables.entry(ident.name.usize()) {
+ if !name.as_str().starts_with("_") {
+ match mutables.entry(name.usize()) {
Vacant(entry) => { entry.insert(vec![id]); },
Occupied(mut entry) => { entry.get_mut().push(id); },
}
struct Binding<H:Hair> {
span: H::Span,
source: Lvalue<H>,
- name: H::Ident,
+ name: H::Name,
var_id: H::VarId,
var_ty: H::Ty,
mutability: Mutability,
fn declare_binding(&mut self,
var_extent: H::CodeExtent,
mutability: Mutability,
- name: H::Ident,
+ name: H::Name,
var_id: H::VarId,
var_ty: H::Ty,
span: H::Span)
type DefId: Copy+Debug+Eq+Hash; // e.g., DefId
type AdtDef: Copy+Debug+Eq+Hash; // e.g., AdtDef<'tcx>
type Name: Copy+Debug+Eq+Hash; // e.g., ast::Name
- type Ident: Copy+Debug+Eq+Hash; // e.g., ast::Ident
type InternedString: Clone+Debug+Eq+Hash; // e.g., InternedString
type Bytes: Clone+Debug+Eq+Hash; // e.g., Rc<Vec<u8>>
type Span: Copy+Debug+Eq; // e.g., syntax::codemap::Span
// x, ref x, x @ P, etc
Binding { mutability: Mutability,
- name: H::Ident,
+ name: H::Name,
mode: BindingMode<H>,
var: H::VarId,
ty: H::Ty,
// decl, a let, etc.
pub struct VarDecl<H:Hair> {
pub mutability: Mutability,
- pub name: H::Ident,
+ pub name: H::Name,
pub ty: H::Ty,
}
hir::ExprField(ref source, name) =>
ExprKind::Field { lhs: source.to_ref(),
name: Field::Named(name.node) },
- hir::ExprTupField(ref source, ident) =>
+ hir::ExprTupField(ref source, index) =>
ExprKind::Field { lhs: source.to_ref(),
- name: Field::Indexed(ident.node) },
+ name: Field::Indexed(index.node) },
hir::ExprCast(ref source, _) =>
ExprKind::Cast { source: source.to_ref() },
hir::ExprBox(ref place, ref value) =>
type DefId = DefId;
type AdtDef = ty::AdtDef<'tcx>;
type Name = ast::Name;
- type Ident = ast::Ident;
type InternedString = InternedString;
type Bytes = Rc<Vec<u8>>;
type Span = Span;
#[derive(Clone, Debug)]
pub struct PatNode<'tcx> {
pat: &'tcx hir::Pat,
- binding_map: Option<Rc<FnvHashMap<ast::Ident, ast::NodeId>>>
+ binding_map: Option<Rc<FnvHashMap<ast::Name, ast::NodeId>>>
}
impl<'tcx> PatNode<'tcx> {
pub fn new(pat: &'tcx hir::Pat,
- binding_map: Option<Rc<FnvHashMap<ast::Ident, ast::NodeId>>>)
+ binding_map: Option<Rc<FnvHashMap<ast::Name, ast::NodeId>>>)
-> PatNode<'tcx> {
PatNode {
pat: pat,
{
let id = match self.binding_map {
None => self.pat.id,
- Some(ref map) => map[&ident.node],
+ Some(ref map) => map[&ident.node.name],
};
let var_ty = cx.tcx.node_id_to_type(self.pat.id);
let region = match var_ty.sty {
PatternKind::Binding {
mutability: mutability,
mode: mode,
- name: ident.node,
+ name: ident.node.name,
var: id,
ty: var_ty,
subpattern: self.opt_pat_ref(sub),
enum FieldName {
UnnamedField(usize), // index
- // (Name, not Ident, because struct fields are not macro-hygienic)
NamedField(ast::Name),
}
ViewPathSimple(_, ref full_path) => {
full_path.segments
.split_last().unwrap().1
- .iter().map(|ident| ident.identifier.name)
+ .iter().map(|seg| seg.identifier.name)
.collect()
}
ViewPathGlob(ref module_ident_path) |
ViewPathList(ref module_ident_path, _) => {
module_ident_path.segments
- .iter().map(|ident| ident.identifier.name).collect()
+ .iter().map(|seg| seg.identifier.name).collect()
}
};
use rustc::metadata::decoder::{DefLike, DlDef, DlField, DlImpl};
use rustc::middle::def::*;
use rustc::middle::def_id::DefId;
-use rustc::middle::pat_util::pat_bindings;
+use rustc::middle::pat_util::pat_bindings_hygienic;
use rustc::middle::privacy::*;
use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace};
use rustc::middle::ty::{Freevar, FreevarMap, TraitMap, GlobMap};
// user and one 'x' came from the macro.
fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap {
let mut result = HashMap::new();
- pat_bindings(&self.def_map, pat, |binding_mode, _id, sp, path1| {
+ pat_bindings_hygienic(&self.def_map, pat, |binding_mode, _id, sp, path1| {
let name = mtwt::resolve(path1.node);
result.insert(name, BindingInfo {
span: sp,
)));
}
- for (ident, target_import_resolution) in import_resolutions.iter() {
+ for (name, target_import_resolution) in import_resolutions.iter() {
debug!("(resolving glob import) writing module resolution \
{} into `{}`",
- *ident,
+ *name,
module_to_string(module_));
if !target_import_resolution.is_public {
// Here we merge two import resolutions.
let mut import_resolutions = module_.import_resolutions.borrow_mut();
- match import_resolutions.get_mut(ident) {
+ match import_resolutions.get_mut(name) {
Some(dest_import_resolution) => {
// Merge the two import resolutions at a finer-grained
// level.
Some(ref value_target) => {
self.check_for_conflicting_import(&dest_import_resolution,
import_directive.span,
- *ident,
+ *name,
ValueNS);
dest_import_resolution.value_target = Some(value_target.clone());
}
Some(ref type_target) => {
self.check_for_conflicting_import(&dest_import_resolution,
import_directive.span,
- *ident,
+ *name,
TypeNS);
dest_import_resolution.type_target = Some(type_target.clone());
}
new_import_resolution.type_target =
target_import_resolution.type_target.clone();
- import_resolutions.insert(*ident, new_import_resolution);
+ import_resolutions.insert(*name, new_import_resolution);
}
// Add all children from the containing module.
fn process_const(&mut self,
id: ast::NodeId,
- ident: &ast::Ident,
+ name: &ast::Name,
span: Span,
typ: &ast::Ty,
expr: &ast::Expr) {
self.fmt.static_str(span,
sub_span,
id,
- &ident.name.as_str(),
+ &name.as_str(),
&qualname,
&self.span.snippet(expr.span),
&ty_to_string(&*typ),
fn visit_trait_item(&mut self, trait_item: &ast::TraitItem) {
match trait_item.node {
ast::ConstTraitItem(ref ty, Some(ref expr)) => {
- self.process_const(trait_item.id, &trait_item.ident,
+ self.process_const(trait_item.id, &trait_item.ident.name,
trait_item.span, &*ty, &*expr);
}
ast::MethodTraitItem(ref sig, ref body) => {
fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) {
match impl_item.node {
ast::ConstImplItem(ref ty, ref expr) => {
- self.process_const(impl_item.id, &impl_item.ident,
+ self.process_const(impl_item.id, &impl_item.ident.name,
impl_item.span, &ty, &expr);
}
ast::MethodImplItem(ref sig, ref body) => {
pub ty: Ty<'tcx>,
}
-type BindingsMap<'tcx> = FnvHashMap<ast::Ident, BindingInfo<'tcx>>;
+type BindingsMap<'tcx> = FnvHashMap<ast::Name, BindingInfo<'tcx>>;
struct ArmData<'p, 'blk, 'tcx: 'blk> {
bodycx: Block<'blk, 'tcx>,
struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> {
pats: Vec<&'p hir::Pat>,
data: &'a ArmData<'p, 'blk, 'tcx>,
- bound_ptrs: Vec<(ast::Ident, ValueRef)>,
+ bound_ptrs: Vec<(ast::Name, ValueRef)>,
// Thread along renamings done by the check_match::StaticInliner, so we can
// map back to original NodeIds
pat_renaming_map: Option<&'a FnvHashMap<(NodeId, Span), NodeId>>
loop {
pat = match pat.node {
hir::PatIdent(_, ref path, Some(ref inner)) => {
- bound_ptrs.push((path.node, val.val));
+ bound_ptrs.push((path.node.name, val.val));
&**inner
},
_ => break
match this.node {
hir::PatIdent(_, ref path, None) => {
if pat_is_binding(dm, &*this) {
- bound_ptrs.push((path.node, val.val));
+ bound_ptrs.push((path.node.name, val.val));
}
}
hir::PatVec(ref before, Some(ref slice), ref after) => {
let subslice_val = bind_subslice_pat(
bcx, this.id, val,
before.len(), after.len());
- bound_ptrs.push((path.node, subslice_val));
+ bound_ptrs.push((path.node.name, subslice_val));
}
}
_ => {}
bindings_map: &BindingsMap<'tcx>,
cs: Option<cleanup::ScopeId>)
-> Block<'blk, 'tcx> {
- for (&ident, &binding_info) in bindings_map {
+ for (&name, &binding_info) in bindings_map {
let (llval, aliases_other_state) = match binding_info.trmode {
// By value mut binding for a copy type: load from the ptr
// into the matched value and copy to our alloca
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));
bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum);
- debuginfo::create_match_binding_metadata(bcx, ident.name, binding_info);
+ debuginfo::create_match_binding_metadata(bcx, name, binding_info);
}
bcx
}
let reassigned = is_discr_reassigned(bcx, discr, body);
let mut bindings_map = FnvHashMap();
pat_bindings(&tcx.def_map, &*pat, |bm, p_id, span, path1| {
- let ident = path1.node;
- let name = ident.name;
+ let name = path1.node;
let variable_ty = node_id_type(bcx, p_id);
let llvariable_ty = type_of::type_of(ccx, variable_ty);
let tcx = bcx.tcx();
trmode = TrByRef;
}
};
- bindings_map.insert(ident, BindingInfo {
+ bindings_map.insert(name, BindingInfo {
llmatch: llmatch,
trmode: trmode,
id: p_id,
pat_bindings(&tcx.def_map, pat, |_, p_id, _, path1| {
let scope = cleanup::var_scope(tcx, p_id);
bcx = mk_binding_alloca(
- bcx, p_id, path1.node.name, scope, (),
+ bcx, p_id, path1.node, scope, (),
"_match::store_local::create_dummy_locals",
|(), bcx, Datum { val: llval, ty, kind }| {
// Dummy-locals start out uninitialized, so set their
//
// In such cases, the more general path is unsafe, because
// it assumes it is matching against a valid value.
- match simple_identifier(&*pat) {
- Some(ident) => {
+ match simple_name(pat) {
+ Some(name) => {
let var_scope = cleanup::var_scope(tcx, local.id);
return mk_binding_alloca(
- bcx, pat.id, ident.name, var_scope, (),
+ bcx, pat.id, name, var_scope, (),
"_match::store_local",
|(), bcx, Datum { val: v, .. }| expr::trans_into(bcx, &**init_expr,
expr::SaveIn(v)));
use middle::def_id::{DefId, LOCAL_CRATE};
use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
use middle::weak_lang_items;
-use middle::pat_util::simple_identifier;
+use middle::pat_util::simple_name;
use middle::subst::Substs;
use middle::ty::{self, Ty, HasTypeFlags};
use rustc::front::map as hir_map;
};
let pat = &*args[i].pat;
- bcx = if let Some(ident) = simple_identifier(&*pat) {
+ bcx = if let Some(name) = simple_name(pat) {
// Generate nicer LLVM for the common case of fn a pattern
// like `x: T`
- set_value_name(arg_datum.val, &bcx.name(ident.name));
+ set_value_name(arg_datum.val, &bcx.name(name));
bcx.fcx.lllocals.borrow_mut().insert(pat.id, arg_datum);
bcx
} else {
pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
expr: &hir::Expr,
- opt_label: Option<ast::Ident>,
+ opt_label: Option<ast::Name>,
exit: usize)
-> Block<'blk, 'tcx> {
let _icx = push_ctxt("trans_break_cont");
pub fn trans_break<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
expr: &hir::Expr,
- label_opt: Option<ast::Ident>)
+ label_opt: Option<ast::Name>)
-> Block<'blk, 'tcx> {
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_BREAK);
}
pub fn trans_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
expr: &hir::Expr,
- label_opt: Option<ast::Ident>)
+ label_opt: Option<ast::Name>)
-> Block<'blk, 'tcx> {
return trans_break_cont(bcx, expr, label_opt, cleanup::EXIT_LOOP);
}
for arg in args {
pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, _, path1| {
scope_stack.push(ScopeStackEntry { scope_metadata: fn_metadata,
- name: Some(path1.node.name) });
+ name: Some(path1.node) });
scope_map.insert(node_id, fn_metadata);
})
}
let def_map = &cx.tcx().def_map;
let locals = bcx.fcx.lllocals.borrow();
- pat_util::pat_bindings(def_map, &*local.pat, |_, node_id, span, var_ident| {
+ pat_util::pat_bindings(def_map, &*local.pat, |_, node_id, span, var_name| {
let datum = match locals.get(&node_id) {
Some(datum) => datum,
None => {
let scope_metadata = scope_metadata(bcx.fcx, node_id, span);
declare_local(bcx,
- var_ident.node.name,
+ var_name.node,
datum.ty,
scope_metadata,
VariableAccess::DirectVariable { alloca: datum.val },
.fn_metadata;
let locals = bcx.fcx.lllocals.borrow();
- pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, span, var_ident| {
+ pat_util::pat_bindings(def_map, &*arg.pat, |_, node_id, span, var_name| {
let datum = match locals.get(&node_id) {
Some(v) => v,
None => {
};
declare_local(bcx,
- var_ident.node.name,
+ var_name.node,
datum.ty,
scope_metadata,
VariableAccess::DirectVariable { alloca: datum.val },
match expr.node {
hir::ExprBreak(label_opt) => {
- controlflow::trans_break(bcx, expr, label_opt.map(|l| l.node))
+ controlflow::trans_break(bcx, expr, label_opt.map(|l| l.node.name))
}
hir::ExprAgain(label_opt) => {
- controlflow::trans_cont(bcx, expr, label_opt.map(|l| l.node))
+ controlflow::trans_cont(bcx, expr, label_opt.map(|l| l.node.name))
}
hir::ExprRet(ref ex) => {
// Check to see if the return expression itself is reachable.
// trans. Shudder.
fn make_field(field_name: &str, expr: P<hir::Expr>) -> hir::Field {
hir::Field {
- name: codemap::dummy_spanned(token::str_to_ident(field_name).name),
+ name: codemap::dummy_spanned(token::intern(field_name)),
expr: expr,
span: codemap::DUMMY_SP,
}
// if there are multiple arms, make sure they all agree on
// what the type of the binding `x` ought to be
- let canon_id = *pcx.map.get(&path.node).unwrap();
+ let canon_id = *pcx.map.get(&path.node.name).unwrap();
if canon_id != pat.id {
let ct = fcx.local_ty(pat.span, canon_id);
demand::eqtype(fcx, pat.span, ct, typ);
}
pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
- debug!("check_item_type(it.id={}, it.ident={})",
+ debug!("check_item_type(it.id={}, it.name={})",
it.id,
ccx.tcx.item_path_str(DefId::local(it.id)));
let _indenter = indenter();
}
pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
- debug!("check_item_body(it.id={}, it.ident={})",
+ debug!("check_item_body(it.id={}, it.name={})",
it.id,
ccx.tcx.item_path_str(DefId::local(it.id)));
let _indenter = indenter();
/// the types first.
fn check_item_well_formed(&mut self, item: &hir::Item) {
let ccx = self.ccx;
- debug!("check_item_well_formed(it.id={}, it.ident={})",
+ debug!("check_item_well_formed(it.id={}, it.name={})",
item.id,
ccx.tcx.item_path_str(DefId::local(item.id)));
/// the types first.
fn check_item_well_formed(&mut self, item: &hir::Item) {
let ccx = self.ccx;
- debug!("check_item_well_formed(it.id={}, it.ident={})",
+ debug!("check_item_well_formed(it.id={}, it.name={})",
item.id,
ccx.tcx.item_path_str(DefId::local(item.id)));
rcvr_ty_generics,
rcvr_ty_predicates);
- for (sig, id, ident, vis, _span) in methods {
+ for (sig, id, name, vis, _span) in methods {
convert_method(ccx,
container,
sig,
id,
- ident,
+ name,
vis,
untransformed_rcvr_ty,
rcvr_ty_generics,
let mut trait_path = p.clone();
trait_path.segments.pop();
Type::QPath {
- name: p.segments.last().unwrap().identifier.clean(cx),
+ name: p.segments.last().unwrap().identifier.name.clean(cx),
self_type: box qself.ty.clean(cx),
trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
}
impl Clean<PathSegment> for hir::PathSegment {
fn clean(&self, cx: &DocContext) -> PathSegment {
PathSegment {
- name: self.identifier.clean(cx),
+ name: self.identifier.name.clean(cx),
params: self.parameters.clean(cx)
}
}
s
}
-impl Clean<String> for ast::Ident {
- fn clean(&self, _: &DocContext) -> String {
- self.to_string()
- }
-}
-
impl Clean<String> for ast::Name {
fn clean(&self, _: &DocContext) -> String {
self.to_string()
// "enable" to 0 instead.
// compile-flags:-g -Cllvm-args=-enable-tail-merge=0
// ignore-pretty as this critically relies on line numbers
+// ignore-windows
use std::io;
use std::io::prelude::*;
// no-pretty-expanded FIXME #15189
// ignore-android FIXME #17520
// ignore-msvc FIXME #28133
+// ignore-windows
use std::env;
use std::process::{Command, Stdio};