Skip to content

Commit 30d921f

Browse files
Span Encoding: Replace if with debug_assertion() and add some comments.
1 parent 4aa48a3 commit 30d921f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/librustc_metadata/encoder.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,8 @@ impl<'a, 'tcx> SpecializedEncoder<Span> for EncodeContext<'a, 'tcx> {
151151

152152
let span = span.data();
153153

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

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

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

0 commit comments

Comments
 (0)