Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expansion info to crate metadata #43847

Closed
wants to merge 13 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Actually encode syntax context info for spans.
ibabushkin committed Oct 7, 2017

Unverified

The committer email address is not verified.
commit 7bb56bf742655bade24e82a883eecbb475bc86bd
5 changes: 2 additions & 3 deletions src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
@@ -45,8 +45,7 @@ use syntax::ast::{self, Ident};
use syntax::codemap;
use syntax::symbol::{InternedString, Symbol};
use syntax::ext::base::MacroKind;
use syntax_pos::{self, Span, SyntaxContext, BytePos, Pos, DUMMY_SP};
use syntax_pos::hygiene;
use syntax_pos::{self, hygiene, Span, SyntaxContext, BytePos, Pos, DUMMY_SP};

pub struct DecodeContext<'a, 'tcx: 'a> {
opaque: opaque::Decoder<'a>,
@@ -241,7 +240,7 @@ impl<'a, 'tcx> SpecializedDecoder<CrateNum> for DecodeContext<'a, 'tcx> {
impl<'a, 'tcx> SpecializedDecoder<hygiene::Mark> for DecodeContext<'a, 'tcx> {
fn specialized_decode(&mut self) -> Result<hygiene::Mark, Self::Error> {
let mark = u32::decode(self)?;
//

// We only perform translation if hygiene info is already available and if the
// mark actually needs translation. That way we avoid loops (as obtaining hygiene
// info for an external crate involves decoding marks) and avoid incorrectly translated
6 changes: 5 additions & 1 deletion src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
@@ -316,13 +316,17 @@ impl Default for Span {

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

s.emit_struct_field("hi", 1, |s| {
self.hi().encode(s)
})?;

s.emit_struct_field("ctxt", 2, |s| {
self.ctxt().encode(s)
})
})
}