Skip to content

Commit f881626

Browse files
committed
Rename Span::empty to Span::shrink_to_lo, add Span::shrink_to_hi
1 parent e5fb138 commit f881626

File tree

22 files changed

+38
-31
lines changed

22 files changed

+38
-31
lines changed

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ impl<'a> LoweringContext<'a> {
879879
TyKind::Slice(ref ty) => hir::TySlice(self.lower_ty(ty, itctx)),
880880
TyKind::Ptr(ref mt) => hir::TyPtr(self.lower_mt(mt, itctx)),
881881
TyKind::Rptr(ref region, ref mt) => {
882-
let span = t.span.with_hi(t.span.lo());
882+
let span = t.span.shrink_to_lo();
883883
let lifetime = match *region {
884884
Some(ref lt) => self.lower_lifetime(lt),
885885
None => self.elided_lifetime(span)

src/librustc_allocator/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
9999
f.cx.item_extern_crate(f.span, f.alloc),
100100
f.cx.item_use_simple(
101101
f.span,
102-
respan(f.span.empty(), VisibilityKind::Inherited),
102+
respan(f.span.shrink_to_lo(), VisibilityKind::Inherited),
103103
super_path,
104104
),
105105
];

src/librustc_lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
10821082
if !cx.access_levels.is_reachable(it.id) {
10831083
let msg = "function is marked #[no_mangle], but not exported";
10841084
let mut err = cx.struct_span_lint(PRIVATE_NO_MANGLE_FNS, it.span, msg);
1085-
let insertion_span = it.span.with_hi(it.span.lo());
1085+
let insertion_span = it.span.shrink_to_lo();
10861086
if it.vis == hir::Visibility::Inherited {
10871087
err.span_suggestion(insertion_span,
10881088
"try making it public",
@@ -1107,7 +1107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
11071107
!cx.access_levels.is_reachable(it.id) {
11081108
let msg = "static is marked #[no_mangle], but not exported";
11091109
let mut err = cx.struct_span_lint(PRIVATE_NO_MANGLE_STATICS, it.span, msg);
1110-
let insertion_span = it.span.with_hi(it.span.lo());
1110+
let insertion_span = it.span.shrink_to_lo();
11111111
if it.vis == hir::Visibility::Inherited {
11121112
err.span_suggestion(insertion_span,
11131113
"try making it public",

src/librustc_metadata/cstore_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ impl CrateStore for cstore::CStore {
523523
tokens: body.into(),
524524
legacy: def.legacy,
525525
}),
526-
vis: codemap::respan(local_span.empty(), ast::VisibilityKind::Inherited),
526+
vis: codemap::respan(local_span.shrink_to_lo(), ast::VisibilityKind::Inherited),
527527
tokens: None,
528528
})
529529
}

src/librustc_mir/build/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
422422
builder.args_and_body(block, &arguments, arg_scope, &body.value)
423423
}));
424424
// Attribute epilogue to function's closing brace
425-
let fn_end = span.with_lo(span.hi());
425+
let fn_end = span.shrink_to_hi();
426426
let source_info = builder.source_info(fn_end);
427427
let return_block = builder.return_block();
428428
builder.cfg.terminate(block, source_info,

src/librustc_resolve/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder {
756756
// don't suggest placing a use before the prelude
757757
// import or other generated ones
758758
if item.span.ctxt().outer().expn_info().is_none() {
759-
self.span = Some(item.span.with_hi(item.span.lo()));
759+
self.span = Some(item.span.shrink_to_lo());
760760
self.found_use = true;
761761
return;
762762
}
@@ -768,12 +768,12 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder {
768768
if item.span.ctxt().outer().expn_info().is_none() {
769769
// don't insert between attributes and an item
770770
if item.attrs.is_empty() {
771-
self.span = Some(item.span.with_hi(item.span.lo()));
771+
self.span = Some(item.span.shrink_to_lo());
772772
} else {
773773
// find the first attribute on the item
774774
for attr in &item.attrs {
775775
if self.span.map_or(true, |span| attr.span < span) {
776-
self.span = Some(attr.span.with_hi(attr.span.lo()));
776+
self.span = Some(attr.span.shrink_to_lo());
777777
}
778778
}
779779
}

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
12091209

12101210
fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId) {
12111211
self.process_macro_use(trait_item.span);
1212-
let vis_span = trait_item.span.empty();
1212+
let vis_span = trait_item.span.shrink_to_lo();
12131213
match trait_item.node {
12141214
ast::TraitItemKind::Const(ref ty, ref expr) => {
12151215
self.process_assoc_const(

src/librustc_typeck/check/method/suggest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, '
767767
// don't suggest placing a use before the prelude
768768
// import or other generated ones
769769
if item.span.ctxt().outer().expn_info().is_none() {
770-
self.span = Some(item.span.with_hi(item.span.lo()));
770+
self.span = Some(item.span.shrink_to_lo());
771771
self.found_use = true;
772772
return;
773773
}
@@ -779,12 +779,12 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, '
779779
if item.span.ctxt().outer().expn_info().is_none() {
780780
// don't insert between attributes and an item
781781
if item.attrs.is_empty() {
782-
self.span = Some(item.span.with_hi(item.span.lo()));
782+
self.span = Some(item.span.shrink_to_lo());
783783
} else {
784784
// find the first attribute on the item
785785
for attr in &item.attrs {
786786
if self.span.map_or(true, |span| attr.span < span) {
787-
self.span = Some(attr.span.with_hi(attr.span.lo()));
787+
self.span = Some(attr.span.shrink_to_lo());
788788
}
789789
}
790790
}

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
25202520
if sugg_unit {
25212521
let sugg_span = sess.codemap().end_point(expr_sp);
25222522
// remove closing `)` from the span
2523-
let sugg_span = sugg_span.with_hi(sugg_span.lo());
2523+
let sugg_span = sugg_span.shrink_to_lo();
25242524
err.span_suggestion(
25252525
sugg_span,
25262526
"expected the unit value `()`; create it with empty parentheses",

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Path {
117117
return None;
118118
}
119119
}
120-
Some(PathSegment::crate_root(self.span.with_hi(self.span.lo())))
120+
Some(PathSegment::crate_root(self.span.shrink_to_lo()))
121121
}
122122

123123
pub fn is_global(&self) -> bool {

0 commit comments

Comments
 (0)