use util::nodemap::FnvHashMap;
use syntax::ast;
-use syntax::ext::mtwt;
use rustc_front::hir;
use rustc_front::util::walk_pat;
use syntax::codemap::{respan, Span, Spanned, DUMMY_SP};
// use the NodeId of their namesake in the first pattern.
pub fn pat_id_map(dm: &RefCell<DefMap>, pat: &hir::Pat) -> PatIdMap {
let mut map = FnvHashMap();
- pat_bindings_hygienic(dm, pat, |_bm, p_id, _s, path1| {
- map.insert(mtwt::resolve(path1.node), p_id);
+ pat_bindings(dm, pat, |_bm, p_id, _s, path1| {
+ map.insert(path1.node, p_id);
});
map
}
hir::PatIdent(_, _, None) |
hir::PatStruct(..) => {
match dm.get(&pat.id).map(|d| d.full_def()) {
- Some(DefVariant(..)) => true,
+ Some(Def::Variant(..)) => true,
_ => false
}
}
hir::PatIdent(_, _, None) |
hir::PatStruct(..) => {
match dm.get(&pat.id).map(|d| d.full_def()) {
- Some(DefVariant(..)) | Some(DefStruct(..)) => true,
+ Some(Def::Variant(..)) | Some(Def::Struct(..)) => true,
_ => false
}
}
match pat.node {
hir::PatIdent(_, _, None) | hir::PatEnum(..) | hir::PatQPath(..) => {
match dm.get(&pat.id).map(|d| d.full_def()) {
- Some(DefConst(..)) | Some(DefAssociatedConst(..)) => true,
+ Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => true,
_ => false
}
}
match dm.get(&pat.id)
.and_then(|d| if d.depth == 0 { Some(d.base_def) }
else { None } ) {
- Some(DefConst(..)) | Some(DefAssociatedConst(..)) => true,
+ Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => true,
_ => false
}
}
true
});
}
-
-pub fn pat_bindings_hygienic<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
- I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<ast::Ident>),
+pub fn pat_bindings_ident<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
+ I: FnMut(hir::BindingMode, ast::NodeId, Span, &Spanned<hir::Ident>),
{
walk_pat(pat, |p| {
match p.node {
pub fn arm_contains_ref_binding(dm: &RefCell<DefMap>, arm: &hir::Arm) -> Option<hir::Mutability> {
arm.pats.iter()
.filter_map(|pat| pat_contains_ref_binding(dm, pat))
- .max_by(|m| match *m {
+ .max_by_key(|m| match *m {
hir::MutMutable => 1,
hir::MutImmutable => 0,
})
tcx.with_path(id, |path| hir::Path {
global: false,
segments: path.last().map(|elem| hir::PathSegment {
- identifier: ast::Ident::with_empty_ctxt(elem.name()),
+ identifier: hir::Ident::from_name(elem.name()),
parameters: hir::PathParameters::none(),
}).into_iter().collect(),
span: DUMMY_SP,
hir::PatIdent(_, _, None) |
hir::PatStruct(..) => {
match dm.get(&p.id) {
- Some(&PathResolution { base_def: DefVariant(_, id, _), .. }) => {
+ Some(&PathResolution { base_def: Def::Variant(_, id), .. }) => {
variants.push(id);
}
_ => ()