From 118158729ec694e6d21d94b5a51a7cbb57d9a37a Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Sat, 3 Aug 2013 22:14:01 -0400 Subject: Work around #8256, do not fail the task, just return None --- src/libsyntax/codemap.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/codemap.rs') diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 04b9fdce666..203341790ff 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -369,12 +369,19 @@ impl CodeMap { return @FileLines {file: lo.file, lines: lines}; } - pub fn span_to_snippet(&self, sp: span) -> ~str { + pub fn span_to_snippet(&self, sp: span) -> Option<~str> { let begin = self.lookup_byte_offset(sp.lo); let end = self.lookup_byte_offset(sp.hi); - assert_eq!(begin.fm.start_pos, end.fm.start_pos); - return begin.fm.src.slice( - begin.pos.to_uint(), end.pos.to_uint()).to_owned(); + + // FIXME #8256: this used to be an assert but whatever precondition + // it's testing isn't true for all spans in the AST, so to allow the + // caller to not have to fail (and it can't catch it since the CodeMap + // isn't sendable), return None + if begin.fm.start_pos != end.fm.start_pos { + None + } else { + Some(begin.fm.src.slice( begin.pos.to_uint(), end.pos.to_uint()).to_owned()) + } } pub fn get_filemap(&self, filename: &str) -> @FileMap { -- cgit 1.4.1-3-g733a5