Skip to content

Commit

Permalink
Span Encoding: Replace if with debug_assertion() and add some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Jan 4, 2018
1 parent 4aa48a3 commit 30d921f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ impl<'a, 'tcx> SpecializedEncoder<Span> for EncodeContext<'a, 'tcx> {

let span = span.data();

if span.lo > span.hi {
return TAG_INVALID_SPAN.encode(self)
}
// The Span infrastructure should make sure that this invariant holds:
debug_assert!(span.lo <= span.hi);

if !self.filemap_cache.contains(span.lo) {
let codemap = self.tcx.sess.codemap();
Expand All @@ -162,6 +161,8 @@ impl<'a, 'tcx> SpecializedEncoder<Span> for EncodeContext<'a, 'tcx> {
}

if !self.filemap_cache.contains(span.hi) {
// Unfortunately, macro expansion still sometimes generates Spans
// that malformed in this way.
return TAG_INVALID_SPAN.encode(self)
}

Expand Down

0 comments on commit 30d921f

Please sign in to comment.