Remove more duplicated spans

This commit is contained in:
Vadim Petrochenkov 2018-03-19 03:54:56 +03:00
parent 62000c072e
commit b3b5ef186c
33 changed files with 181 additions and 200 deletions

View file

@ -1099,13 +1099,15 @@ impl TokenTree {
self::TokenTree::Term(tt) => {
let ident = ast::Ident::new(tt.sym, tt.span.0);
let sym_str = tt.sym.as_str();
let token =
if sym_str.starts_with("'") { Lifetime(ident) }
else if sym_str.starts_with("r#") {
let name = Symbol::intern(&sym_str[2..]);
let ident = ast::Ident { name, ctxt: tt.span.0.ctxt() };
Ident(ident, true)
} else { Ident(ident, false) };
let token = if sym_str.starts_with("'") {
Lifetime(ident)
} else if sym_str.starts_with("r#") {
let name = Symbol::intern(&sym_str[2..]);
let ident = ast::Ident::new(name, ident.span);
Ident(ident, true)
} else {
Ident(ident, false)
};
return TokenTree::Token(tt.span.0, token).into();
}
self::TokenTree::Literal(self::Literal {

View file

@ -920,7 +920,7 @@ impl<'a> LoweringContext<'a> {
fn lower_label(&mut self, label: Option<Label>) -> Option<hir::Label> {
label.map(|label| hir::Label {
name: label.ident.name,
span: label.span,
span: label.ident.span,
})
}
@ -1810,7 +1810,7 @@ impl<'a> LoweringContext<'a> {
default: tp.default
.as_ref()
.map(|x| self.lower_ty(x, ImplTraitContext::Disallowed)),
span: tp.span,
span: tp.ident.span,
pure_wrt_drop: attr::contains_name(&tp.attrs, "may_dangle"),
synthetic: tp.attrs
.iter()
@ -1822,21 +1822,22 @@ impl<'a> LoweringContext<'a> {
}
fn lower_lifetime(&mut self, l: &Lifetime) -> hir::Lifetime {
let span = l.ident.span;
match self.lower_ident(l.ident) {
x if x == "'static" => self.new_named_lifetime(l.id, l.span, hir::LifetimeName::Static),
x if x == "'static" => self.new_named_lifetime(l.id, span, hir::LifetimeName::Static),
x if x == "'_" => match self.anonymous_lifetime_mode {
AnonymousLifetimeMode::CreateParameter => {
let fresh_name = self.collect_fresh_in_band_lifetime(l.span);
self.new_named_lifetime(l.id, l.span, fresh_name)
let fresh_name = self.collect_fresh_in_band_lifetime(span);
self.new_named_lifetime(l.id, span, fresh_name)
}
AnonymousLifetimeMode::PassThrough => {
self.new_named_lifetime(l.id, l.span, hir::LifetimeName::Underscore)
self.new_named_lifetime(l.id, span, hir::LifetimeName::Underscore)
}
},
name => {
self.maybe_collect_in_band_lifetime(l.span, name);
self.new_named_lifetime(l.id, l.span, hir::LifetimeName::Name(name))
self.maybe_collect_in_band_lifetime(span, name);
self.new_named_lifetime(l.id, span, hir::LifetimeName::Name(name))
}
}
}
@ -2936,7 +2937,7 @@ impl<'a> LoweringContext<'a> {
ImplTraitContext::Disallowed,
);
let args = args.iter().map(|x| self.lower_expr(x)).collect();
hir::ExprMethodCall(hir_seg, seg.span, args)
hir::ExprMethodCall(hir_seg, seg.ident.span, args)
}
ExprKind::Binary(binop, ref lhs, ref rhs) => {
let binop = self.lower_binop(binop);

View file

@ -202,7 +202,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
lifetime_def.lifetime.id,
DefPathData::LifetimeDef(lifetime_def.lifetime.ident.name.as_str()),
REGULAR_SPACE,
lifetime_def.lifetime.span
lifetime_def.lifetime.ident.span
);
}
GenericParam::Type(ref ty_param) => {
@ -210,7 +210,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
ty_param.id,
DefPathData::TypeParam(ty_param.ident.name.as_str()),
REGULAR_SPACE,
ty_param.span
ty_param.ident.span
);
}
}

View file

@ -162,7 +162,7 @@ impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, span, ident });
impl_stable_hash_for!(struct ::syntax::ast::Lifetime { id, ident });
impl_stable_hash_for!(enum ::syntax::ast::StrStyle { Cooked, Raw(pounds) });
impl_stable_hash_for!(enum ::syntax::ast::AttrStyle { Outer, Inner });

View file

@ -952,8 +952,8 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
ast_visit::walk_ty(self, t);
}
fn visit_ident(&mut self, sp: Span, id: ast::Ident) {
run_lints!(self, check_ident, early_passes, sp, id);
fn visit_ident(&mut self, ident: ast::Ident) {
run_lints!(self, check_ident, early_passes, ident);
}
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, _a: &[ast::Attribute], n: ast::NodeId) {

View file

@ -236,7 +236,7 @@ pub trait LateLintPass<'a, 'tcx>: LintPass {
}
pub trait EarlyLintPass: LintPass {
fn check_ident(&mut self, _: &EarlyContext, _: Span, _: ast::Ident) { }
fn check_ident(&mut self, _: &EarlyContext, _: ast::Ident) { }
fn check_crate(&mut self, _: &EarlyContext, _: &ast::Crate) { }
fn check_crate_post(&mut self, _: &EarlyContext, _: &ast::Crate) { }
fn check_mod(&mut self, _: &EarlyContext, _: &ast::Mod, _: Span, _: ast::NodeId) { }

View file

@ -36,19 +36,20 @@ impl<'a> AstValidator<'a> {
&self.session.parse_sess.span_diagnostic
}
fn check_lifetime(&self, lifetime: &Lifetime) {
fn check_lifetime(&self, ident: Ident) {
let valid_names = [keywords::UnderscoreLifetime.name(),
keywords::StaticLifetime.name(),
keywords::Invalid.name()];
if !valid_names.contains(&lifetime.ident.name) &&
token::is_reserved_ident(lifetime.ident.without_first_quote()) {
self.err_handler().span_err(lifetime.span, "lifetimes cannot use keyword names");
if !valid_names.contains(&ident.name) &&
token::is_reserved_ident(ident.without_first_quote()) {
self.err_handler().span_err(ident.span, "lifetimes cannot use keyword names");
}
}
fn check_label(&self, label: Ident, span: Span) {
if token::is_reserved_ident(label.without_first_quote()) {
self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name));
fn check_label(&self, ident: Ident) {
if token::is_reserved_ident(ident.without_first_quote()) {
self.err_handler()
.span_err(ident.span, &format!("invalid label name `{}`", ident.name));
}
}
@ -144,7 +145,7 @@ impl<'a> AstValidator<'a> {
let non_lifetime_param_spans : Vec<_> = params.iter()
.filter_map(|param| match *param {
GenericParam::Lifetime(_) => None,
GenericParam::Type(ref t) => Some(t.span),
GenericParam::Type(ref t) => Some(t.ident.span),
}).collect();
if !non_lifetime_param_spans.is_empty() {
self.err_handler().span_err(non_lifetime_param_spans,
@ -156,7 +157,7 @@ impl<'a> AstValidator<'a> {
match *param {
GenericParam::Lifetime(ref l) => {
if !l.bounds.is_empty() {
let spans : Vec<_> = l.bounds.iter().map(|b| b.span).collect();
let spans: Vec<_> = l.bounds.iter().map(|b| b.ident.span).collect();
self.err_handler().span_err(spans,
"lifetime bounds cannot be used in this context");
}
@ -193,7 +194,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
for bound in bounds {
if let RegionTyParamBound(ref lifetime) = *bound {
if any_lifetime_bounds {
span_err!(self.session, lifetime.span, E0226,
span_err!(self.session, lifetime.ident.span, E0226,
"only a single explicit lifetime bound is permitted");
break;
}
@ -234,12 +235,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
fn visit_label(&mut self, label: &'a Label) {
self.check_label(label.ident, label.span);
self.check_label(label.ident);
visit::walk_label(self, label);
}
fn visit_lifetime(&mut self, lifetime: &'a Lifetime) {
self.check_lifetime(lifetime);
self.check_lifetime(lifetime.ident);
visit::walk_lifetime(self, lifetime);
}
@ -328,19 +329,19 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
ItemKind::TraitAlias(Generics { ref params, .. }, ..) => {
for param in params {
if let GenericParam::Type(TyParam {
ident,
ref bounds,
ref default,
span,
..
}) = *param
{
if !bounds.is_empty() {
self.err_handler().span_err(span,
self.err_handler().span_err(ident.span,
"type parameters on the left side of a \
trait alias cannot be bounded");
}
if !default.is_none() {
self.err_handler().span_err(span,
self.err_handler().span_err(ident.span,
"type parameters on the left side of a \
trait alias cannot have defaults");
}
@ -408,7 +409,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
match (param, seen_non_lifetime_param) {
(&GenericParam::Lifetime(ref ld), true) => {
self.err_handler()
.span_err(ld.lifetime.span, "lifetime parameters must be leading");
.span_err(ld.lifetime.ident.span, "lifetime parameters must be leading");
},
(&GenericParam::Lifetime(_), false) => {}
_ => {
@ -417,7 +418,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
if let GenericParam::Type(ref ty_param @ TyParam { default: Some(_), .. }) = *param {
seen_default = Some(ty_param.span);
seen_default = Some(ty_param.ident.span);
} else if let Some(span) = seen_default {
self.err_handler()
.span_err(span, "type parameters with a default must be trailing");

View file

@ -195,7 +195,7 @@ impl<'a> Resolver<'a> {
ast::UseTreeKind::Nested(ref items) => {
let prefix = ast::Path {
segments: module_path.into_iter()
.map(|ident| ast::PathSegment::from_ident(ident, ident.span))
.map(|ident| ast::PathSegment::from_ident(ident))
.collect(),
span: path.span,
};

View file

@ -2281,9 +2281,9 @@ impl<'a> Resolver<'a> {
ident.name,
span,
);
resolve_error(self, type_parameter.span, err);
resolve_error(self, type_parameter.ident.span, err);
}
seen_bindings.entry(ident).or_insert(type_parameter.span);
seen_bindings.entry(ident).or_insert(type_parameter.ident.span);
// plain insert (no renaming)
let def_id = self.definitions.local_def_id(type_parameter.id);
@ -3634,7 +3634,7 @@ impl<'a> Resolver<'a> {
});
self.record_def(expr.id, err_path_resolution());
resolve_error(self,
label.span,
label.ident.span,
ResolutionError::UndeclaredLabel(&label.ident.name.as_str(),
close_match));
}
@ -3865,7 +3865,7 @@ impl<'a> Resolver<'a> {
if filter_fn(name_binding.def()) {
// create the path
let mut segms = path_segments.clone();
segms.push(ast::PathSegment::from_ident(ident, name_binding.span));
segms.push(ast::PathSegment::from_ident(ident));
let path = Path {
span: name_binding.span,
segments: segms,
@ -3887,7 +3887,7 @@ impl<'a> Resolver<'a> {
if let Some(module) = name_binding.module() {
// form the path
let mut path_segments = path_segments.clone();
path_segments.push(ast::PathSegment::from_ident(ident, name_binding.span));
path_segments.push(ast::PathSegment::from_ident(ident));
if !in_module_is_extern || name_binding.vis == ty::Visibility::Public {
// add the module to the lookup
@ -3926,7 +3926,7 @@ impl<'a> Resolver<'a> {
if let Some(module) = name_binding.module() {
// form the path
let mut path_segments = path_segments.clone();
path_segments.push(ast::PathSegment::from_ident(ident, name_binding.span));
path_segments.push(ast::PathSegment::from_ident(ident));
if module.def() == Some(module_def) {
let path = Path {
span: name_binding.span,
@ -3958,7 +3958,7 @@ impl<'a> Resolver<'a> {
enum_module.for_each_child_stable(|ident, _, name_binding| {
if let Def::Variant(..) = name_binding.def() {
let mut segms = enum_import_suggestion.path.segments.clone();
segms.push(ast::PathSegment::from_ident(ident, name_binding.span));
segms.push(ast::PathSegment::from_ident(ident));
variants.push(Path {
span: name_binding.span,
segments: segms,

View file

@ -141,10 +141,10 @@ impl<'a> base::Resolver for Resolver<'a> {
path.segments[0].ident.name = keywords::CrateRoot.name();
let module = self.0.resolve_crate_root(ident.span.ctxt(), true);
if !module.is_local() {
let span = path.segments[0].span;
let span = path.segments[0].ident.span;
path.segments.insert(1, match module.kind {
ModuleKind::Def(_, name) => ast::PathSegment::from_ident(
ast::Ident::with_empty_ctxt(name), span
ast::Ident::with_empty_ctxt(name).with_span_pos(span)
),
_ => unreachable!(),
})
@ -277,7 +277,7 @@ impl<'a> base::Resolver for Resolver<'a> {
}).into();
}
return Some(ast::Attribute {
path: ast::Path::from_ident(span, Ident::with_empty_ctxt(legacy_name)),
path: ast::Path::from_ident(Ident::new(legacy_name, span)),
tokens: TokenStream::empty(),
id: attr::mk_attr_id(),
style: ast::AttrStyle::Outer,

View file

@ -183,7 +183,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
for (i, seg) in segments.iter().enumerate() {
segs.push(seg.clone());
let sub_path = ast::Path {
span: seg.span, // span for the last segment
span: seg.ident.span, // span for the last segment
segments: segs,
};
let qualname = if i == 0 && path.is_global() {
@ -191,7 +191,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
} else {
path_to_string(&sub_path)
};
result.push((seg.span, qualname));
result.push((seg.ident.span, qualname));
segs = sub_path.segments;
}
@ -351,14 +351,14 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
collector.visit_pat(&arg.pat);
let span_utils = self.span.clone();
for (id, i, sp, ..) in collector.collected_idents {
for (id, ident, ..) in collector.collected_idents {
let hir_id = self.tcx.hir.node_to_hir_id(id);
let typ = match self.save_ctxt.tables.node_id_to_type_opt(hir_id) {
Some(s) => s.to_string(),
None => continue,
};
let sub_span = span_utils.span_for_last_ident(sp);
if !self.span.filter_generated(sub_span, sp) {
let sub_span = span_utils.span_for_last_ident(ident.span);
if !self.span.filter_generated(sub_span, ident.span) {
let id = ::id_from_node_id(id, &self.save_ctxt);
let span = self.span_from_span(sub_span.expect("No span found for variable"));
@ -371,8 +371,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
kind: DefKind::Local,
id,
span,
name: i.to_string(),
qualname: format!("{}::{}", qualname, i.to_string()),
name: ident.to_string(),
qualname: format!("{}::{}", qualname, ident.to_string()),
value: typ,
parent: None,
children: vec![],
@ -447,7 +447,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
) {
for param in &generics.params {
if let ast::GenericParam::Type(ref ty_param) = *param {
let param_ss = ty_param.span;
let param_ss = ty_param.ident.span;
let name = escape(self.span.snippet(param_ss));
// Append $id to name to make sure each one is unique
let qualname = format!("{}::{}${}", prefix, name, id);
@ -1040,11 +1040,11 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
}
// process collected paths
for (id, i, sp, immut) in collector.collected_idents {
for (id, ident, immut) in collector.collected_idents {
match self.save_ctxt.get_path_def(id) {
HirDef::Local(id) => {
let mut value = if immut == ast::Mutability::Immutable {
self.span.snippet(sp).to_string()
self.span.snippet(ident.span).to_string()
} else {
"<mutable>".to_string()
};
@ -1057,10 +1057,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
value.push_str(": ");
value.push_str(&typ);
if !self.span.filter_generated(Some(sp), sp) {
let qualname = format!("{}${}", i.to_string(), id);
if !self.span.filter_generated(Some(ident.span), ident.span) {
let qualname = format!("{}${}", ident.to_string(), id);
let id = ::id_from_node_id(id, &self.save_ctxt);
let span = self.span_from_span(sp);
let span = self.span_from_span(ident.span);
self.dumper.dump_def(
&Access {
@ -1071,7 +1071,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
kind: DefKind::Local,
id,
span,
name: i.to_string(),
name: ident.to_string(),
qualname,
value: typ,
parent: None,
@ -1093,7 +1093,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
HirDef::TyAlias(..) |
HirDef::AssociatedTy(..) |
HirDef::SelfTy(..) => {
self.dump_path_ref(id, &ast::Path::from_ident(sp, i));
self.dump_path_ref(id, &ast::Path::from_ident(ident));
}
def => error!(
"unexpected definition kind when processing collected idents: {:?}",
@ -1114,7 +1114,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
collector.visit_pat(&p);
self.visit_pat(&p);
for (id, i, sp, immut) in collector.collected_idents {
for (id, ident, immut) in collector.collected_idents {
let mut value = match immut {
ast::Mutability::Immutable => value.to_string(),
_ => String::new(),
@ -1134,10 +1134,10 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
// Get the span only for the name of the variable (I hope the path
// is only ever a variable name, but who knows?).
let sub_span = self.span.span_for_last_ident(sp);
let sub_span = self.span.span_for_last_ident(ident.span);
// Rust uses the id of the pattern for var lookups, so we'll use it too.
if !self.span.filter_generated(sub_span, sp) {
let qualname = format!("{}${}", i.to_string(), id);
if !self.span.filter_generated(sub_span, ident.span) {
let qualname = format!("{}${}", ident.to_string(), id);
let id = ::id_from_node_id(id, &self.save_ctxt);
let span = self.span_from_span(sub_span.expect("No span found for variable"));
@ -1150,7 +1150,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
kind: DefKind::Local,
id,
span,
name: i.to_string(),
name: ident.to_string(),
qualname,
value: typ,
parent: None,

View file

@ -603,7 +603,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
ty::ImplContainer(_) => (Some(method_id), None),
ty::TraitContainer(_) => (None, Some(method_id)),
};
let sub_span = seg.span;
let sub_span = seg.ident.span;
filter!(self.span_utils, Some(sub_span), expr.span, None);
let span = self.span_from_span(sub_span);
Some(Data::RefData(Ref {
@ -707,7 +707,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
let def = self.get_path_def(id);
let last_seg = &path.segments[path.segments.len() - 1];
let sub_span = last_seg.span;
let sub_span = last_seg.ident.span;
filter!(self.span_utils, Some(sub_span), path.span, None);
match def {
HirDef::Upvar(id, ..) | HirDef::Local(id) => {
@ -961,7 +961,7 @@ fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String {
// variables (idents) from patterns.
struct PathCollector<'l> {
collected_paths: Vec<(NodeId, &'l ast::Path)>,
collected_idents: Vec<(NodeId, ast::Ident, Span, ast::Mutability)>,
collected_idents: Vec<(NodeId, ast::Ident, ast::Mutability)>,
}
impl<'l> PathCollector<'l> {
@ -997,7 +997,7 @@ impl<'l, 'a: 'l> Visitor<'a> for PathCollector<'l> {
ast::BindingMode::ByValue(mt) => mt,
};
self.collected_idents
.push((p.id, ident, ident.span, immut));
.push((p.id, ident, immut));
}
_ => {}
}

View file

@ -1146,7 +1146,7 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option
fn macro_resolve(cx: &DocContext, path_str: &str) -> Option<Def> {
use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::hygiene::Mark;
let segment = ast::PathSegment::from_ident(ast::Ident::from_str(path_str), DUMMY_SP);
let segment = ast::PathSegment::from_ident(ast::Ident::from_str(path_str));
let path = ast::Path { segments: vec![segment], span: DUMMY_SP };
let mut resolver = cx.resolver.borrow_mut();
let mark = Mark::root();

View file

@ -36,7 +36,6 @@ use std::u32;
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub struct Label {
pub ident: Ident,
pub span: Span,
}
impl fmt::Debug for Label {
@ -48,7 +47,6 @@ impl fmt::Debug for Label {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub struct Lifetime {
pub id: NodeId,
pub span: Span,
pub ident: Ident,
}
@ -101,11 +99,8 @@ impl fmt::Display for Path {
impl Path {
// convert a span and an identifier to the corresponding
// 1-segment path
pub fn from_ident(s: Span, ident: Ident) -> Path {
Path {
span: s,
segments: vec![PathSegment::from_ident(ident, s)],
}
pub fn from_ident(ident: Ident) -> Path {
Path { segments: vec![PathSegment::from_ident(ident)], span: ident.span }
}
// Make a "crate root" segment for this path unless it already has it
@ -132,8 +127,6 @@ impl Path {
pub struct PathSegment {
/// The identifier portion of this path segment.
pub ident: Ident,
/// Span of the segment identifier.
pub span: Span,
/// Type/lifetime parameters attached to this path. They come in
/// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`.
@ -145,11 +138,11 @@ pub struct PathSegment {
}
impl PathSegment {
pub fn from_ident(ident: Ident, span: Span) -> Self {
PathSegment { ident, span, parameters: None }
pub fn from_ident(ident: Ident) -> Self {
PathSegment { ident, parameters: None }
}
pub fn crate_root(span: Span) -> Self {
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span), span)
PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span))
}
}
@ -293,7 +286,7 @@ impl TyParamBound {
pub fn span(&self) -> Span {
match self {
&TraitTyParamBound(ref t, ..) => t.span,
&RegionTyParamBound(ref l) => l.span,
&RegionTyParamBound(ref l) => l.ident.span,
}
}
}
@ -315,7 +308,6 @@ pub struct TyParam {
pub id: NodeId,
pub bounds: TyParamBounds,
pub default: Option<P<Ty>>,
pub span: Span,
}
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@ -366,7 +358,7 @@ impl Generics {
for param in &self.params {
if let GenericParam::Type(ref t) = *param {
if t.ident.name == name {
return Some(t.span);
return Some(t.ident.span);
}
}
}
@ -541,7 +533,7 @@ impl Pat {
let node = match &self.node {
PatKind::Wild => TyKind::Infer,
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None) =>
TyKind::Path(None, Path::from_ident(ident.span, *ident)),
TyKind::Path(None, Path::from_ident(*ident)),
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
PatKind::Ref(pat, mutbl) =>

View file

@ -436,10 +436,11 @@ pub fn mk_attr_inner(span: Span, id: AttrId, item: MetaItem) -> Attribute {
/// Returns an inner attribute with the given value and span.
pub fn mk_spanned_attr_inner(sp: Span, id: AttrId, item: MetaItem) -> Attribute {
let ident = ast::Ident::with_empty_ctxt(item.name).with_span_pos(item.span);
Attribute {
id,
style: ast::AttrStyle::Inner,
path: ast::Path::from_ident(item.span, ast::Ident::with_empty_ctxt(item.name)),
path: ast::Path::from_ident(ident),
tokens: item.node.tokens(item.span),
is_sugared_doc: false,
span: sp,
@ -454,10 +455,11 @@ pub fn mk_attr_outer(span: Span, id: AttrId, item: MetaItem) -> Attribute {
/// Returns an outer attribute with the given value and span.
pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute {
let ident = ast::Ident::with_empty_ctxt(item.name).with_span_pos(item.span);
Attribute {
id,
style: ast::AttrStyle::Outer,
path: ast::Path::from_ident(item.span, ast::Ident::with_empty_ctxt(item.name)),
path: ast::Path::from_ident(ident),
tokens: item.node.tokens(item.span),
is_sugared_doc: false,
span: sp,
@ -470,7 +472,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, span: Span) -> Attribute {
Attribute {
id,
style,
path: ast::Path::from_ident(span, ast::Ident::from_str("doc")),
path: ast::Path::from_ident(ast::Ident::from_str("doc").with_span_pos(span)),
tokens: MetaItemKind::NameValue(lit).tokens(span),
is_sugared_doc: true,
span,

View file

@ -322,13 +322,15 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
let last_ident = idents.pop().unwrap();
let mut segments: Vec<ast::PathSegment> = Vec::new();
segments.extend(idents.into_iter().map(|i| ast::PathSegment::from_ident(i, span)));
segments.extend(idents.into_iter().map(|ident| {
ast::PathSegment::from_ident(ident.with_span_pos(span))
}));
let parameters = if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() {
ast::AngleBracketedParameterData { lifetimes, types, bindings, span }.into()
} else {
None
};
segments.push(ast::PathSegment { ident: last_ident, span, parameters });
segments.push(ast::PathSegment { ident: last_ident.with_span_pos(span), parameters });
let mut path = ast::Path { span, segments };
if global {
if let Some(seg) = path.make_root() {
@ -366,7 +368,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
} else {
None
};
path.segments.push(ast::PathSegment { ident, span: ident.span, parameters });
path.segments.push(ast::PathSegment { ident, parameters });
(ast::QSelf {
ty: self_type,
@ -435,17 +437,16 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn typaram(&self,
span: Span,
id: ast::Ident,
ident: ast::Ident,
attrs: Vec<ast::Attribute>,
bounds: ast::TyParamBounds,
default: Option<P<ast::Ty>>) -> ast::TyParam {
ast::TyParam {
ident: id,
ident: ident.with_span_pos(span),
id: ast::DUMMY_NODE_ID,
attrs: attrs.into(),
bounds,
default,
span,
}
}
@ -469,7 +470,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
}
fn lifetime(&self, span: Span, ident: ast::Ident) -> ast::Lifetime {
ast::Lifetime { id: ast::DUMMY_NODE_ID, span: span, ident: ident }
ast::Lifetime { id: ast::DUMMY_NODE_ID, ident: ident.with_span_pos(span) }
}
fn lifetime_def(&self,
@ -662,7 +663,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
ident: ast::Ident,
mut args: Vec<P<ast::Expr>> ) -> P<ast::Expr> {
args.insert(0, expr);
self.expr(span, ast::ExprKind::MethodCall(ast::PathSegment::from_ident(ident, span), args))
let segment = ast::PathSegment::from_ident(ident.with_span_pos(span));
self.expr(span, ast::ExprKind::MethodCall(segment, args))
}
fn expr_block(&self, b: P<ast::Block>) -> P<ast::Expr> {
self.expr(b.span, ast::ExprKind::Block(b))

View file

@ -193,7 +193,7 @@ pub mod rt {
impl ToTokens for ast::Lifetime {
fn to_tokens(&self, _cx: &ExtCtxt) -> Vec<TokenTree> {
vec![TokenTree::Token(DUMMY_SP, token::Lifetime(self.ident))]
vec![TokenTree::Token(self.ident.span, token::Lifetime(self.ident))]
}
}

View file

@ -823,7 +823,7 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
"expr" => token::NtExpr(panictry!(p.parse_expr())),
"ty" => token::NtTy(panictry!(p.parse_ty())),
// this could be handled like a token, since it is one
"ident" => if let Some((ident, is_raw))) = get_macro_ident(&p.token) {
"ident" => if let Some((ident, is_raw)) = get_macro_ident(&p.token) {
let span = p.span;
p.bump();
token::NtIdent(Ident::new(ident.name, span), is_raw)

View file

@ -53,7 +53,7 @@ impl<'a> ParserAnyMacro<'a> {
}
// Make sure we don't have any tokens left to parse so we don't silently drop anything.
let path = ast::Path::from_ident(site_span, macro_ident);
let path = ast::Path::from_ident(macro_ident.with_span_pos(site_span));
parser.ensure_complete_parse(&path, kind.name(), site_span);
expansion
}

View file

@ -1767,10 +1767,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
fn visit_path(&mut self, path: &'a ast::Path, _id: NodeId) {
for segment in &path.segments {
if segment.ident.name == keywords::Crate.name() {
gate_feature_post!(&self, crate_in_paths, segment.span,
gate_feature_post!(&self, crate_in_paths, segment.ident.span,
"`crate` in paths is experimental");
} else if segment.ident.name == keywords::Extern.name() {
gate_feature_post!(&self, extern_in_paths, segment.span,
gate_feature_post!(&self, extern_in_paths, segment.ident.span,
"`extern` in paths is experimental");
}
}

View file

@ -449,9 +449,8 @@ pub fn noop_fold_usize<T: Folder>(i: usize, _: &mut T) -> usize {
pub fn noop_fold_path<T: Folder>(Path { segments, span }: Path, fld: &mut T) -> Path {
Path {
segments: segments.move_map(|PathSegment {ident, span, parameters}| PathSegment {
segments: segments.move_map(|PathSegment {ident, parameters}| PathSegment {
ident: fld.fold_ident(ident),
span: fld.new_span(span),
parameters: parameters.map(|ps| ps.map(|ps| fld.fold_path_parameters(ps))),
}),
span: fld.new_span(span)
@ -679,7 +678,7 @@ pub fn noop_fold_ty_param_bound<T>(tpb: TyParamBound, fld: &mut T)
}
pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
let TyParam {attrs, id, ident, bounds, default, span} = tp;
let TyParam {attrs, id, ident, bounds, default} = tp;
let attrs: Vec<_> = attrs.into();
TyParam {
attrs: attrs.into_iter()
@ -690,7 +689,6 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
ident: fld.fold_ident(ident),
bounds: fld.fold_bounds(bounds),
default: default.map(|x| fld.fold_ty(x)),
span: fld.new_span(span),
}
}
@ -711,7 +709,6 @@ pub fn noop_fold_generic_params<T: Folder>(
pub fn noop_fold_label<T: Folder>(label: Label, fld: &mut T) -> Label {
Label {
ident: fld.fold_ident(label.ident),
span: fld.new_span(label.span),
}
}
@ -719,7 +716,6 @@ pub fn noop_fold_lifetime<T: Folder>(l: Lifetime, fld: &mut T) -> Lifetime {
Lifetime {
id: fld.new_id(l.id),
ident: fld.fold_ident(l.ident),
span: fld.new_span(l.span)
}
}
@ -1194,7 +1190,6 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
ExprKind::MethodCall(
PathSegment {
ident: folder.fold_ident(seg.ident),
span: folder.new_span(seg.span),
parameters: seg.parameters.map(|ps| {
ps.map(|ps| folder.fold_path_parameters(ps))
}),

View file

@ -149,7 +149,7 @@ impl<'a> Parser<'a> {
};
Ok(if let Some(meta) = meta {
self.bump();
(ast::Path::from_ident(meta.span, ast::Ident::with_empty_ctxt(meta.name)),
(ast::Path::from_ident(ast::Ident::with_empty_ctxt(meta.name).with_span_pos(meta.span)),
meta.node.tokens(meta.span))
} else {
(self.parse_path(PathStyle::Mod)?, self.parse_tokens())

View file

@ -689,7 +689,7 @@ mod tests {
}
fn str2seg(s: &str, lo: u32, hi: u32) -> ast::PathSegment {
ast::PathSegment::from_ident(Ident::from_str(s), sp(lo, hi))
ast::PathSegment::from_ident(Ident::new(Symbol::intern(s), sp(lo, hi)))
}
#[test] fn path_exprs_1() {

View file

@ -1317,19 +1317,6 @@ impl<'a> Parser<'a> {
self.check_keyword(keywords::Extern) && self.is_extern_non_path()
}
fn eat_label(&mut self) -> Option<Label> {
let ident = match self.token {
token::Lifetime(ident) => ident,
token::Interpolated(ref nt) => match nt.0 {
token::NtLifetime(lifetime) => lifetime.ident,
_ => return None,
},
_ => return None,
};
self.bump();
Some(Label { ident, span: self.prev_span })
}
/// parse a TyKind::BareFn type:
pub fn parse_ty_bare_fn(&mut self, generic_params: Vec<GenericParam>)
-> PResult<'a, TyKind> {
@ -1979,7 +1966,7 @@ impl<'a> Parser<'a> {
};
if let Some(ident) = meta_ident {
self.bump();
return Ok(ast::Path::from_ident(self.prev_span, ident));
return Ok(ast::Path::from_ident(ident.with_span_pos(self.prev_span)));
}
self.parse_path(style)
}
@ -2047,10 +2034,10 @@ impl<'a> Parser<'a> {
ParenthesizedParameterData { inputs, output, span }.into()
};
PathSegment { ident, span: ident.span, parameters }
PathSegment { ident, parameters }
} else {
// Generic arguments are not found.
PathSegment::from_ident(ident, ident.span)
PathSegment::from_ident(ident)
})
}
@ -2061,7 +2048,7 @@ impl<'a> Parser<'a> {
/// Parse single lifetime 'a or panic.
pub fn expect_lifetime(&mut self) -> Lifetime {
if let Some(lifetime) = self.token.lifetime(self.span) {
if let Some(lifetime) = self.token.lifetime2(self.span) {
self.bump();
lifetime
} else {
@ -2069,6 +2056,15 @@ impl<'a> Parser<'a> {
}
}
fn eat_label(&mut self) -> Option<Label> {
if let Some(lifetime) = self.token.lifetime2(self.span) {
self.bump();
Some(Label { ident: lifetime.ident })
} else {
None
}
}
/// Parse mutability (`mut` or nothing).
fn parse_mutability(&mut self) -> Mutability {
if self.eat_keyword(keywords::Mut) {
@ -2101,7 +2097,7 @@ impl<'a> Parser<'a> {
let fieldname = self.parse_ident_common(false)?;
// Mimic `x: x` for the `x` field shorthand.
let path = ast::Path::from_ident(fieldname.span, fieldname);
let path = ast::Path::from_ident(fieldname);
let expr = self.mk_expr(fieldname.span, ExprKind::Path(None, path), ThinVec::new());
(fieldname, expr, true)
};
@ -2312,7 +2308,7 @@ impl<'a> Parser<'a> {
return self.parse_while_expr(None, lo, attrs);
}
if let Some(label) = self.eat_label() {
let lo = label.span;
let lo = label.ident.span;
self.expect(&token::Colon)?;
if self.eat_keyword(keywords::While) {
return self.parse_while_expr(Some(label), lo, attrs)
@ -4689,7 +4685,6 @@ impl<'a> Parser<'a> {
/// Matches typaram = IDENT (`?` unbound)? optbounds ( EQ ty )?
fn parse_ty_param(&mut self, preceding_attrs: Vec<Attribute>) -> PResult<'a, TyParam> {
let span = self.span;
let ident = self.parse_ident()?;
// Parse optional colon and param bounds.
@ -4711,7 +4706,6 @@ impl<'a> Parser<'a> {
id: ast::DUMMY_NODE_ID,
bounds,
default,
span,
})
}
@ -4719,7 +4713,6 @@ impl<'a> Parser<'a> {
/// TraitItemAssocTy = Ident ["<"...">"] [":" [TyParamBounds]] ["where" ...] ["=" Ty]
fn parse_trait_item_assoc_ty(&mut self, preceding_attrs: Vec<Attribute>)
-> PResult<'a, (ast::Generics, TyParam)> {
let span = self.span;
let ident = self.parse_ident()?;
let mut generics = self.parse_generics()?;
@ -4744,7 +4737,6 @@ impl<'a> Parser<'a> {
id: ast::DUMMY_NODE_ID,
bounds,
default,
span,
}))
}
@ -5555,7 +5547,7 @@ impl<'a> Parser<'a> {
TyKind::Path(None, path) => path,
_ => {
self.span_err(ty_first.span, "expected a trait, found type");
ast::Path::from_ident(ty_first.span, keywords::Invalid.ident())
ast::Path::from_ident(Ident::new(keywords::Invalid.name(), ty_first.span))
}
};
let trait_ref = TraitRef { path, ref_id: ty_first.id };
@ -5940,8 +5932,7 @@ impl<'a> Parser<'a> {
let attr = Attribute {
id: attr::mk_attr_id(),
style: ast::AttrStyle::Outer,
path: ast::Path::from_ident(syntax_pos::DUMMY_SP,
Ident::from_str("warn_directory_ownership")),
path: ast::Path::from_ident(Ident::from_str("warn_directory_ownership")),
tokens: TokenStream::empty(),
is_sugared_doc: false,
span: syntax_pos::DUMMY_SP,

View file

@ -362,10 +362,10 @@ impl Token {
/// Returns a lifetime with the span and a dummy id if it is a lifetime,
/// or the original lifetime if it is an interpolated lifetime, ignoring
/// the span.
pub fn lifetime(&self, span: Span) -> Option<ast::Lifetime> {
pub fn lifetime2(&self, span: Span) -> Option<ast::Lifetime> {
match *self {
Lifetime(ident) =>
Some(ast::Lifetime { ident: ident, span: span, id: ast::DUMMY_NODE_ID }),
Lifetime(ident) => Some(ast::Lifetime { id: ast::DUMMY_NODE_ID,
ident: ast::Ident::new(ident.name, span) }),
Interpolated(ref nt) => match nt.0 {
NtLifetime(lifetime) => Some(lifetime),
_ => None,
@ -376,7 +376,7 @@ impl Token {
/// Returns `true` if the token is a lifetime.
pub fn is_lifetime(&self) -> bool {
self.lifetime(syntax_pos::DUMMY_SP).is_some()
self.lifetime2(syntax_pos::DUMMY_SP).is_some()
}
/// Returns `true` if the token is either the `mut` or `const` keyword.
@ -544,7 +544,7 @@ impl Token {
}
Nonterminal::NtLifetime(lifetime) => {
let token = Token::Lifetime(lifetime.ident);
tokens = Some(TokenTree::Token(lifetime.span, token).into());
tokens = Some(TokenTree::Token(lifetime.ident.span, token).into());
}
Nonterminal::NtTT(ref tt) => {
tokens = Some(tt.clone().into());

View file

@ -70,7 +70,7 @@ pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<&str>
krate.module.items.insert(0, P(ast::Item {
attrs: vec![ast::Attribute {
style: ast::AttrStyle::Outer,
path: ast::Path::from_ident(span, ast::Ident::from_str("prelude_import")),
path: ast::Path::from_ident(ast::Ident::new(Symbol::intern("prelude_import"), span)),
tokens: TokenStream::empty(),
id: attr::mk_attr_id(),
is_sugared_doc: false,
@ -80,7 +80,7 @@ pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<&str>
node: ast::ItemKind::Use(P(ast::UseTree {
prefix: ast::Path {
segments: [name, "prelude", "v1"].into_iter().map(|name| {
ast::PathSegment::from_ident(ast::Ident::from_str(name), DUMMY_SP)
ast::PathSegment::from_ident(ast::Ident::from_str(name))
}).collect(),
span,
},

View file

@ -623,7 +623,7 @@ fn nospan<T>(t: T) -> codemap::Spanned<T> {
fn path_node(ids: Vec<Ident>) -> ast::Path {
ast::Path {
span: DUMMY_SP,
segments: ids.into_iter().map(|id| ast::PathSegment::from_ident(id, DUMMY_SP)).collect(),
segments: ids.into_iter().map(|id| ast::PathSegment::from_ident(id)).collect(),
}
}

View file

@ -27,9 +27,9 @@ impl NodeCounter {
}
impl<'ast> Visitor<'ast> for NodeCounter {
fn visit_ident(&mut self, span: Span, ident: Ident) {
fn visit_ident(&mut self, ident: Ident) {
self.count += 1;
walk_ident(self, span, ident);
walk_ident(self, ident);
}
fn visit_mod(&mut self, m: &Mod, _s: Span, _a: &[Attribute], _n: NodeId) {
self.count += 1;

View file

@ -55,8 +55,8 @@ pub trait Visitor<'ast>: Sized {
fn visit_name(&mut self, _span: Span, _name: Name) {
// Nothing to do.
}
fn visit_ident(&mut self, span: Span, ident: Ident) {
walk_ident(self, span, ident);
fn visit_ident(&mut self, ident: Ident) {
walk_ident(self, ident);
}
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _attrs: &[Attribute], _n: NodeId) {
walk_mod(self, m);
@ -166,8 +166,8 @@ macro_rules! walk_list {
}
}
pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, span: Span, ident: Ident) {
visitor.visit_name(span, ident.name);
pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, ident: Ident) {
visitor.visit_name(ident.span, ident.name);
}
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
@ -189,11 +189,11 @@ pub fn walk_local<'a, V: Visitor<'a>>(visitor: &mut V, local: &'a Local) {
}
pub fn walk_label<'a, V: Visitor<'a>>(visitor: &mut V, label: &'a Label) {
visitor.visit_ident(label.span, label.ident);
visitor.visit_ident(label.ident);
}
pub fn walk_lifetime<'a, V: Visitor<'a>>(visitor: &mut V, lifetime: &'a Lifetime) {
visitor.visit_ident(lifetime.span, lifetime.ident);
visitor.visit_ident(lifetime.ident);
}
pub fn walk_poly_trait_ref<'a, V>(visitor: &mut V,
@ -211,7 +211,7 @@ pub fn walk_trait_ref<'a, V: Visitor<'a>>(visitor: &mut V, trait_ref: &'a TraitR
pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
visitor.visit_vis(&item.vis);
visitor.visit_ident(item.span, item.ident);
visitor.visit_ident(item.ident);
match item.node {
ItemKind::ExternCrate(orig_name) => {
if let Some(orig_name) = orig_name {
@ -293,7 +293,7 @@ pub fn walk_variant<'a, V>(visitor: &mut V,
item_id: NodeId)
where V: Visitor<'a>,
{
visitor.visit_ident(variant.span, variant.node.ident);
visitor.visit_ident(variant.node.ident);
visitor.visit_variant_data(&variant.node.data, variant.node.ident,
generics, item_id, variant.span);
walk_list!(visitor, visit_expr, &variant.node.disr_expr);
@ -357,7 +357,7 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>(
match use_tree.kind {
UseTreeKind::Simple(rename) => {
if let Some(rename) = rename {
visitor.visit_ident(use_tree.span, rename);
visitor.visit_ident(rename);
}
}
UseTreeKind::Glob => {},
@ -372,7 +372,7 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>(
pub fn walk_path_segment<'a, V: Visitor<'a>>(visitor: &mut V,
path_span: Span,
segment: &'a PathSegment) {
visitor.visit_ident(path_span, segment.ident);
visitor.visit_ident(segment.ident);
if let Some(ref parameters) = segment.parameters {
visitor.visit_path_parameters(path_span, parameters);
}
@ -398,7 +398,7 @@ pub fn walk_path_parameters<'a, V>(visitor: &mut V,
pub fn walk_assoc_type_binding<'a, V: Visitor<'a>>(visitor: &mut V,
type_binding: &'a TypeBinding) {
visitor.visit_ident(type_binding.span, type_binding.ident);
visitor.visit_ident(type_binding.ident);
visitor.visit_ty(&type_binding.ty);
}
@ -418,7 +418,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
visitor.visit_path(path, pattern.id);
for field in fields {
walk_list!(visitor, visit_attribute, field.node.attrs.iter());
visitor.visit_ident(field.span, field.node.ident);
visitor.visit_ident(field.node.ident);
visitor.visit_pat(&field.node.pat)
}
}
@ -431,7 +431,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
visitor.visit_pat(subpattern)
}
PatKind::Ident(_, ident, ref optional_subpattern) => {
visitor.visit_ident(ident.span, ident);
visitor.visit_ident(ident);
walk_list!(visitor, visit_pat, optional_subpattern);
}
PatKind::Lit(ref expression) => visitor.visit_expr(expression),
@ -451,7 +451,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, foreign_item: &'a ForeignItem) {
visitor.visit_vis(&foreign_item.vis);
visitor.visit_ident(foreign_item.span, foreign_item.ident);
visitor.visit_ident(foreign_item.ident);
match foreign_item.node {
ForeignItemKind::Fn(ref function_declaration, ref generics) => {
@ -489,7 +489,7 @@ pub fn walk_generic_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Generi
walk_list!(visitor, visit_attribute, &*l.attrs);
}
GenericParam::Type(ref t) => {
visitor.visit_ident(t.span, t.ident);
visitor.visit_ident(t.ident);
walk_list!(visitor, visit_ty_param_bound, &t.bounds);
walk_list!(visitor, visit_ty, &t.default);
walk_list!(visitor, visit_attribute, &*t.attrs);
@ -561,7 +561,7 @@ pub fn walk_fn<'a, V>(visitor: &mut V, kind: FnKind<'a>, declaration: &'a FnDecl
}
pub fn walk_trait_item<'a, V: Visitor<'a>>(visitor: &mut V, trait_item: &'a TraitItem) {
visitor.visit_ident(trait_item.span, trait_item.ident);
visitor.visit_ident(trait_item.ident);
walk_list!(visitor, visit_attribute, &trait_item.attrs);
visitor.visit_generics(&trait_item.generics);
match trait_item.node {
@ -588,7 +588,7 @@ pub fn walk_trait_item<'a, V: Visitor<'a>>(visitor: &mut V, trait_item: &'a Trai
pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplItem) {
visitor.visit_vis(&impl_item.vis);
visitor.visit_ident(impl_item.span, impl_item.ident);
visitor.visit_ident(impl_item.ident);
walk_list!(visitor, visit_attribute, &impl_item.attrs);
visitor.visit_generics(&impl_item.generics);
match impl_item.node {
@ -616,7 +616,7 @@ pub fn walk_struct_def<'a, V: Visitor<'a>>(visitor: &mut V, struct_definition: &
pub fn walk_struct_field<'a, V: Visitor<'a>>(visitor: &mut V, struct_field: &'a StructField) {
visitor.visit_vis(&struct_field.vis);
if let Some(ident) = struct_field.ident {
visitor.visit_ident(struct_field.span, ident);
visitor.visit_ident(ident);
}
visitor.visit_ty(&struct_field.ty);
walk_list!(visitor, visit_attribute, &struct_field.attrs);
@ -666,7 +666,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
visitor.visit_path(path, expression.id);
for field in fields {
walk_list!(visitor, visit_attribute, field.attrs.iter());
visitor.visit_ident(field.ident.span, field.ident);
visitor.visit_ident(field.ident);
visitor.visit_expr(&field.expr)
}
walk_list!(visitor, visit_expr, optional_base);
@ -747,7 +747,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
}
ExprKind::Field(ref subexpression, ident) => {
visitor.visit_expr(subexpression);
visitor.visit_ident(ident.span, ident);
visitor.visit_ident(ident);
}
ExprKind::TupField(ref subexpression, _) => {
visitor.visit_expr(subexpression);

View file

@ -14,6 +14,7 @@ use syntax::ext::base::*;
use syntax::ext::build::AstBuilder;
use syntax::parse::token;
use syntax::print::pprust;
use syntax::symbol::Symbol;
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax_pos::{Span, DUMMY_SP};
@ -37,7 +38,7 @@ pub fn expand_assert<'cx>(
let sp = sp.apply_mark(cx.current_expansion.mark);
let panic_call = Mac_ {
path: Path::from_ident(sp, Ident::from_str("panic")),
path: Path::from_ident(Ident::new(Symbol::intern("panic"), sp)),
tts: if let Some(ts) = custom_msg_args {
ts.into()
} else {

View file

@ -61,7 +61,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
fn make_expr(self: Box<Self>) -> Option<P<ast::Expr>> {
Some(P(ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident.span, self.ident)),
node: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)),
span: self.ident.span,
attrs: ast::ThinVec::new(),
}))
@ -70,7 +70,7 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
fn make_ty(self: Box<Self>) -> Option<P<ast::Ty>> {
Some(P(ast::Ty {
id: ast::DUMMY_NODE_ID,
node: ast::TyKind::Path(None, ast::Path::from_ident(self.ident.span, self.ident)),
node: ast::TyKind::Path(None, ast::Path::from_ident(self.ident)),
span: self.ident.span,
}))
}

View file

@ -61,7 +61,7 @@ fn expr(kind: ExprKind) -> P<Expr> {
}
fn make_x() -> P<Expr> {
let seg = PathSegment::from_ident(Ident::from_str("x"), DUMMY_SP);
let seg = PathSegment::from_ident(Ident::from_str("x"));
let path = Path { segments: vec![seg], span: DUMMY_SP };
expr(ExprKind::Path(None, path))
}
@ -82,7 +82,7 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
0 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Box(e))),
1 => iter_exprs(depth - 1, &mut |e| g(ExprKind::Call(e, vec![]))),
2 => {
let seg = PathSegment::from_ident(Ident::from_str("x"), DUMMY_SP);
let seg = PathSegment::from_ident(Ident::from_str("x"));
iter_exprs(depth - 1, &mut |e| g(ExprKind::MethodCall(
seg.clone(), vec![e, make_x()])));
iter_exprs(depth - 1, &mut |e| g(ExprKind::MethodCall(
@ -150,7 +150,7 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
iter_exprs(depth - 1, &mut |e| g(ExprKind::Ret(Some(e))));
},
14 => {
let path = Path::from_ident(DUMMY_SP, Ident::from_str("S"));
let path = Path::from_ident(Ident::from_str("S"));
g(ExprKind::Struct(path, vec![], Some(make_x())));
},
15 => {

View file

@ -1,8 +1,8 @@
error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:11:1
--> $DIR/feature-gate-non_ascii_idents.rs:11:22
|
LL | extern crate core as bäz; //~ ERROR non-ascii idents
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
@ -10,29 +10,23 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:13:5
|
LL | use föö::bar; //~ ERROR non-ascii idents
| ^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:15:1
--> $DIR/feature-gate-non_ascii_idents.rs:15:5
|
LL | mod föö { //~ ERROR non-ascii idents
| ^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:19:1
--> $DIR/feature-gate-non_ascii_idents.rs:19:4
|
LL | / fn bär( //~ ERROR non-ascii idents
LL | | bäz: isize //~ ERROR non-ascii idents
LL | | ) {
LL | | let _ö: isize; //~ ERROR non-ascii idents
... |
LL | | }
LL | | }
| |_^
LL | fn bär( //~ ERROR non-ascii idents
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
@ -61,10 +55,10 @@ LL | (_ä, _) => {} //~ ERROR non-ascii idents
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:29:1
--> $DIR/feature-gate-non_ascii_idents.rs:29:8
|
LL | struct Föö { //~ ERROR non-ascii idents
| ^^^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
@ -72,15 +66,15 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:30:5
|
LL | föö: isize //~ ERROR non-ascii idents
| ^^^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:33:1
--> $DIR/feature-gate-non_ascii_idents.rs:33:6
|
LL | enum Bär { //~ ERROR non-ascii idents
| ^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
@ -96,15 +90,15 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:35:9
|
LL | qüx: isize //~ ERROR non-ascii idents
| ^^^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
error[E0658]: non-ascii idents are not fully supported. (see issue #28979)
--> $DIR/feature-gate-non_ascii_idents.rs:40:5
--> $DIR/feature-gate-non_ascii_idents.rs:40:8
|
LL | fn qüx(); //~ ERROR non-ascii idents
| ^^^^^^^^^
| ^^^
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable