Skip to content

Commit 316fd18

Browse files
committed
Remove LineColumn, Span::start, Span::end
1 parent 3572d74 commit 316fd18

File tree

4 files changed

+2
-76
lines changed

4 files changed

+2
-76
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::base::ExtCtxt;
22
use pm::bridge::{
33
server, DelimSpan, Diagnostic, ExpnGlobals, Group, Ident, LitKind, Literal, Punct, TokenTree,
44
};
5-
use pm::{Delimiter, Level, LineColumn};
5+
use pm::{Delimiter, Level};
66
use rustc_ast as ast;
77
use rustc_ast::token;
88
use rustc_ast::tokenstream::{self, Spacing::*, TokenStream};
@@ -648,17 +648,6 @@ impl server::Span for Rustc<'_, '_> {
648648

649649
Range { start: relative_start_pos.0 as usize, end: relative_end_pos.0 as usize }
650650
}
651-
652-
fn start(&mut self, span: Self::Span) -> LineColumn {
653-
let loc = self.sess().source_map().lookup_char_pos(span.lo());
654-
LineColumn { line: loc.line, column: loc.col.to_usize() }
655-
}
656-
657-
fn end(&mut self, span: Self::Span) -> LineColumn {
658-
let loc = self.sess().source_map().lookup_char_pos(span.hi());
659-
LineColumn { line: loc.line, column: loc.col.to_usize() }
660-
}
661-
662651
fn before(&mut self, span: Self::Span) -> Self::Span {
663652
span.shrink_to_lo()
664653
}

library/proc_macro/src/bridge/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
#![deny(unsafe_code)]
1010

11-
use crate::{Delimiter, Level, LineColumn, Spacing};
11+
use crate::{Delimiter, Level, Spacing};
1212
use std::fmt;
1313
use std::hash::Hash;
1414
use std::marker;
@@ -95,8 +95,6 @@ macro_rules! with_api {
9595
fn parent($self: $S::Span) -> Option<$S::Span>;
9696
fn source($self: $S::Span) -> $S::Span;
9797
fn byte_range($self: $S::Span) -> Range<usize>;
98-
fn start($self: $S::Span) -> LineColumn;
99-
fn end($self: $S::Span) -> LineColumn;
10098
fn before($self: $S::Span) -> $S::Span;
10199
fn after($self: $S::Span) -> $S::Span;
102100
fn join($self: $S::Span, other: $S::Span) -> Option<$S::Span>;
@@ -299,7 +297,6 @@ mark_noop! {
299297
Delimiter,
300298
LitKind,
301299
Level,
302-
LineColumn,
303300
Spacing,
304301
}
305302

@@ -319,7 +316,6 @@ rpc_encode_decode!(
319316
Help,
320317
}
321318
);
322-
rpc_encode_decode!(struct LineColumn { line, column });
323319
rpc_encode_decode!(
324320
enum Spacing {
325321
Alone,

library/proc_macro/src/lib.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ mod diagnostic;
4343
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
4444
pub use diagnostic::{Diagnostic, Level, MultiSpan};
4545

46-
use std::cmp::Ordering;
4746
use std::ops::{Range, RangeBounds};
4847
use std::path::PathBuf;
4948
use std::str::FromStr;
@@ -494,18 +493,6 @@ impl Span {
494493
self.0.byte_range()
495494
}
496495

497-
/// Gets the starting line/column in the source file for this span.
498-
#[unstable(feature = "proc_macro_span", issue = "54725")]
499-
pub fn start(&self) -> LineColumn {
500-
self.0.start().add_1_to_column()
501-
}
502-
503-
/// Gets the ending line/column in the source file for this span.
504-
#[unstable(feature = "proc_macro_span", issue = "54725")]
505-
pub fn end(&self) -> LineColumn {
506-
self.0.end().add_1_to_column()
507-
}
508-
509496
/// Creates an empty span pointing to directly before this span.
510497
#[unstable(feature = "proc_macro_span_shrink", issue = "87552")]
511498
pub fn before(&self) -> Span {
@@ -586,44 +573,6 @@ impl fmt::Debug for Span {
586573
}
587574
}
588575

589-
/// A line-column pair representing the start or end of a `Span`.
590-
#[unstable(feature = "proc_macro_span", issue = "54725")]
591-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
592-
pub struct LineColumn {
593-
/// The 1-indexed line in the source file on which the span starts or ends (inclusive).
594-
#[unstable(feature = "proc_macro_span", issue = "54725")]
595-
pub line: usize,
596-
/// The 1-indexed column (number of bytes in UTF-8 encoding) in the source
597-
/// file on which the span starts or ends (inclusive).
598-
#[unstable(feature = "proc_macro_span", issue = "54725")]
599-
pub column: usize,
600-
}
601-
602-
impl LineColumn {
603-
fn add_1_to_column(self) -> Self {
604-
LineColumn { line: self.line, column: self.column + 1 }
605-
}
606-
}
607-
608-
#[unstable(feature = "proc_macro_span", issue = "54725")]
609-
impl !Send for LineColumn {}
610-
#[unstable(feature = "proc_macro_span", issue = "54725")]
611-
impl !Sync for LineColumn {}
612-
613-
#[unstable(feature = "proc_macro_span", issue = "54725")]
614-
impl Ord for LineColumn {
615-
fn cmp(&self, other: &Self) -> Ordering {
616-
self.line.cmp(&other.line).then(self.column.cmp(&other.column))
617-
}
618-
}
619-
620-
#[unstable(feature = "proc_macro_span", issue = "54725")]
621-
impl PartialOrd for LineColumn {
622-
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
623-
Some(self.cmp(other))
624-
}
625-
}
626-
627576
/// The source file of a given `Span`.
628577
#[unstable(feature = "proc_macro_span", issue = "54725")]
629578
#[derive(Clone)]

src/tools/rust-analyzer/crates/proc-macro-srv/src/server.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,6 @@ impl server::Span for RustAnalyzer {
304304
// FIXME handle span
305305
Range { start: 0, end: 0 }
306306
}
307-
fn start(&mut self, _span: Self::Span) -> LineColumn {
308-
// FIXME handle span
309-
LineColumn { line: 0, column: 0 }
310-
}
311-
fn end(&mut self, _span: Self::Span) -> LineColumn {
312-
// FIXME handle span
313-
LineColumn { line: 0, column: 0 }
314-
}
315307
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
316308
// Just return the first span again, because some macros will unwrap the result.
317309
Some(first)

0 commit comments

Comments
 (0)