Rollup merge of #59735 - matklad:deadcode, r=sanxiyn

remove lookup_char_pos_adj

It is now exactly equivalent to lookup_char_pos.
This commit is contained in:
Mazdak Farrokhzad
2019-04-14 00:23:29 +02:00
committed by GitHub
5 changed files with 9 additions and 30 deletions
+1 -1
View File
@@ -278,7 +278,7 @@ fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str {
}
fn explain_span(self, heading: &str, span: Span) -> (String, Option<Span>) {
let lo = self.sess.source_map().lookup_char_pos_adj(span.lo());
let lo = self.sess.source_map().lookup_char_pos(span.lo());
(
format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
Some(span),
+2 -2
View File
@@ -65,8 +65,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "inside call to `{}`", self.instance)?;
}
if !self.call_site.is_dummy() {
let lo = tcx.sess.source_map().lookup_char_pos_adj(self.call_site.lo());
write!(f, " at {}:{}:{}", lo.filename, lo.line, lo.col.to_usize() + 1)?;
let lo = tcx.sess.source_map().lookup_char_pos(self.call_site.lo());
write!(f, " at {}:{}:{}", lo.file.name, lo.line, lo.col.to_usize() + 1)?;
}
Ok(())
})
+2 -2
View File
@@ -36,9 +36,9 @@ pub struct ErrorLocation {
impl ErrorLocation {
/// Creates an error location from a span.
pub fn from_span(ecx: &ExtCtxt<'_>, sp: Span) -> ErrorLocation {
let loc = ecx.source_map().lookup_char_pos_adj(sp.lo());
let loc = ecx.source_map().lookup_char_pos(sp.lo());
ErrorLocation {
filename: loc.filename,
filename: loc.file.name.clone(),
line: loc.line
}
}
+3 -13
View File
@@ -388,16 +388,6 @@ pub fn lookup_line(&self, pos: BytePos) -> Result<SourceFileAndLine, Lrc<SourceF
}
}
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
let loc = self.lookup_char_pos(pos);
LocWithOpt {
filename: loc.file.name.clone(),
line: loc.line,
col: loc.col,
file: Some(loc.file)
}
}
/// Returns `Some(span)`, a union of the lhs and rhs span. The lhs must precede the rhs. If
/// there are gaps between lhs and rhs, the resulting union will cross these gaps.
/// For this to work, the spans have to be:
@@ -438,10 +428,10 @@ pub fn span_to_string(&self, sp: Span) -> String {
return "no-location".to_string();
}
let lo = self.lookup_char_pos_adj(sp.lo());
let hi = self.lookup_char_pos_adj(sp.hi());
let lo = self.lookup_char_pos(sp.lo());
let hi = self.lookup_char_pos(sp.hi());
format!("{}:{}:{}: {}:{}",
lo.filename,
lo.file.name,
lo.line,
lo.col.to_usize() + 1,
hi.line,
+1 -12
View File
@@ -1295,7 +1295,7 @@ fn sub(self, rhs: CharPos) -> CharPos {
}
// _____________________________________________________________________________
// Loc, LocWithOpt, SourceFileAndLine, SourceFileAndBytePos
// Loc, SourceFileAndLine, SourceFileAndBytePos
//
/// A source code location used for error reporting.
@@ -1311,17 +1311,6 @@ pub struct Loc {
pub col_display: usize,
}
/// A source code location used as the result of `lookup_char_pos_adj`.
// Actually, *none* of the clients use the filename *or* file field;
// perhaps they should just be removed.
#[derive(Debug)]
pub struct LocWithOpt {
pub filename: FileName,
pub line: usize,
pub col: CharPos,
pub file: Option<Lrc<SourceFile>>,
}
// Used to be structural records.
#[derive(Debug)]
pub struct SourceFileAndLine { pub sf: Lrc<SourceFile>, pub line: usize }