Skip to content

Commit b5099a7

Browse files
committed
Replace dummy spans with empty spans
1 parent d6bdf29 commit b5099a7

File tree

16 files changed

+32
-25
lines changed

16 files changed

+32
-25
lines changed

src/librustc_allocator/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use syntax::ast::{Crate, Attribute, LitKind, StrStyle, ExprKind};
1515
use syntax::ast::{Unsafety, Constness, Generics, Mutability, Ty, Mac, Arg};
1616
use syntax::ast::{self, Ident, Item, ItemKind, TyKind, VisibilityKind, Expr};
1717
use syntax::attr;
18-
use syntax::codemap::dummy_spanned;
18+
use syntax::codemap::{dummy_spanned, respan};
1919
use syntax::codemap::{ExpnInfo, NameAndSpan, MacroAttribute};
2020
use syntax::ext::base::ExtCtxt;
2121
use syntax::ext::base::Resolver;
@@ -97,7 +97,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
9797
]);
9898
let mut items = vec![
9999
f.cx.item_extern_crate(f.span, f.alloc),
100-
f.cx.item_use_simple(f.span, dummy_spanned(VisibilityKind::Inherited), super_path),
100+
f.cx.item_use_simple(f.span, respan(f.span.empty(), VisibilityKind::Inherited), super_path),
101101
];
102102
for method in ALLOCATOR_METHODS {
103103
items.push(f.allocator_fn(method));

src/librustc_metadata/cstore_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl CrateStore for cstore::CStore {
497497
tokens: body.into(),
498498
legacy: def.legacy,
499499
}),
500-
vis: codemap::dummy_spanned(ast::VisibilityKind::Inherited),
500+
vis: codemap::respan(local_span.empty(), ast::VisibilityKind::Inherited),
501501
tokens: None,
502502
})
503503
}

src/librustc_save_analysis/dump_visitor.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use syntax::print::pprust::{
4343
ty_to_string
4444
};
4545
use syntax::ptr::P;
46-
use syntax::codemap::{Spanned, DUMMY_SP, dummy_spanned};
46+
use syntax::codemap::{Spanned, DUMMY_SP, respan};
4747
use syntax_pos::*;
4848

4949
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> {
11341134

11351135
fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
11361136
self.process_macro_use(trait_item.span);
1137+
let vis_span = trait_item.span.empty();
11371138
match trait_item.node {
11381139
ast::TraitItemKind::Const(ref ty, ref expr) => {
11391140
self.process_assoc_const(
@@ -1143,7 +1144,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
11431144
&ty,
11441145
expr.as_ref().map(|e| &**e),
11451146
trait_id,
1146-
dummy_spanned(ast::VisibilityKind::Public),
1147+
respan(vis_span, ast::VisibilityKind::Public),
11471148
&trait_item.attrs,
11481149
);
11491150
}
@@ -1154,7 +1155,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
11541155
trait_item.id,
11551156
trait_item.ident,
11561157
&trait_item.generics,
1157-
dummy_spanned(ast::VisibilityKind::Public),
1158+
respan(vis_span, ast::VisibilityKind::Public),
11581159
trait_item.span,
11591160
);
11601161
}

src/libsyntax/diagnostics/plugin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
235235
ty,
236236
expr,
237237
),
238-
vis: codemap::dummy_spanned(ast::VisibilityKind::Public),
238+
vis: codemap::respan(span.empty(), ast::VisibilityKind::Public),
239239
span,
240240
tokens: None,
241241
})

src/libsyntax/ext/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
987987
attrs,
988988
id: ast::DUMMY_NODE_ID,
989989
node,
990-
vis: dummy_spanned(ast::VisibilityKind::Inherited),
990+
vis: respan(span.empty(), ast::VisibilityKind::Inherited),
991991
span,
992992
tokens: None,
993993
})
@@ -1033,7 +1033,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
10331033
span: ty.span,
10341034
ty,
10351035
ident: None,
1036-
vis: dummy_spanned(ast::VisibilityKind::Inherited),
1036+
vis: respan(span.empty(), ast::VisibilityKind::Inherited),
10371037
attrs: Vec::new(),
10381038
id: ast::DUMMY_NODE_ID,
10391039
}

src/libsyntax/ext/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
238238
node: ast::ItemKind::Mod(krate.module),
239239
ident: keywords::Invalid.ident(),
240240
id: ast::DUMMY_NODE_ID,
241-
vis: dummy_spanned(ast::VisibilityKind::Public),
241+
vis: respan(krate.span.empty(), ast::VisibilityKind::Public),
242242
tokens: None,
243243
})));
244244

src/libsyntax/ext/quote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use ast::{self, Arg, Arm, Block, Expr, Item, Pat, Stmt, Ty};
12-
use codemap::dummy_spanned;
12+
use codemap::respan;
1313
use syntax_pos::Span;
1414
use ext::base::ExtCtxt;
1515
use ext::base;
@@ -858,7 +858,7 @@ fn expand_wrapper(cx: &ExtCtxt,
858858
let path = path.iter().map(|s| s.to_string()).collect();
859859
let use_item = cx.item_use_glob(
860860
sp,
861-
dummy_spanned(ast::VisibilityKind::Inherited),
861+
respan(sp.empty(), ast::VisibilityKind::Inherited),
862862
ids_ext(path),
863863
);
864864
cx.stmt_item(sp, use_item)

src/libsyntax/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use ast::*;
2222
use ast;
2323
use syntax_pos::Span;
24-
use codemap::{Spanned, respan, dummy_spanned};
24+
use codemap::{Spanned, respan};
2525
use parse::token::{self, Token};
2626
use ptr::P;
2727
use symbol::keywords;
@@ -1018,7 +1018,7 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, span}: Crate,
10181018
ident: keywords::Invalid.ident(),
10191019
attrs,
10201020
id: ast::DUMMY_NODE_ID,
1021-
vis: dummy_spanned(ast::VisibilityKind::Public),
1021+
vis: respan(span.empty(), ast::VisibilityKind::Public),
10221022
span,
10231023
node: ast::ItemKind::Mod(module),
10241024
tokens: None,

src/libsyntax/parse/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ mod tests {
932932
span: sp(15,21),
933933
recovered: false,
934934
})),
935-
vis: codemap::dummy_spanned(ast::VisibilityKind::Inherited),
935+
vis: codemap::respan(sp(0, 0), ast::VisibilityKind::Inherited),
936936
span: sp(0,21)})));
937937
}
938938

src/libsyntax/print/pprust.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ impl<'a> State<'a> {
15731573
ti.ident,
15741574
ty,
15751575
default.as_ref().map(|expr| &**expr),
1576-
&codemap::dummy_spanned(ast::VisibilityKind::Inherited),
1576+
&codemap::respan(ti.span.empty(), ast::VisibilityKind::Inherited),
15771577
)?;
15781578
}
15791579
ast::TraitItemKind::Method(ref sig, ref body) => {
@@ -1584,7 +1584,7 @@ impl<'a> State<'a> {
15841584
ti.ident,
15851585
&ti.generics,
15861586
sig,
1587-
&codemap::dummy_spanned(ast::VisibilityKind::Inherited),
1587+
&codemap::respan(ti.span.empty(), ast::VisibilityKind::Inherited),
15881588
)?;
15891589
if let Some(ref body) = *body {
15901590
self.nbsp()?;

src/libsyntax/std_inject.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::cell::Cell;
1414
use ext::hygiene::{Mark, SyntaxContext};
1515
use symbol::{Symbol, keywords};
1616
use syntax_pos::{DUMMY_SP, Span};
17-
use codemap::{ExpnInfo, NameAndSpan, MacroAttribute, dummy_spanned};
17+
use codemap::{ExpnInfo, NameAndSpan, MacroAttribute, dummy_spanned, respan};
1818
use ptr::P;
1919
use tokenstream::TokenStream;
2020

@@ -78,7 +78,7 @@ pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<Strin
7878
is_sugared_doc: false,
7979
span,
8080
}],
81-
vis: dummy_spanned(ast::VisibilityKind::Inherited),
81+
vis: respan(span.empty(), ast::VisibilityKind::Inherited),
8282
node: ast::ItemKind::Use(P(ast::UseTree {
8383
prefix: ast::Path {
8484
segments: ["{{root}}", name, "prelude", "v1"].into_iter().map(|name| {

src/libsyntax_ext/deriving/generic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ impl<'a> TraitDef<'a> {
530530
id: ast::DUMMY_NODE_ID,
531531
span: self.span,
532532
ident,
533-
vis: dummy_spanned(ast::VisibilityKind::Inherited),
533+
vis: respan(self.span.empty(), ast::VisibilityKind::Inherited),
534534
defaultness: ast::Defaultness::Final,
535535
attrs: Vec::new(),
536536
generics: Generics::default(),
@@ -977,7 +977,7 @@ impl<'a> MethodDef<'a> {
977977
attrs: self.attributes.clone(),
978978
generics: fn_generics,
979979
span: trait_.span,
980-
vis: dummy_spanned(ast::VisibilityKind::Inherited),
980+
vis: respan(trait_.span.empty(), ast::VisibilityKind::Inherited),
981981
defaultness: ast::Defaultness::Final,
982982
ident: method_ident,
983983
node: ast::ImplItemKind::Method(ast::MethodSig {

src/libsyntax_ext/global_asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/// therefore apply.
2020
2121
use syntax::ast;
22-
use syntax::codemap::dummy_spanned;
22+
use syntax::codemap::respan;
2323
use syntax::ext::base;
2424
use syntax::ext::base::*;
2525
use syntax::feature_gate;
@@ -60,7 +60,7 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
6060
asm,
6161
ctxt: cx.backtrace(),
6262
})),
63-
vis: dummy_spanned(ast::VisibilityKind::Inherited),
63+
vis: respan(sp.empty(), ast::VisibilityKind::Inherited),
6464
span: sp,
6565
tokens: None,
6666
})))

src/libsyntax_pos/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ impl Span {
216216
self.data().with_ctxt(ctxt)
217217
}
218218

219+
/// Returns a new span representing an empty span at the beginning of this span
220+
#[inline]
221+
pub fn empty(self) -> Span {
222+
span.with_hi(self.lo())
223+
}
224+
219225
/// Returns `self` if `self` is not the dummy span, and `other` otherwise.
220226
pub fn substitute_dummy(self, other: Span) -> Span {
221227
if self.source_equal(&DUMMY_SP) { other } else { self }

src/tools/cargo

0 commit comments

Comments
 (0)