Replace dummy spans with empty spans
This commit is contained in:
parent
d6bdf296a4
commit
b5099a708d
16 changed files with 32 additions and 25 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 56444a4545bd71430d64b86b8a71714cfdbe9f5d
|
Subproject commit 2b4cd1016bdba92becb4f982a4dcb18fe6653bc4
|
|
@ -15,7 +15,7 @@ use syntax::ast::{Crate, Attribute, LitKind, StrStyle, ExprKind};
|
||||||
use syntax::ast::{Unsafety, Constness, Generics, Mutability, Ty, Mac, Arg};
|
use syntax::ast::{Unsafety, Constness, Generics, Mutability, Ty, Mac, Arg};
|
||||||
use syntax::ast::{self, Ident, Item, ItemKind, TyKind, VisibilityKind, Expr};
|
use syntax::ast::{self, Ident, Item, ItemKind, TyKind, VisibilityKind, Expr};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::dummy_spanned;
|
use syntax::codemap::{dummy_spanned, respan};
|
||||||
use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute};
|
use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute};
|
||||||
use syntax::ext::base::ExtCtxt;
|
use syntax::ext::base::ExtCtxt;
|
||||||
use syntax::ext::base::Resolver;
|
use syntax::ext::base::Resolver;
|
||||||
|
@ -97,7 +97,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
|
||||||
]);
|
]);
|
||||||
let mut items = vec![
|
let mut items = vec![
|
||||||
f.cx.item_extern_crate(f.span, f.alloc),
|
f.cx.item_extern_crate(f.span, f.alloc),
|
||||||
f.cx.item_use_simple(f.span, dummy_spanned(VisibilityKind::Inherited), super_path),
|
f.cx.item_use_simple(f.span, respan(f.span.empty(), VisibilityKind::Inherited), super_path),
|
||||||
];
|
];
|
||||||
for method in ALLOCATOR_METHODS {
|
for method in ALLOCATOR_METHODS {
|
||||||
items.push(f.allocator_fn(method));
|
items.push(f.allocator_fn(method));
|
||||||
|
|
|
@ -497,7 +497,7 @@ impl CrateStore for cstore::CStore {
|
||||||
tokens: body.into(),
|
tokens: body.into(),
|
||||||
legacy: def.legacy,
|
legacy: def.legacy,
|
||||||
}),
|
}),
|
||||||
vis: codemap::dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: codemap::respan(local_span.empty(), ast::VisibilityKind::Inherited),
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ use syntax::print::pprust::{
|
||||||
ty_to_string
|
ty_to_string
|
||||||
};
|
};
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::codemap::{Spanned, DUMMY_SP, dummy_spanned};
|
use syntax::codemap::{Spanned, DUMMY_SP, respan};
|
||||||
use syntax_pos::*;
|
use syntax_pos::*;
|
||||||
|
|
||||||
use {escape, generated_code, lower_attributes, PathCollector, SaveContext};
|
use {escape, generated_code, lower_attributes, PathCollector, SaveContext};
|
||||||
|
@ -1134,6 +1134,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
||||||
|
|
||||||
fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
|
fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
|
||||||
self.process_macro_use(trait_item.span);
|
self.process_macro_use(trait_item.span);
|
||||||
|
let vis_span = trait_item.span.empty();
|
||||||
match trait_item.node {
|
match trait_item.node {
|
||||||
ast::TraitItemKind::Const(ref ty, ref expr) => {
|
ast::TraitItemKind::Const(ref ty, ref expr) => {
|
||||||
self.process_assoc_const(
|
self.process_assoc_const(
|
||||||
|
@ -1143,7 +1144,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
||||||
&ty,
|
&ty,
|
||||||
expr.as_ref().map(|e| &**e),
|
expr.as_ref().map(|e| &**e),
|
||||||
trait_id,
|
trait_id,
|
||||||
dummy_spanned(ast::VisibilityKind::Public),
|
respan(vis_span, ast::VisibilityKind::Public),
|
||||||
&trait_item.attrs,
|
&trait_item.attrs,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1155,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
|
||||||
trait_item.id,
|
trait_item.id,
|
||||||
trait_item.ident,
|
trait_item.ident,
|
||||||
&trait_item.generics,
|
&trait_item.generics,
|
||||||
dummy_spanned(ast::VisibilityKind::Public),
|
respan(vis_span, ast::VisibilityKind::Public),
|
||||||
trait_item.span,
|
trait_item.span,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||||
ty,
|
ty,
|
||||||
expr,
|
expr,
|
||||||
),
|
),
|
||||||
vis: codemap::dummy_spanned(ast::VisibilityKind::Public),
|
vis: codemap::respan(span.empty(), ast::VisibilityKind::Public),
|
||||||
span,
|
span,
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})
|
})
|
||||||
|
|
|
@ -987,7 +987,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
attrs,
|
attrs,
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node,
|
node,
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: respan(span.empty(), ast::VisibilityKind::Inherited),
|
||||||
span,
|
span,
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})
|
})
|
||||||
|
@ -1033,7 +1033,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
span: ty.span,
|
span: ty.span,
|
||||||
ty,
|
ty,
|
||||||
ident: None,
|
ident: None,
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: respan(span.empty(), ast::VisibilityKind::Inherited),
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
node: ast::ItemKind::Mod(krate.module),
|
node: ast::ItemKind::Mod(krate.module),
|
||||||
ident: keywords::Invalid.ident(),
|
ident: keywords::Invalid.ident(),
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Public),
|
vis: respan(krate.span.empty(), ast::VisibilityKind::Public),
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Stmt, Ty};
|
use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Stmt, Ty};
|
||||||
use codemap::dummy_spanned;
|
use codemap::respan;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use ext::base::ExtCtxt;
|
use ext::base::ExtCtxt;
|
||||||
use ext::base;
|
use ext::base;
|
||||||
|
@ -858,7 +858,7 @@ fn expand_wrapper(cx: &ExtCtxt,
|
||||||
let path = path.iter().map(|s| s.to_string()).collect();
|
let path = path.iter().map(|s| s.to_string()).collect();
|
||||||
let use_item = cx.item_use_glob(
|
let use_item = cx.item_use_glob(
|
||||||
sp,
|
sp,
|
||||||
dummy_spanned(ast::VisibilityKind::Inherited),
|
respan(sp.empty(), ast::VisibilityKind::Inherited),
|
||||||
ids_ext(path),
|
ids_ext(path),
|
||||||
);
|
);
|
||||||
cx.stmt_item(sp, use_item)
|
cx.stmt_item(sp, use_item)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
use ast::*;
|
use ast::*;
|
||||||
use ast;
|
use ast;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use codemap::{Spanned, respan, dummy_spanned};
|
use codemap::{Spanned, respan};
|
||||||
use parse::token::{self, Token};
|
use parse::token::{self, Token};
|
||||||
use ptr::P;
|
use ptr::P;
|
||||||
use symbol::keywords;
|
use symbol::keywords;
|
||||||
|
@ -1018,7 +1018,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, span}: Crate,
|
||||||
ident: keywords::Invalid.ident(),
|
ident: keywords::Invalid.ident(),
|
||||||
attrs,
|
attrs,
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Public),
|
vis: respan(span.empty(), ast::VisibilityKind::Public),
|
||||||
span,
|
span,
|
||||||
node: ast::ItemKind::Mod(module),
|
node: ast::ItemKind::Mod(module),
|
||||||
tokens: None,
|
tokens: None,
|
||||||
|
|
|
@ -932,7 +932,7 @@ mod tests {
|
||||||
span: sp(15,21),
|
span: sp(15,21),
|
||||||
recovered: false,
|
recovered: false,
|
||||||
})),
|
})),
|
||||||
vis: codemap::dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: codemap::respan(sp(0, 0), ast::VisibilityKind::Inherited),
|
||||||
span: sp(0,21)})));
|
span: sp(0,21)})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1573,7 +1573,7 @@ impl<'a> State<'a> {
|
||||||
ti.ident,
|
ti.ident,
|
||||||
ty,
|
ty,
|
||||||
default.as_ref().map(|expr| &**expr),
|
default.as_ref().map(|expr| &**expr),
|
||||||
&codemap::dummy_spanned(ast::VisibilityKind::Inherited),
|
&codemap::respan(ti.span.empty(), ast::VisibilityKind::Inherited),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
ast::TraitItemKind::Method(ref sig, ref body) => {
|
ast::TraitItemKind::Method(ref sig, ref body) => {
|
||||||
|
@ -1584,7 +1584,7 @@ impl<'a> State<'a> {
|
||||||
ti.ident,
|
ti.ident,
|
||||||
&ti.generics,
|
&ti.generics,
|
||||||
sig,
|
sig,
|
||||||
&codemap::dummy_spanned(ast::VisibilityKind::Inherited),
|
&codemap::respan(ti.span.empty(), ast::VisibilityKind::Inherited),
|
||||||
)?;
|
)?;
|
||||||
if let Some(ref body) = *body {
|
if let Some(ref body) = *body {
|
||||||
self.nbsp()?;
|
self.nbsp()?;
|
||||||
|
|
|
@ -14,7 +14,7 @@ use std::cell::Cell;
|
||||||
use ext::hygiene::{Mark, SyntaxContext};
|
use ext::hygiene::{Mark, SyntaxContext};
|
||||||
use symbol::{Symbol, keywords};
|
use symbol::{Symbol, keywords};
|
||||||
use syntax_pos::{DUMMY_SP, Span};
|
use syntax_pos::{DUMMY_SP, Span};
|
||||||
use codemap::{ExpnInfo, NameAndSpan, MacroAttribute, dummy_spanned};
|
use codemap::{ExpnInfo, NameAndSpan, MacroAttribute, dummy_spanned, respan};
|
||||||
use ptr::P;
|
use ptr::P;
|
||||||
use tokenstream::TokenStream;
|
use tokenstream::TokenStream;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<Strin
|
||||||
is_sugared_doc: false,
|
is_sugared_doc: false,
|
||||||
span,
|
span,
|
||||||
}],
|
}],
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: respan(span.empty(), ast::VisibilityKind::Inherited),
|
||||||
node: ast::ItemKind::Use(P(ast::UseTree {
|
node: ast::ItemKind::Use(P(ast::UseTree {
|
||||||
prefix: ast::Path {
|
prefix: ast::Path {
|
||||||
segments: ["{{root}}", name, "prelude", "v1"].into_iter().map(|name| {
|
segments: ["{{root}}", name, "prelude", "v1"].into_iter().map(|name| {
|
||||||
|
|
|
@ -530,7 +530,7 @@ impl<'a> TraitDef<'a> {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
span: self.span,
|
span: self.span,
|
||||||
ident,
|
ident,
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: respan(self.span.empty(), ast::VisibilityKind::Inherited),
|
||||||
defaultness: ast::Defaultness::Final,
|
defaultness: ast::Defaultness::Final,
|
||||||
attrs: Vec::new(),
|
attrs: Vec::new(),
|
||||||
generics: Generics::default(),
|
generics: Generics::default(),
|
||||||
|
@ -977,7 +977,7 @@ impl<'a> MethodDef<'a> {
|
||||||
attrs: self.attributes.clone(),
|
attrs: self.attributes.clone(),
|
||||||
generics: fn_generics,
|
generics: fn_generics,
|
||||||
span: trait_.span,
|
span: trait_.span,
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: respan(trait_.span.empty(), ast::VisibilityKind::Inherited),
|
||||||
defaultness: ast::Defaultness::Final,
|
defaultness: ast::Defaultness::Final,
|
||||||
ident: method_ident,
|
ident: method_ident,
|
||||||
node: ast::ImplItemKind::Method(ast::MethodSig {
|
node: ast::ImplItemKind::Method(ast::MethodSig {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
/// therefore apply.
|
/// therefore apply.
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::codemap::dummy_spanned;
|
use syntax::codemap::respan;
|
||||||
use syntax::ext::base;
|
use syntax::ext::base;
|
||||||
use syntax::ext::base::*;
|
use syntax::ext::base::*;
|
||||||
use syntax::feature_gate;
|
use syntax::feature_gate;
|
||||||
|
@ -60,7 +60,7 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
|
||||||
asm,
|
asm,
|
||||||
ctxt: cx.backtrace(),
|
ctxt: cx.backtrace(),
|
||||||
})),
|
})),
|
||||||
vis: dummy_spanned(ast::VisibilityKind::Inherited),
|
vis: respan(sp.empty(), ast::VisibilityKind::Inherited),
|
||||||
span: sp,
|
span: sp,
|
||||||
tokens: None,
|
tokens: None,
|
||||||
})))
|
})))
|
||||||
|
|
|
@ -216,6 +216,12 @@ impl Span {
|
||||||
self.data().with_ctxt(ctxt)
|
self.data().with_ctxt(ctxt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a new span representing an empty span at the beginning of this span
|
||||||
|
#[inline]
|
||||||
|
pub fn empty(self) -> Span {
|
||||||
|
span.with_hi(self.lo())
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
|
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
|
||||||
pub fn substitute_dummy(self, other: Span) -> Span {
|
pub fn substitute_dummy(self, other: Span) -> Span {
|
||||||
if self.source_equal(&DUMMY_SP) { other } else { self }
|
if self.source_equal(&DUMMY_SP) { other } else { self }
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1d6dfea44f97199d5d5c177c7dadcde393eaff9a
|
Subproject commit 91e36aa86c7037de50642f2fec1cf47c3d18af02
|
Loading…
Add table
Add a link
Reference in a new issue