Skip to content

Commit

Permalink
Use out-of-tree rustc serialize
Browse files Browse the repository at this point in the history
And remove a few data structures in favour of rls-data ones
  • Loading branch information
nrc committed Mar 15, 2017
1 parent a77e528 commit 83f84ff
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 95 deletions.
24 changes: 12 additions & 12 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/librustc_save_analysis/Cargo.toml
Expand Up @@ -12,6 +12,7 @@ crate-type = ["dylib"]
log = { path = "../liblog" }
rustc = { path = "../librustc" }
syntax = { path = "../libsyntax" }
serialize = { path = "../libserialize" }
# FIXME should move rustc serialize out of tree
rustc-serialize = "0.3"
syntax_pos = { path = "../libsyntax_pos" }
rls-data = { git = "https://github.com/nrc/rls-data" }
60 changes: 30 additions & 30 deletions src/librustc_save_analysis/data.rs
Expand Up @@ -28,7 +28,7 @@ pub struct CrateData {

/// Data for any entity in the Rust language. The actual data contained varies
/// with the kind of entity being queried. See the nested structs for details.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub enum Data {
/// Data for Enums.
EnumData(EnumData),
Expand Down Expand Up @@ -79,7 +79,7 @@ pub enum Data {
VariableRefData(VariableRefData),
}

#[derive(Eq, PartialEq, Clone, Copy, Debug, RustcEncodable)]
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum Visibility {
Public,
Restricted,
Expand Down Expand Up @@ -109,7 +109,7 @@ impl<'a> From<&'a hir::Visibility> for Visibility {
}

/// Data for the prelude of a crate.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct CratePreludeData {
pub crate_name: String,
pub crate_root: String,
Expand All @@ -118,7 +118,7 @@ pub struct CratePreludeData {
}

/// Data for enum declarations.
#[derive(Clone, Debug, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct EnumData {
pub id: NodeId,
pub name: String,
Expand All @@ -134,7 +134,7 @@ pub struct EnumData {
}

/// Data for extern crates.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct ExternCrateData {
pub id: NodeId,
pub name: String,
Expand All @@ -145,15 +145,15 @@ pub struct ExternCrateData {
}

/// Data about a function call.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct FunctionCallData {
pub span: Span,
pub scope: NodeId,
pub ref_id: DefId,
}

/// Data for all kinds of functions and methods.
#[derive(Clone, Debug, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct FunctionData {
pub id: NodeId,
pub name: String,
Expand All @@ -170,14 +170,14 @@ pub struct FunctionData {
}

/// Data about a function call.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct FunctionRefData {
pub span: Span,
pub scope: NodeId,
pub ref_id: DefId,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct ImplData {
pub id: NodeId,
pub span: Span,
Expand All @@ -186,7 +186,7 @@ pub struct ImplData {
pub self_ref: Option<DefId>,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
// FIXME: this struct should not exist. However, removing it requires heavy
// refactoring of dump_visitor.rs. See PR 31838 for more info.
pub struct ImplData2 {
Expand All @@ -200,15 +200,15 @@ pub struct ImplData2 {
pub self_ref: Option<TypeRefData>,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct InheritanceData {
pub span: Span,
pub base_id: DefId,
pub deriv_id: NodeId
}

/// Data about a macro declaration.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct MacroData {
pub span: Span,
pub name: String,
Expand All @@ -217,7 +217,7 @@ pub struct MacroData {
}

/// Data about a macro use.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct MacroUseData {
pub span: Span,
pub name: String,
Expand All @@ -230,7 +230,7 @@ pub struct MacroUseData {
}

/// Data about a method call.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct MethodCallData {
pub span: Span,
pub scope: NodeId,
Expand All @@ -239,7 +239,7 @@ pub struct MethodCallData {
}

/// Data for method declarations (methods with a body are treated as functions).
#[derive(Clone, Debug, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct MethodData {
pub id: NodeId,
pub name: String,
Expand All @@ -256,7 +256,7 @@ pub struct MethodData {
}

/// Data for modules.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct ModData {
pub id: NodeId,
pub name: String,
Expand All @@ -272,15 +272,15 @@ pub struct ModData {
}

/// Data for a reference to a module.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct ModRefData {
pub span: Span,
pub scope: NodeId,
pub ref_id: Option<DefId>,
pub qualname: String
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct StructData {
pub span: Span,
pub name: String,
Expand All @@ -296,7 +296,7 @@ pub struct StructData {
pub attributes: Vec<Attribute>,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct StructVariantData {
pub span: Span,
pub name: String,
Expand All @@ -311,7 +311,7 @@ pub struct StructVariantData {
pub attributes: Vec<Attribute>,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct TraitData {
pub span: Span,
pub id: NodeId,
Expand All @@ -326,7 +326,7 @@ pub struct TraitData {
pub attributes: Vec<Attribute>,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct TupleVariantData {
pub span: Span,
pub id: NodeId,
Expand All @@ -342,7 +342,7 @@ pub struct TupleVariantData {
}

/// Data for a typedef.
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct TypeDefData {
pub id: NodeId,
pub name: String,
Expand All @@ -357,15 +357,15 @@ pub struct TypeDefData {
}

/// Data for a reference to a type or trait.
#[derive(Clone, Debug, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct TypeRefData {
pub span: Span,
pub scope: NodeId,
pub ref_id: Option<DefId>,
pub qualname: String,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct UseData {
pub id: NodeId,
pub span: Span,
Expand All @@ -375,7 +375,7 @@ pub struct UseData {
pub visibility: Visibility,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct UseGlobData {
pub id: NodeId,
pub span: Span,
Expand All @@ -385,7 +385,7 @@ pub struct UseGlobData {
}

/// Data for local and global variables (consts and statics).
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct VariableData {
pub id: NodeId,
pub kind: VariableKind,
Expand All @@ -402,7 +402,7 @@ pub struct VariableData {
pub attributes: Vec<Attribute>,
}

#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub enum VariableKind {
Static,
Const,
Expand All @@ -412,7 +412,7 @@ pub enum VariableKind {

/// Data for the use of some item (e.g., the use of a local variable, which
/// will refer to that variables declaration (by ref_id)).
#[derive(Debug, RustcEncodable)]
#[derive(Debug)]
pub struct VariableRefData {
pub name: String,
pub span: Span,
Expand All @@ -424,7 +424,7 @@ pub struct VariableRefData {
/// Encodes information about the signature of a definition. This should have
/// enough information to create a nice display about a definition without
/// access to the source code.
#[derive(Clone, Debug, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct Signature {
pub span: Span,
pub text: String,
Expand All @@ -438,7 +438,7 @@ pub struct Signature {

/// An element of a signature. `start` and `end` are byte offsets into the `text`
/// of the parent `Signature`.
#[derive(Clone, Debug, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct SigElement {
pub id: DefId,
pub start: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/dump_visitor.rs
Expand Up @@ -139,7 +139,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
let lo_loc = self.span.sess.codemap().lookup_char_pos(c.span.lo);
ExternalCrateData {
name: c.name,
num: CrateNum::from_u32(c.number),
num: c.number,
file_name: SpanUtils::make_path_string(&lo_loc.file.name),
}
}).collect();
Expand Down

0 comments on commit 83f84ff

Please sign in to comment.