Work around #8256, do not fail the task, just return None
This commit is contained in:
parent
8ce953347c
commit
118158729e
2 changed files with 12 additions and 5 deletions
|
@ -3097,7 +3097,7 @@ impl Resolver {
|
||||||
let imports: &mut ~[@ImportDirective] = &mut *module_.imports;
|
let imports: &mut ~[@ImportDirective] = &mut *module_.imports;
|
||||||
let import_count = imports.len();
|
let import_count = imports.len();
|
||||||
if index != import_count {
|
if index != import_count {
|
||||||
let sn = self.session.codemap.span_to_snippet(imports[index].span);
|
let sn = self.session.codemap.span_to_snippet(imports[index].span).unwrap();
|
||||||
if sn.contains("::") {
|
if sn.contains("::") {
|
||||||
self.session.span_err(imports[index].span, "unresolved import");
|
self.session.span_err(imports[index].span, "unresolved import");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -369,12 +369,19 @@ impl CodeMap {
|
||||||
return @FileLines {file: lo.file, lines: lines};
|
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 begin = self.lookup_byte_offset(sp.lo);
|
||||||
let end = self.lookup_byte_offset(sp.hi);
|
let end = self.lookup_byte_offset(sp.hi);
|
||||||
assert_eq!(begin.fm.start_pos, end.fm.start_pos);
|
|
||||||
return begin.fm.src.slice(
|
// FIXME #8256: this used to be an assert but whatever precondition
|
||||||
begin.pos.to_uint(), end.pos.to_uint()).to_owned();
|
// 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 {
|
pub fn get_filemap(&self, filename: &str) -> @FileMap {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue