File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3097,7 +3097,7 @@ impl Resolver {
3097
3097
let imports: & mut ~[ @ImportDirective ] = & mut * module_. imports ;
3098
3098
let import_count = imports. len ( ) ;
3099
3099
if index != import_count {
3100
- let sn = self . session . codemap . span_to_snippet ( imports[ index] . span ) ;
3100
+ let sn = self . session . codemap . span_to_snippet ( imports[ index] . span ) . unwrap ( ) ;
3101
3101
if sn. contains ( "::" ) {
3102
3102
self . session . span_err ( imports[ index] . span , "unresolved import" ) ;
3103
3103
} else {
Original file line number Diff line number Diff line change @@ -369,12 +369,19 @@ impl CodeMap {
369
369
return @FileLines { file : lo. file , lines : lines} ;
370
370
}
371
371
372
- pub fn span_to_snippet ( & self , sp : span ) -> ~str {
372
+ pub fn span_to_snippet ( & self , sp : span ) -> Option < ~str > {
373
373
let begin = self . lookup_byte_offset ( sp. lo ) ;
374
374
let end = self . lookup_byte_offset ( sp. hi ) ;
375
- assert_eq ! ( begin. fm. start_pos, end. fm. start_pos) ;
376
- return begin. fm . src . slice (
377
- begin. pos . to_uint ( ) , end. pos . to_uint ( ) ) . to_owned ( ) ;
375
+
376
+ // FIXME #8256: this used to be an assert but whatever precondition
377
+ // it's testing isn't true for all spans in the AST, so to allow the
378
+ // caller to not have to fail (and it can't catch it since the CodeMap
379
+ // isn't sendable), return None
380
+ if begin. fm . start_pos != end. fm . start_pos {
381
+ None
382
+ } else {
383
+ Some ( begin. fm . src . slice ( begin. pos . to_uint ( ) , end. pos . to_uint ( ) ) . to_owned ( ) )
384
+ }
378
385
}
379
386
380
387
pub fn get_filemap ( & self , filename : & str ) -> @FileMap {
You can’t perform that action at this time.
0 commit comments