From a817c69297dc2bfac4029410cc055d32022cea95 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 29 Jan 2015 21:18:17 +0200 Subject: [PATCH] syntax: don't store a secondary NodeId for TyPath. --- src/librustc/lint/builtin.rs | 11 ++-- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/astconv_util.rs | 4 +- src/librustc/middle/infer/error_reporting.rs | 6 +- src/librustc/middle/resolve_lifetime.rs | 12 ++-- src/librustc_privacy/lib.rs | 69 ++++++++------------ src/librustc_resolve/build_reduced_graph.rs | 4 +- src/librustc_resolve/lib.rs | 12 ++-- src/librustc_trans/save/mod.rs | 8 +-- src/librustc_typeck/astconv.rs | 12 ++-- src/librustdoc/clean/mod.rs | 4 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/ast_util.rs | 3 - src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/feature_gate.rs | 2 +- src/libsyntax/fold.rs | 5 +- src/libsyntax/parse/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 7 +- src/libsyntax/print/pprust.rs | 2 +- src/libsyntax/visit.rs | 4 +- 21 files changed, 74 insertions(+), 101 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 8a00622486dd..8c6984972718 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -405,8 +405,8 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> { } impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { - fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) { - match self.cx.tcx.def_map.borrow()[path_id].clone() { + fn check_def(&mut self, sp: Span, id: ast::NodeId) { + match self.cx.tcx.def_map.borrow()[id].clone() { def::DefPrimTy(ast::TyInt(ast::TyIs(_))) => { self.cx.span_lint(IMPROPER_CTYPES, sp, "found rust type `isize` in foreign module, while \ @@ -418,7 +418,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { libc::c_uint or libc::c_ulong should be used"); } def::DefTy(..) => { - let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&ty_id) { + let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().get(&id) { Some(&ty::atttce_resolved(t)) => t, _ => panic!("ast_ty_to_ty_cache was incomplete after typeck!") }; @@ -437,9 +437,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: &ast::Ty) { - match ty.node { - ast::TyPath(_, id) => self.check_def(ty.span, ty.id, id), - _ => (), + if let ast::TyPath(_) = ty.node { + self.check_def(ty.span, ty.id); } visit::walk_ty(self, ty); } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e0832bb683a1..e6f5c36a2f81 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1221,7 +1221,7 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_unsafety(rbml_w, unsafety); encode_polarity(rbml_w, polarity); match ty.node { - ast::TyPath(ref path, _) if path.segments.len() == 1 => { + ast::TyPath(ref path) if path.segments.len() == 1 => { let ident = path.segments.last().unwrap().identifier; encode_impl_type_basename(rbml_w, ident); } diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index d699ba40e822..d46808448389 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -43,8 +43,8 @@ pub fn check_path_args(tcx: &ty::ctxt, pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty) -> Option> { match ast_ty.node { - ast::TyPath(ref path, id) => { - let a_def = match tcx.def_map.borrow().get(&id) { + ast::TyPath(ref path) => { + let a_def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess.span_bug(ast_ty.span, &format!("unbound path {}", diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 110c7bf41e55..4439472ab567 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -1233,8 +1233,8 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } ty_queue.push(&*mut_ty.ty); } - ast::TyPath(ref path, id) => { - let a_def = match self.tcx.def_map.borrow().get(&id) { + ast::TyPath(ref path) => { + let a_def = match self.tcx.def_map.borrow().get(&cur_ty.id) { None => { self.tcx .sess @@ -1279,7 +1279,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { let new_path = self.rebuild_path(rebuild_info, lifetime); let to = ast::Ty { id: cur_ty.id, - node: ast::TyPath(new_path, id), + node: ast::TyPath(new_path), span: cur_ty.span }; new_ty = self.rebuild_ty(new_ty, P(to)); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 9012de0850fa..7b957d6ce849 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -165,13 +165,13 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { visit::walk_ty(this, ty); }); } - ast::TyPath(ref path, id) => { + ast::TyPath(ref path) => { // if this path references a trait, then this will resolve to // a trait ref, which introduces a binding scope. - match self.def_map.borrow().get(&id) { + match self.def_map.borrow().get(&ty.id) { Some(&def::DefTrait(..)) => { self.with(LateScope(&Vec::new(), self.scope), |_, this| { - this.visit_path(path, id); + this.visit_path(path, ty.id); }); } _ => { @@ -270,16 +270,12 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { for lifetime in &trait_ref.bound_lifetimes { this.visit_lifetime_def(lifetime); } - this.visit_trait_ref(&trait_ref.trait_ref) + visit::walk_path(this, &trait_ref.trait_ref.path) }) } else { self.visit_trait_ref(&trait_ref.trait_ref) } } - - fn visit_trait_ref(&mut self, trait_ref: &ast::TraitRef) { - self.visit_path(&trait_ref.path, trait_ref.ref_id); - } } impl<'a> LifetimeContext<'a> { diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 3d92b387cdb3..838ba9c658cf 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -259,8 +259,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> { // * Private trait impls for private types can be completely ignored ast::ItemImpl(_, _, _, _, ref ty, ref impl_items) => { let public_ty = match ty.node { - ast::TyPath(_, id) => { - match self.tcx.def_map.borrow()[id].clone() { + ast::TyPath(_) => { + match self.tcx.def_map.borrow()[ty.id].clone() { def::DefPrimTy(..) => true, def => { let did = def.def_id(); @@ -326,8 +326,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> { } ast::ItemTy(ref ty, _) if public_first => { - if let ast::TyPath(_, id) = ty.node { - match self.tcx.def_map.borrow()[id].clone() { + if let ast::TyPath(_) = ty.node { + match self.tcx.def_map.borrow()[ty.id].clone() { def::DefPrimTy(..) | def::DefTyParam(..) => {}, def => { let did = def.def_id(); @@ -628,11 +628,11 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { // back up the chains to find the relevant struct/enum that // was private. ast::ItemImpl(_, _, _, _, ref ty, _) => { - let id = match ty.node { - ast::TyPath(_, id) => id, + match ty.node { + ast::TyPath(_) => {} _ => return Some((err_span, err_msg, None)), }; - let def = self.tcx.def_map.borrow()[id].clone(); + let def = self.tcx.def_map.borrow()[ty.id].clone(); let did = def.def_id(); assert!(is_local(did)); match self.tcx.map.get(did.node) { @@ -716,13 +716,13 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { } // Checks that a path is in scope. - fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) { + fn check_path(&mut self, span: Span, path_id: ast::NodeId, last: ast::Ident) { debug!("privacy - path {}", self.nodestr(path_id)); let orig_def = self.tcx.def_map.borrow()[path_id].clone(); let ck = |tyname: &str| { let ck_public = |def: ast::DefId| { debug!("privacy - ck_public {:?}", def); - let name = token::get_ident(path.segments.last().unwrap().identifier); + let name = token::get_ident(last); let origdid = orig_def.def_id(); self.ensure_public(span, def, @@ -832,37 +832,22 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &ast::Item) { - match item.node { - ast::ItemUse(ref vpath) => { - match vpath.node { - ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {} - ast::ViewPathList(ref prefix, ref list) => { - for pid in list { - match pid.node { - ast::PathListIdent { id, name } => { - debug!("privacy - ident item {}", id); - let seg = ast::PathSegment { - identifier: name, - parameters: ast::PathParameters::none(), - }; - let segs = vec![seg]; - let path = ast::Path { - global: false, - span: pid.span, - segments: segs, - }; - self.check_path(pid.span, id, &path); - } - ast::PathListMod { id } => { - debug!("privacy - mod item {}", id); - self.check_path(pid.span, id, prefix); - } - } + if let ast::ItemUse(ref vpath) = item.node { + if let ast::ViewPathList(ref prefix, ref list) = vpath.node { + for pid in list { + match pid.node { + ast::PathListIdent { id, name } => { + debug!("privacy - ident item {}", id); + self.check_path(pid.span, id, name); + } + ast::PathListMod { id } => { + debug!("privacy - mod item {}", id); + let name = prefix.segments.last().unwrap().identifier; + self.check_path(pid.span, id, name); } } } } - _ => {} } let orig_curitem = replace(&mut self.curitem, item.id); visit::walk_item(self, item); @@ -1033,7 +1018,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> { } fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId) { - self.check_path(path.span, id, path); + self.check_path(path.span, id, path.segments.last().unwrap().identifier); visit::walk_path(self, path); } } @@ -1273,8 +1258,8 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> { impl<'a, 'b, 'tcx, 'v> Visitor<'v> for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> { fn visit_ty(&mut self, ty: &ast::Ty) { - if let ast::TyPath(_, path_id) = ty.node { - if self.inner.path_is_private_type(path_id) { + if let ast::TyPath(_) = ty.node { + if self.inner.path_is_private_type(ty.id) { self.contains_private = true; // found what we're looking for so let's stop // working. @@ -1398,7 +1383,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { // // Those in 2. are warned via walk_generics and this // call here. - self.visit_trait_ref(tr) + visit::walk_path(self, &tr.path); } } } else if trait_ref.is_none() && self_is_public_path { @@ -1479,9 +1464,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { } fn visit_ty(&mut self, t: &ast::Ty) { - if let ast::TyPath(ref p, path_id) = t.node { + if let ast::TyPath(ref p) = t.node { if !self.tcx.sess.features.borrow().visible_private_types && - self.path_is_private_type(path_id) { + self.path_is_private_type(t.id) { self.tcx.sess.span_err(p.span, "private type in exported type signature"); } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index a181497010fa..ad5fa600bd81 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -523,14 +523,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { // within this module. let mod_name = match ty.node { - TyPath(ref path, _) if path.segments.len() == 1 => { + TyPath(ref path) if path.segments.len() == 1 => { // FIXME(18446) we should distinguish between the name of // a trait and the name of an impl of that trait. Some(path.segments.last().unwrap().identifier.name) } TyObjectSum(ref lhs_ty, _) => { match lhs_ty.node { - TyPath(ref path, _) if path.segments.len() == 1 => { + TyPath(ref path) if path.segments.len() == 1 => { Some(path.segments.last().unwrap().identifier.name) } _ => { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2da8bd5b538b..55ad52762e0c 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3387,8 +3387,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // type, the result will be that the type name resolves to a module but not // a type (shadowing any imported modules or types with this name), leading // to weird user-visible bugs. So we ward this off here. See #15060. - TyPath(ref path, path_id) => { - match self.def_map.borrow().get(&path_id) { + TyPath(ref path) => { + match self.def_map.borrow().get(&self_type.id) { // FIXME: should we catch other options and give more precise errors? Some(&DefMod(_)) => { self.resolve_error(path.span, "inherent implementations are not \ @@ -3576,7 +3576,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Like path expressions, the interpretation of path types depends // on whether the path has multiple elements in it or not. - TyPath(ref path, path_id) => { + TyPath(ref path) => { // This is a path in the type namespace. Walk through scopes // looking for it. let mut result_def = None; @@ -3617,8 +3617,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { debug!("(resolving type) writing resolution for `{}` \ (id {}) = {:?}", self.path_names_to_string(path), - path_id, def); - self.record_def(path_id, def); + ty.id, def); + self.record_def(ty.id, def); } None => { let msg = format!("use of undeclared type name `{}`", @@ -4281,7 +4281,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks) -> Option<(Path, NodeId, FallbackChecks)> { match t.node { - TyPath(ref path, node_id) => Some((path.clone(), node_id, allow)), + TyPath(ref path) => Some((path.clone(), t.id, allow)), TyPtr(ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, OnlyTraitAndStatics), TyRptr(_, ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, allow), // This doesn't handle the remaining `Ty` variants as they are not diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 59fca4b03188..af891001ea00 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -662,9 +662,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { let trait_id = trait_ref.as_ref().and_then(|tr| self.lookup_type_ref(tr.ref_id)); match typ.node { // Common case impl for a struct or something basic. - ast::TyPath(ref path, id) => { + ast::TyPath(ref path) => { let sub_span = self.span.sub_span_for_type_name(path.span); - let self_id = self.lookup_type_ref(id).map(|id| { + let self_id = self.lookup_type_ref(typ.id).map(|id| { self.fmt.ref_str(recorder::TypeRef, path.span, sub_span, @@ -1303,8 +1303,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { } match t.node { - ast::TyPath(ref path, id) => { - match self.lookup_type_ref(id) { + ast::TyPath(ref path) => { + match self.lookup_type_ref(t.id) { Some(id) => { let sub_span = self.span.sub_span_for_type_name(t.span); self.fmt.ref_str(recorder::TypeRef, diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 46a7041fff67..16a2dbf26870 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -852,8 +852,8 @@ pub fn ast_ty_to_builtin_ty<'tcx>( } match ast_ty.node { - ast::TyPath(ref path, id) => { - let a_def = match this.tcx().def_map.borrow().get(&id) { + ast::TyPath(ref path) => { + let a_def = match this.tcx().def_map.borrow().get(&ast_ty.id) { None => { this.tcx() .sess @@ -912,8 +912,8 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>, */ match ty.node { - ast::TyPath(ref path, id) => { - match this.tcx().def_map.borrow().get(&id) { + ast::TyPath(ref path) => { + match this.tcx().def_map.borrow().get(&ty.id) { Some(&def::DefTrait(trait_def_id)) => { let mut projection_bounds = Vec::new(); let trait_ref = object_path_to_poly_trait_ref(this, @@ -1183,8 +1183,8 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, ast::TyPolyTraitRef(ref bounds) => { conv_ty_poly_trait_ref(this, rscope, ast_ty.span, &bounds[..]) } - ast::TyPath(ref path, id) => { - let a_def = match tcx.def_map.borrow().get(&id) { + ast::TyPath(ref path) => { + let a_def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess .span_bug(ast_ty.span, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 058d55bd7ba9..d05aa4d20066 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1496,8 +1496,8 @@ impl Clean for ast::Ty { TyFixedLengthVec(ref ty, ref e) => FixedVector(box ty.clean(cx), e.span.to_src(cx)), TyTup(ref tys) => Tuple(tys.clean(cx)), - TyPath(ref p, id) => { - resolve_type(cx, p.clean(cx), id) + TyPath(ref p) => { + resolve_type(cx, p.clean(cx), self.id) } TyObjectSum(ref lhs, ref bounds) => { let lhs_ty = lhs.clean(cx); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index effaac527163..7c83286f656b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1257,7 +1257,7 @@ pub enum Ty_ { /// A path (`module::module::...::Type`) or primitive /// /// Type parameters are stored in the Path itself - TyPath(Path, NodeId), + TyPath(Path), /// Something like `A+B`. Note that `B` must always be a path. TyObjectSum(P, TyParamBounds), /// A type like `for<'a> Foo<&'a Bar>` diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index f1228c1d3630..6ea37aaf72ce 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -488,9 +488,6 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { fn visit_ty(&mut self, typ: &Ty) { self.operation.visit_id(typ.id); - if let TyPath(_, id) = typ.node { - self.operation.visit_id(id); - } visit::walk_ty(self, typ) } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 656d507ed69b..baa2fab044f3 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -398,7 +398,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn ty_path(&self, path: ast::Path) -> P { - self.ty(path.span, ast::TyPath(path, ast::DUMMY_NODE_ID)) + self.ty(path.span, ast::TyPath(path)) } fn ty_sum(&self, path: ast::Path, bounds: OwnedSlice) -> P { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index bc239d0c7c26..f7014d6cc3c0 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -41,7 +41,7 @@ pub fn expand_type(t: P, debug!("expanding type {:?} with impl_ty {:?}", t, impl_ty); let t = match (t.node.clone(), impl_ty) { // Expand uses of `Self` in impls to the concrete type. - (ast::Ty_::TyPath(ref path, _), Some(ref impl_ty)) => { + (ast::Ty_::TyPath(ref path), Some(ref impl_ty)) => { let path_as_ident = path_to_ident(path); // Note unhygenic comparison here. I think this is correct, since // even though `Self` is almost just a type parameter, the treatment diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 071158fcebb5..4efae84fea5a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -549,7 +549,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { fn visit_ty(&mut self, t: &ast::Ty) { match t.node { - ast::TyPath(ref p, _) => { + ast::TyPath(ref p) => { match &*p.segments { [ast::PathSegment { identifier, .. }] => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index dae830583c44..ae4d2a800459 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -428,10 +428,7 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { } TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))), TyParen(ty) => TyParen(fld.fold_ty(ty)), - TyPath(path, id) => { - let id = fld.new_id(id); - TyPath(fld.fold_path(path), id) - } + TyPath(path) => TyPath(fld.fold_path(path)), TyObjectSum(ty, bounds) => { TyObjectSum(fld.fold_ty(ty), fld.fold_bounds(bounds)) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 43dfcbae57e4..d4c66529e77d 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -1051,7 +1051,7 @@ mod test { parameters: ast::PathParameters::none(), } ), - }, ast::DUMMY_NODE_ID), + }), span:sp(10,13) }), pat: P(ast::Pat { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fec33eddb91c..bcef7238d7f2 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1076,8 +1076,7 @@ impl<'a> Parser<'a> { } pub fn parse_ty_path(&mut self) -> Ty_ { - let path = self.parse_path(LifetimeAndTypesWithoutColons); - TyPath(path, ast::DUMMY_NODE_ID) + TyPath(self.parse_path(LifetimeAndTypesWithoutColons)) } /// parse a TyBareFn type: @@ -4815,10 +4814,10 @@ impl<'a> Parser<'a> { let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) { // New-style trait. Reinterpret the type as a trait. match ty.node { - TyPath(ref path, node_id) => { + TyPath(ref path) => { Some(TraitRef { path: (*path).clone(), - ref_id: node_id, + ref_id: ty.id, }) } _ => { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 869dad867ebc..752d34a19c6e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -729,7 +729,7 @@ impl<'a> State<'a> { &generics, None)); } - ast::TyPath(ref path, _) => { + ast::TyPath(ref path) => { try!(self.print_path(path, false)); } ast::TyObjectSum(ref ty, ref bounds) => { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 412bf0fa22a0..4586495227d0 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -399,8 +399,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { walk_fn_ret_ty(visitor, &function_declaration.decl.output); walk_lifetime_decls_helper(visitor, &function_declaration.lifetimes); } - TyPath(ref path, id) => { - visitor.visit_path(path, id); + TyPath(ref path) => { + visitor.visit_path(path, typ.id); } TyObjectSum(ref ty, ref bounds) => { visitor.visit_ty(&**ty);