diff options
| author | bors <bors@rust-lang.org> | 2013-08-05 20:07:59 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-05 20:07:59 -0700 |
| commit | 6f88f4dea559157c690688721cff6761172db6c3 (patch) | |
| tree | 71201a7b0f442ebec6be0987f75f5414d803cc1c /src/libsyntax/codemap.rs | |
| parent | bbda3fa9383dba653b20bd064102caceef91897a (diff) | |
| parent | 118158729ec694e6d21d94b5a51a7cbb57d9a37a (diff) | |
| download | rust-6f88f4dea559157c690688721cff6761172db6c3.tar.gz rust-6f88f4dea559157c690688721cff6761172db6c3.zip | |
auto merge of #8278 : cmr/rust/workaround, r=brson
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 0da424ce54c..8c70f128d9a 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 { |
