Skip to content

Commit ff6c0af

Browse files
committed
libsyntax: Remove the obsolete ability to parse from substrings.
This was used by the quasiquoter.
1 parent 7232dbf commit ff6c0af

File tree

2 files changed

+9
-82
lines changed

2 files changed

+9
-82
lines changed

src/libsyntax/codemap.rs

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,6 @@ pub struct FileLines
191191
lines: ~[uint]
192192
}
193193

194-
// represents the origin of a file:
195-
pub enum FileSubstr {
196-
// indicates that this is a normal standalone file:
197-
FssNone,
198-
// indicates that this "file" is actually a substring
199-
// of another file that appears earlier in the codemap
200-
FssInternal(Span),
201-
}
202-
203194
/// Identifies an offset of a multi-byte character in a FileMap
204195
pub struct MultiByteChar {
205196
/// The absolute offset of the character in the CodeMap
@@ -214,8 +205,6 @@ pub struct FileMap {
214205
/// originate from files has names between angle brackets by convention,
215206
/// e.g. `<anon>`
216207
name: FileName,
217-
/// Extra information used by qquote
218-
substr: FileSubstr,
219208
/// The complete source code
220209
src: @str,
221210
/// The start position of this source in the CodeMap
@@ -278,16 +267,7 @@ impl CodeMap {
278267
}
279268
}
280269

281-
/// Add a new FileMap to the CodeMap and return it
282270
pub fn new_filemap(&self, filename: FileName, src: @str) -> @FileMap {
283-
return self.new_filemap_w_substr(filename, FssNone, src);
284-
}
285-
286-
pub fn new_filemap_w_substr(&self,
287-
filename: FileName,
288-
substr: FileSubstr,
289-
src: @str)
290-
-> @FileMap {
291271
let mut files = self.files.borrow_mut();
292272
let start_pos = if files.get().len() == 0 {
293273
0
@@ -298,7 +278,8 @@ impl CodeMap {
298278
};
299279

300280
let filemap = @FileMap {
301-
name: filename, substr: substr, src: src,
281+
name: filename,
282+
src: src,
302283
start_pos: Pos::from_uint(start_pos),
303284
lines: RefCell::new(~[]),
304285
multibyte_chars: RefCell::new(~[]),
@@ -322,31 +303,16 @@ impl CodeMap {
322303

323304
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
324305
let loc = self.lookup_char_pos(pos);
325-
match (loc.file.substr) {
326-
FssNone =>
327-
LocWithOpt {
328-
filename: loc.file.name,
329-
line: loc.line,
330-
col: loc.col,
331-
file: Some(loc.file)},
332-
FssInternal(sp) =>
333-
self.lookup_char_pos_adj(
334-
sp.lo + (pos - loc.file.start_pos)),
306+
LocWithOpt {
307+
filename: loc.file.name,
308+
line: loc.line,
309+
col: loc.col,
310+
file: Some(loc.file)
335311
}
336312
}
337313

338314
pub fn adjust_span(&self, sp: Span) -> Span {
339-
let line = self.lookup_line(sp.lo);
340-
match (line.fm.substr) {
341-
FssNone => sp,
342-
FssInternal(s) => {
343-
self.adjust_span(Span {
344-
lo: s.lo + (sp.lo - line.fm.start_pos),
345-
hi: s.lo + (sp.hi - line.fm.start_pos),
346-
expn_info: sp.expn_info
347-
})
348-
}
349-
}
315+
sp
350316
}
351317

352318
pub fn span_to_str(&self, sp: Span) -> ~str {

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313

1414
use ast;
15-
use codemap::{Span, CodeMap, FileMap, FileSubstr};
15+
use codemap::{Span, CodeMap, FileMap};
1616
use codemap;
1717
use diagnostic::{SpanHandler, mk_span_handler, mk_handler, Emitter};
1818
use parse::attr::ParserAttr;
@@ -180,27 +180,6 @@ pub fn parse_tts_from_source_str(
180180
maybe_aborted(p.parse_all_token_trees(),p)
181181
}
182182

183-
// given a function and parsing information (source str,
184-
// filename, crate cfg, and sess), create a parser,
185-
// apply the function, and check that the parser
186-
// consumed all of the input before returning the function's
187-
// result.
188-
pub fn parse_from_source_str<T>(
189-
f: |&mut Parser| -> T,
190-
name: @str,
191-
ss: codemap::FileSubstr,
192-
source: @str,
193-
cfg: ast::CrateConfig,
194-
sess: @ParseSess)
195-
-> T {
196-
let mut p = new_parser_from_source_substr(sess, cfg, name, ss, source);
197-
let r = f(&mut p);
198-
if !p.reader.is_eof() {
199-
p.reader.fatal(~"expected end-of-string");
200-
}
201-
maybe_aborted(r,p)
202-
}
203-
204183
// Create a new parser from a source string
205184
pub fn new_parser_from_source_str(sess: @ParseSess,
206185
cfg: ast::CrateConfig,
@@ -210,17 +189,6 @@ pub fn new_parser_from_source_str(sess: @ParseSess,
210189
filemap_to_parser(sess,string_to_filemap(sess,source,name),cfg)
211190
}
212191

213-
// Create a new parser from a source string where the origin
214-
// is specified as a substring of another file.
215-
pub fn new_parser_from_source_substr(sess: @ParseSess,
216-
cfg: ast::CrateConfig,
217-
name: @str,
218-
ss: codemap::FileSubstr,
219-
source: @str)
220-
-> Parser {
221-
filemap_to_parser(sess,substring_to_filemap(sess,source,name,ss),cfg)
222-
}
223-
224192
/// Create a new parser, handling errors as appropriate
225193
/// if the file doesn't exist
226194
pub fn new_parser_from_file(
@@ -297,13 +265,6 @@ pub fn string_to_filemap(sess: @ParseSess, source: @str, path: @str)
297265
sess.cm.new_filemap(path, source)
298266
}
299267

300-
// given a session and a string and a path and a FileSubStr, add
301-
// the string to the CodeMap and return the new FileMap
302-
pub fn substring_to_filemap(sess: @ParseSess, source: @str, path: @str,
303-
filesubstr: FileSubstr) -> @FileMap {
304-
sess.cm.new_filemap_w_substr(path,filesubstr,source)
305-
}
306-
307268
// given a filemap, produce a sequence of token-trees
308269
pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap)
309270
-> ~[ast::TokenTree] {

0 commit comments

Comments
 (0)