Skip to content

Commit 7bb56bf

Browse files
committed
Actually encode syntax context info for spans.
1 parent b47a791 commit 7bb56bf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/librustc_metadata/decoder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ use syntax::ast::{self, Ident};
4545
use syntax::codemap;
4646
use syntax::symbol::{InternedString, Symbol};
4747
use syntax::ext::base::MacroKind;
48-
use syntax_pos::{self, Span, SyntaxContext, BytePos, Pos, DUMMY_SP};
49-
use syntax_pos::hygiene;
48+
use syntax_pos::{self, hygiene, Span, SyntaxContext, BytePos, Pos, DUMMY_SP};
5049

5150
pub struct DecodeContext<'a, 'tcx: 'a> {
5251
opaque: opaque::Decoder<'a>,
@@ -241,7 +240,7 @@ impl<'a, 'tcx> SpecializedDecoder<CrateNum> for DecodeContext<'a, 'tcx> {
241240
impl<'a, 'tcx> SpecializedDecoder<hygiene::Mark> for DecodeContext<'a, 'tcx> {
242241
fn specialized_decode(&mut self) -> Result<hygiene::Mark, Self::Error> {
243242
let mark = u32::decode(self)?;
244-
//
243+
245244
// We only perform translation if hygiene info is already available and if the
246245
// mark actually needs translation. That way we avoid loops (as obtaining hygiene
247246
// info for an external crate involves decoding marks) and avoid incorrectly translated

src/libsyntax_pos/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,17 @@ impl Default for Span {
316316

317317
impl serialize::UseSpecializedEncodable for Span {
318318
fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
319-
s.emit_struct("Span", 2, |s| {
319+
s.emit_struct("Span", 3, |s| {
320320
s.emit_struct_field("lo", 0, |s| {
321321
self.lo().encode(s)
322322
})?;
323323

324324
s.emit_struct_field("hi", 1, |s| {
325325
self.hi().encode(s)
326+
})?;
327+
328+
s.emit_struct_field("ctxt", 2, |s| {
329+
self.ctxt().encode(s)
326330
})
327331
})
328332
}

0 commit comments

Comments
 (0)