Skip to content

Commit fbd1750

Browse files
Remove the now redundant CodeMap::new_filemap_with_lines() method.
1 parent 63b97ea commit fbd1750

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/libsyntax/codemap.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ impl CodeMap {
211211
}
212212
}
213213

214-
/// Creates a new filemap without setting its line information. If you don't
215-
/// intend to set the line information yourself, you should use new_filemap_and_lines.
214+
/// Creates a new filemap.
216215
/// This does not ensure that only one FileMap exists per file name.
217216
pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<FileMap> {
218217
let start_pos = self.next_start_pos();
@@ -247,13 +246,6 @@ impl CodeMap {
247246
filemap
248247
}
249248

250-
/// Creates a new filemap and sets its line information.
251-
/// This does not ensure that only one FileMap exists per file name.
252-
pub fn new_filemap_and_lines(&self, filename: &Path, src: &str) -> Lrc<FileMap> {
253-
self.new_filemap(filename.to_owned().into(), src.to_owned())
254-
}
255-
256-
257249
/// Allocates a new FileMap representing a source file from an external
258250
/// crate. The source code of such an "imported filemap" is not available,
259251
/// but we still know enough to generate accurate debuginfo location
@@ -1116,7 +1108,7 @@ mod tests {
11161108
let cm = CodeMap::new(FilePathMapping::empty());
11171109
let inputtext = "aaaaa\nbbbbBB\nCCC\nDDDDDddddd\neee\n";
11181110
let selection = " \n ~~\n~~~\n~~~~~ \n \n";
1119-
cm.new_filemap_and_lines(Path::new("blork.rs"), inputtext);
1111+
cm.new_filemap(Path::new("blork.rs").to_owned().into(), inputtext.to_string());
11201112
let span = span_from_selection(inputtext, selection);
11211113

11221114
// check that we are extracting the text we thought we were extracting
@@ -1159,7 +1151,7 @@ mod tests {
11591151
let inputtext = "bbbb BB\ncc CCC\n";
11601152
let selection1 = " ~~\n \n";
11611153
let selection2 = " \n ~~~\n";
1162-
cm.new_filemap_and_lines(Path::new("blork.rs"), inputtext);
1154+
cm.new_filemap(Path::new("blork.rs").to_owned().into(), inputtext.to_owned());
11631155
let span1 = span_from_selection(inputtext, selection1);
11641156
let span2 = span_from_selection(inputtext, selection2);
11651157

src/libsyntax/ext/expand.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1451,17 +1451,19 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
14511451

14521452
match String::from_utf8(buf) {
14531453
Ok(src) => {
1454+
let src_interned = Symbol::intern(&src);
1455+
14541456
// Add this input file to the code map to make it available as
14551457
// dependency information
1456-
self.cx.codemap().new_filemap_and_lines(&filename, &src);
1458+
self.cx.codemap().new_filemap(filename.into(), src);
14571459

14581460
let include_info = vec![
14591461
dummy_spanned(ast::NestedMetaItemKind::MetaItem(
14601462
attr::mk_name_value_item_str(Ident::from_str("file"),
14611463
dummy_spanned(file)))),
14621464
dummy_spanned(ast::NestedMetaItemKind::MetaItem(
14631465
attr::mk_name_value_item_str(Ident::from_str("contents"),
1464-
dummy_spanned(Symbol::intern(&src))))),
1466+
dummy_spanned(src_interned)))),
14651467
];
14661468

14671469
let include_ident = Ident::from_str("include");

src/libsyntax/ext/source_util.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenT
150150
};
151151
match String::from_utf8(bytes) {
152152
Ok(src) => {
153+
let interned_src = Symbol::intern(&src);
154+
153155
// Add this input file to the code map to make it available as
154156
// dependency information
155-
cx.codemap().new_filemap_and_lines(&file, &src);
157+
cx.codemap().new_filemap(file.into(), src);
156158

157-
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&src)))
159+
base::MacEager::expr(cx.expr_str(sp, interned_src))
158160
}
159161
Err(_) => {
160162
cx.span_err(sp,
@@ -182,7 +184,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Toke
182184
Ok(..) => {
183185
// Add this input file to the code map to make it available as
184186
// dependency information, but don't enter it's contents
185-
cx.codemap().new_filemap_and_lines(&file, "");
187+
cx.codemap().new_filemap(file.into(), "".to_string());
186188

187189
base::MacEager::expr(cx.expr_lit(sp, ast::LitKind::ByteStr(Lrc::new(bytes))))
188190
}

src/libsyntax/test_snippet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &
5151
let output = Arc::new(Mutex::new(Vec::new()));
5252

5353
let code_map = Lrc::new(CodeMap::new(FilePathMapping::empty()));
54-
code_map.new_filemap_and_lines(Path::new("test.rs"), &file_text);
54+
code_map.new_filemap(Path::new("test.rs").to_owned().into(), file_text.to_owned());
5555

5656
let primary_span = make_span(&file_text, &span_labels[0].start, &span_labels[0].end);
5757
let mut msp = MultiSpan::from_span(primary_span);

0 commit comments

Comments
 (0)