Navigation Menu

Skip to content

Commit

Permalink
Get rid of SpannedIdent
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Apr 6, 2018
1 parent 8719d1e commit e2afefd
Show file tree
Hide file tree
Showing 24 changed files with 231 additions and 272 deletions.
14 changes: 7 additions & 7 deletions src/librustc/hir/lowering.rs
Expand Up @@ -1720,7 +1720,7 @@ impl<'a> LoweringContext<'a> {
decl.inputs
.iter()
.map(|arg| match arg.pat.node {
PatKind::Ident(_, ident, None) => respan(ident.span, ident.node.name),
PatKind::Ident(_, ident, None) => respan(ident.span, ident.name),
_ => respan(arg.pat.span, keywords::Invalid.name()),
})
.collect()
Expand Down Expand Up @@ -2099,7 +2099,7 @@ impl<'a> LoweringContext<'a> {

fn lower_field(&mut self, f: &Field) -> hir::Field {
hir::Field {
name: respan(f.ident.span, self.lower_ident(f.ident.node)),
name: respan(f.ident.span, self.lower_ident(f.ident)),
expr: P(self.lower_expr(&f.expr)),
span: f.span,
is_shorthand: f.is_shorthand,
Expand Down Expand Up @@ -2801,7 +2801,7 @@ impl<'a> LoweringContext<'a> {
fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
let node = match p.node {
PatKind::Wild => hir::PatKind::Wild,
PatKind::Ident(ref binding_mode, pth1, ref sub) => {
PatKind::Ident(ref binding_mode, ident, ref sub) => {
match self.resolver.get_resolution(p.id).map(|d| d.base_def()) {
// `None` can occur in body-less function signatures
def @ None | def @ Some(Def::Local(_)) => {
Expand All @@ -2812,16 +2812,16 @@ impl<'a> LoweringContext<'a> {
hir::PatKind::Binding(
self.lower_binding_mode(binding_mode),
canonical_id,
respan(pth1.span, pth1.node.name),
respan(ident.span, ident.name),
sub.as_ref().map(|x| self.lower_pat(x)),
)
}
Some(def) => hir::PatKind::Path(hir::QPath::Resolved(
None,
P(hir::Path {
span: pth1.span,
span: ident.span,
def,
segments: hir_vec![hir::PathSegment::from_name(pth1.node.name)],
segments: hir_vec![hir::PathSegment::from_name(ident.name)],
}),
)),
}
Expand Down Expand Up @@ -3071,7 +3071,7 @@ impl<'a> LoweringContext<'a> {
),
ExprKind::Field(ref el, ident) => hir::ExprField(
P(self.lower_expr(el)),
respan(ident.span, self.lower_ident(ident.node)),
respan(ident.span, self.lower_ident(ident)),
),
ExprKind::TupField(ref el, ident) => hir::ExprTupField(P(self.lower_expr(el)), ident),
ExprKind::Index(ref el, ref er) => {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_lint/builtin.rs
Expand Up @@ -171,16 +171,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
if fieldpat.node.is_shorthand {
continue;
}
if let PatKind::Binding(_, _, ident, None) = fieldpat.node.pat.node {
if ident.node == fieldpat.node.name {
if let PatKind::Binding(_, _, name, None) = fieldpat.node.pat.node {
if name.node == fieldpat.node.name {
let mut err = cx.struct_span_lint(NON_SHORTHAND_FIELD_PATTERNS,
fieldpat.span,
&format!("the `{}:` in this pattern is redundant",
ident.node));
name.node));
let subspan = cx.tcx.sess.codemap().span_through_char(fieldpat.span, ':');
err.span_suggestion_short(subspan,
"remove this",
format!("{}", ident.node));
format!("{}", name.node));
err.emit();
}
}
Expand Down Expand Up @@ -625,7 +625,7 @@ impl EarlyLintPass for AnonymousParameters {
for arg in sig.decl.inputs.iter() {
match arg.pat.node {
ast::PatKind::Ident(_, ident, None) => {
if ident.node.name == keywords::Invalid.name() {
if ident.name == keywords::Invalid.name() {
cx.span_lint(ANONYMOUS_PARAMETERS,
arg.pat.span,
"use of deprecated anonymous parameter");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/build/mod.rs
Expand Up @@ -467,8 +467,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
mutability: Mutability::Not,
};
if let Some(hir::map::NodeBinding(pat)) = tcx.hir.find(var_id) {
if let hir::PatKind::Binding(_, _, ref ident, _) = pat.node {
decl.debug_name = ident.node;
if let hir::PatKind::Binding(_, _, ref name, _) = pat.node {
decl.debug_name = name.node;

let bm = *hir.tables.pat_binding_modes()
.get(pat.hir_id)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/hair/pattern/mod.rs
Expand Up @@ -466,7 +466,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
}
}

PatKind::Binding(_, id, ref ident, ref sub) => {
PatKind::Binding(_, id, ref name, ref sub) => {
let var_ty = self.tables.node_id_to_type(pat.hir_id);
let region = match var_ty.sty {
ty::TyRef(r, _) => Some(r),
Expand All @@ -493,14 +493,14 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
if let ty::TyRef(_, mt) = ty.sty {
ty = mt.ty;
} else {
bug!("`ref {}` has wrong type {}", ident.node, ty);
bug!("`ref {}` has wrong type {}", name.node, ty);
}
}

PatternKind::Binding {
mutability,
mode,
name: ident.node,
name: name.node,
var: id,
ty: var_ty,
subpattern: self.lower_opt_pattern(sub),
Expand Down
15 changes: 7 additions & 8 deletions src/librustc_resolve/build_reduced_graph.rs
Expand Up @@ -34,7 +34,6 @@ use syntax::attr;

use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId};
use syntax::ast::{Mutability, StmtKind, TraitItem, TraitItemKind, Variant};
use syntax::codemap::respan;
use syntax::ext::base::SyntaxExtension;
use syntax::ext::base::Determinacy::Undetermined;
use syntax::ext::hygiene::Mark;
Expand Down Expand Up @@ -115,13 +114,13 @@ impl<'a> Resolver<'a> {

let mut module_path: Vec<_> = prefix.segments.iter()
.chain(path.segments.iter())
.map(|seg| respan(seg.span, seg.ident))
.map(|seg| seg.ident)
.collect();

match use_tree.kind {
ast::UseTreeKind::Simple(rename) => {
let mut ident = use_tree.ident();
let mut source = module_path.pop().unwrap().node;
let mut source = module_path.pop().unwrap();
let mut type_ns_only = false;

if nested {
Expand All @@ -130,7 +129,7 @@ impl<'a> Resolver<'a> {
type_ns_only = true;

let last_segment = *module_path.last().unwrap();
if last_segment.node.name == keywords::CrateRoot.name() {
if last_segment.name == keywords::CrateRoot.name() {
resolve_error(
self,
use_tree.span,
Expand All @@ -142,9 +141,9 @@ impl<'a> Resolver<'a> {

// Replace `use foo::self;` with `use foo;`
let _ = module_path.pop();
source = last_segment.node;
source = last_segment;
if rename.is_none() {
ident = last_segment.node;
ident = last_segment;
}
}
} else {
Expand Down Expand Up @@ -195,8 +194,8 @@ impl<'a> Resolver<'a> {
}
ast::UseTreeKind::Nested(ref items) => {
let prefix = ast::Path {
segments: module_path.iter()
.map(|s| ast::PathSegment::from_ident(s.node, s.span))
segments: module_path.into_iter()
.map(|ident| ast::PathSegment::from_ident(ident, ident.span))
.collect(),
span: path.span,
};
Expand Down

0 comments on commit e2afefd

Please sign in to comment.