| 226 | } |
| 227 | |
| 228 | fn encode_span(&mut self, span: Span) { |
| 229 | // TODO: We probably should encode the hygiene context here as well, but |
| 230 | // the span currently is only for error reporting, so it's not a big deal |
| 231 | // to not have these. |
| 232 | let span = span.data(); |
| 233 | |
| 234 | if span.is_dummy() { |
| 235 | return TAG_PARTIAL_SPAN.encode(self); |
| 236 | } |
| 237 | |
| 238 | let pos = self.tcx.sess.source_map().lookup_byte_offset(span.lo); |
| 239 | if !pos.sf.contains(span.hi) { |
| 240 | return TAG_PARTIAL_SPAN.encode(self); |
| 241 | } |
| 242 | |
| 243 | if Arc::ptr_eq(&pos.sf, &self.relative_file) { |
| 244 | TAG_RELATIVE_SPAN.encode(self); |
| 245 | (span.lo - self.relative_file.start_pos).encode(self); |
| 246 | (span.hi - self.relative_file.start_pos).encode(self); |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | TAG_FULL_SPAN.encode(self); |
| 251 | pos.sf.stable_id.encode(self); |
| 252 | pos.pos.encode(self); |
| 253 | (span.hi - pos.sf.start_pos).encode(self); |
| 254 | } |
| 255 | |
| 256 | fn encode_symbol(&mut self, symbol: Symbol) { |
| 257 | self.emit_str(symbol.as_str()) |