Skip to content

Commit 63080b3

Browse files
committed
remove lookup_char_pos_adj
It is now exactly equivalent to lookup_char_pos.
1 parent 20dbf28 commit 63080b3

File tree

5 files changed

+9
-30
lines changed

5 files changed

+9
-30
lines changed

src/librustc/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
278278
}
279279

280280
fn explain_span(self, heading: &str, span: Span) -> (String, Option<Span>) {
281-
let lo = self.sess.source_map().lookup_char_pos_adj(span.lo());
281+
let lo = self.sess.source_map().lookup_char_pos(span.lo());
282282
(
283283
format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
284284
Some(span),

src/librustc/mir/interpret/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
6565
write!(f, "inside call to `{}`", self.instance)?;
6666
}
6767
if !self.call_site.is_dummy() {
68-
let lo = tcx.sess.source_map().lookup_char_pos_adj(self.call_site.lo());
69-
write!(f, " at {}:{}:{}", lo.filename, lo.line, lo.col.to_usize() + 1)?;
68+
let lo = tcx.sess.source_map().lookup_char_pos(self.call_site.lo());
69+
write!(f, " at {}:{}:{}", lo.file.name, lo.line, lo.col.to_usize() + 1)?;
7070
}
7171
Ok(())
7272
})

src/libsyntax/diagnostics/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub struct ErrorLocation {
3636
impl ErrorLocation {
3737
/// Creates an error location from a span.
3838
pub fn from_span(ecx: &ExtCtxt<'_>, sp: Span) -> ErrorLocation {
39-
let loc = ecx.source_map().lookup_char_pos_adj(sp.lo());
39+
let loc = ecx.source_map().lookup_char_pos(sp.lo());
4040
ErrorLocation {
41-
filename: loc.filename,
41+
filename: loc.file.name.clone(),
4242
line: loc.line
4343
}
4444
}

src/libsyntax/source_map.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,6 @@ impl SourceMap {
388388
}
389389
}
390390

391-
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
392-
let loc = self.lookup_char_pos(pos);
393-
LocWithOpt {
394-
filename: loc.file.name.clone(),
395-
line: loc.line,
396-
col: loc.col,
397-
file: Some(loc.file)
398-
}
399-
}
400-
401391
/// Returns `Some(span)`, a union of the lhs and rhs span. The lhs must precede the rhs. If
402392
/// there are gaps between lhs and rhs, the resulting union will cross these gaps.
403393
/// For this to work, the spans have to be:
@@ -438,10 +428,10 @@ impl SourceMap {
438428
return "no-location".to_string();
439429
}
440430

441-
let lo = self.lookup_char_pos_adj(sp.lo());
442-
let hi = self.lookup_char_pos_adj(sp.hi());
431+
let lo = self.lookup_char_pos(sp.lo());
432+
let hi = self.lookup_char_pos(sp.hi());
443433
format!("{}:{}:{}: {}:{}",
444-
lo.filename,
434+
lo.file.name,
445435
lo.line,
446436
lo.col.to_usize() + 1,
447437
hi.line,

src/libsyntax_pos/lib.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ impl Sub for CharPos {
12951295
}
12961296

12971297
// _____________________________________________________________________________
1298-
// Loc, LocWithOpt, SourceFileAndLine, SourceFileAndBytePos
1298+
// Loc, SourceFileAndLine, SourceFileAndBytePos
12991299
//
13001300

13011301
/// A source code location used for error reporting.
@@ -1311,17 +1311,6 @@ pub struct Loc {
13111311
pub col_display: usize,
13121312
}
13131313

1314-
/// A source code location used as the result of `lookup_char_pos_adj`.
1315-
// Actually, *none* of the clients use the filename *or* file field;
1316-
// perhaps they should just be removed.
1317-
#[derive(Debug)]
1318-
pub struct LocWithOpt {
1319-
pub filename: FileName,
1320-
pub line: usize,
1321-
pub col: CharPos,
1322-
pub file: Option<Lrc<SourceFile>>,
1323-
}
1324-
13251314
// Used to be structural records.
13261315
#[derive(Debug)]
13271316
pub struct SourceFileAndLine { pub sf: Lrc<SourceFile>, pub line: usize }

0 commit comments

Comments
 (0)