Skip to content

Commit 83f84ff

Browse files
committed
Use out-of-tree rustc serialize
And remove a few data structures in favour of rls-data ones
1 parent a77e528 commit 83f84ff

File tree

7 files changed

+80
-95
lines changed

7 files changed

+80
-95
lines changed

src/Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_save_analysis/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ crate-type = ["dylib"]
1212
log = { path = "../liblog" }
1313
rustc = { path = "../librustc" }
1414
syntax = { path = "../libsyntax" }
15-
serialize = { path = "../libserialize" }
15+
# FIXME should move rustc serialize out of tree
16+
rustc-serialize = "0.3"
1617
syntax_pos = { path = "../libsyntax_pos" }
1718
rls-data = { git = "https://github.com/nrc/rls-data" }

src/librustc_save_analysis/data.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct CrateData {
2828

2929
/// Data for any entity in the Rust language. The actual data contained varies
3030
/// with the kind of entity being queried. See the nested structs for details.
31-
#[derive(Debug, RustcEncodable)]
31+
#[derive(Debug)]
3232
pub enum Data {
3333
/// Data for Enums.
3434
EnumData(EnumData),
@@ -79,7 +79,7 @@ pub enum Data {
7979
VariableRefData(VariableRefData),
8080
}
8181

82-
#[derive(Eq, PartialEq, Clone, Copy, Debug, RustcEncodable)]
82+
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
8383
pub enum Visibility {
8484
Public,
8585
Restricted,
@@ -109,7 +109,7 @@ impl<'a> From<&'a hir::Visibility> for Visibility {
109109
}
110110

111111
/// Data for the prelude of a crate.
112-
#[derive(Debug, RustcEncodable)]
112+
#[derive(Debug)]
113113
pub struct CratePreludeData {
114114
pub crate_name: String,
115115
pub crate_root: String,
@@ -118,7 +118,7 @@ pub struct CratePreludeData {
118118
}
119119

120120
/// Data for enum declarations.
121-
#[derive(Clone, Debug, RustcEncodable)]
121+
#[derive(Clone, Debug)]
122122
pub struct EnumData {
123123
pub id: NodeId,
124124
pub name: String,
@@ -134,7 +134,7 @@ pub struct EnumData {
134134
}
135135

136136
/// Data for extern crates.
137-
#[derive(Debug, RustcEncodable)]
137+
#[derive(Debug)]
138138
pub struct ExternCrateData {
139139
pub id: NodeId,
140140
pub name: String,
@@ -145,15 +145,15 @@ pub struct ExternCrateData {
145145
}
146146

147147
/// Data about a function call.
148-
#[derive(Debug, RustcEncodable)]
148+
#[derive(Debug)]
149149
pub struct FunctionCallData {
150150
pub span: Span,
151151
pub scope: NodeId,
152152
pub ref_id: DefId,
153153
}
154154

155155
/// Data for all kinds of functions and methods.
156-
#[derive(Clone, Debug, RustcEncodable)]
156+
#[derive(Clone, Debug)]
157157
pub struct FunctionData {
158158
pub id: NodeId,
159159
pub name: String,
@@ -170,14 +170,14 @@ pub struct FunctionData {
170170
}
171171

172172
/// Data about a function call.
173-
#[derive(Debug, RustcEncodable)]
173+
#[derive(Debug)]
174174
pub struct FunctionRefData {
175175
pub span: Span,
176176
pub scope: NodeId,
177177
pub ref_id: DefId,
178178
}
179179

180-
#[derive(Debug, RustcEncodable)]
180+
#[derive(Debug)]
181181
pub struct ImplData {
182182
pub id: NodeId,
183183
pub span: Span,
@@ -186,7 +186,7 @@ pub struct ImplData {
186186
pub self_ref: Option<DefId>,
187187
}
188188

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

203-
#[derive(Debug, RustcEncodable)]
203+
#[derive(Debug)]
204204
pub struct InheritanceData {
205205
pub span: Span,
206206
pub base_id: DefId,
207207
pub deriv_id: NodeId
208208
}
209209

210210
/// Data about a macro declaration.
211-
#[derive(Debug, RustcEncodable)]
211+
#[derive(Debug)]
212212
pub struct MacroData {
213213
pub span: Span,
214214
pub name: String,
@@ -217,7 +217,7 @@ pub struct MacroData {
217217
}
218218

219219
/// Data about a macro use.
220-
#[derive(Debug, RustcEncodable)]
220+
#[derive(Debug)]
221221
pub struct MacroUseData {
222222
pub span: Span,
223223
pub name: String,
@@ -230,7 +230,7 @@ pub struct MacroUseData {
230230
}
231231

232232
/// Data about a method call.
233-
#[derive(Debug, RustcEncodable)]
233+
#[derive(Debug)]
234234
pub struct MethodCallData {
235235
pub span: Span,
236236
pub scope: NodeId,
@@ -239,7 +239,7 @@ pub struct MethodCallData {
239239
}
240240

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

258258
/// Data for modules.
259-
#[derive(Debug, RustcEncodable)]
259+
#[derive(Debug)]
260260
pub struct ModData {
261261
pub id: NodeId,
262262
pub name: String,
@@ -272,15 +272,15 @@ pub struct ModData {
272272
}
273273

274274
/// Data for a reference to a module.
275-
#[derive(Debug, RustcEncodable)]
275+
#[derive(Debug)]
276276
pub struct ModRefData {
277277
pub span: Span,
278278
pub scope: NodeId,
279279
pub ref_id: Option<DefId>,
280280
pub qualname: String
281281
}
282282

283-
#[derive(Debug, RustcEncodable)]
283+
#[derive(Debug)]
284284
pub struct StructData {
285285
pub span: Span,
286286
pub name: String,
@@ -296,7 +296,7 @@ pub struct StructData {
296296
pub attributes: Vec<Attribute>,
297297
}
298298

299-
#[derive(Debug, RustcEncodable)]
299+
#[derive(Debug)]
300300
pub struct StructVariantData {
301301
pub span: Span,
302302
pub name: String,
@@ -311,7 +311,7 @@ pub struct StructVariantData {
311311
pub attributes: Vec<Attribute>,
312312
}
313313

314-
#[derive(Debug, RustcEncodable)]
314+
#[derive(Debug)]
315315
pub struct TraitData {
316316
pub span: Span,
317317
pub id: NodeId,
@@ -326,7 +326,7 @@ pub struct TraitData {
326326
pub attributes: Vec<Attribute>,
327327
}
328328

329-
#[derive(Debug, RustcEncodable)]
329+
#[derive(Debug)]
330330
pub struct TupleVariantData {
331331
pub span: Span,
332332
pub id: NodeId,
@@ -342,7 +342,7 @@ pub struct TupleVariantData {
342342
}
343343

344344
/// Data for a typedef.
345-
#[derive(Debug, RustcEncodable)]
345+
#[derive(Debug)]
346346
pub struct TypeDefData {
347347
pub id: NodeId,
348348
pub name: String,
@@ -357,15 +357,15 @@ pub struct TypeDefData {
357357
}
358358

359359
/// Data for a reference to a type or trait.
360-
#[derive(Clone, Debug, RustcEncodable)]
360+
#[derive(Clone, Debug)]
361361
pub struct TypeRefData {
362362
pub span: Span,
363363
pub scope: NodeId,
364364
pub ref_id: Option<DefId>,
365365
pub qualname: String,
366366
}
367367

368-
#[derive(Debug, RustcEncodable)]
368+
#[derive(Debug)]
369369
pub struct UseData {
370370
pub id: NodeId,
371371
pub span: Span,
@@ -375,7 +375,7 @@ pub struct UseData {
375375
pub visibility: Visibility,
376376
}
377377

378-
#[derive(Debug, RustcEncodable)]
378+
#[derive(Debug)]
379379
pub struct UseGlobData {
380380
pub id: NodeId,
381381
pub span: Span,
@@ -385,7 +385,7 @@ pub struct UseGlobData {
385385
}
386386

387387
/// Data for local and global variables (consts and statics).
388-
#[derive(Debug, RustcEncodable)]
388+
#[derive(Debug)]
389389
pub struct VariableData {
390390
pub id: NodeId,
391391
pub kind: VariableKind,
@@ -402,7 +402,7 @@ pub struct VariableData {
402402
pub attributes: Vec<Attribute>,
403403
}
404404

405-
#[derive(Debug, RustcEncodable)]
405+
#[derive(Debug)]
406406
pub enum VariableKind {
407407
Static,
408408
Const,
@@ -412,7 +412,7 @@ pub enum VariableKind {
412412

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

439439
/// An element of a signature. `start` and `end` are byte offsets into the `text`
440440
/// of the parent `Signature`.
441-
#[derive(Clone, Debug, RustcEncodable)]
441+
#[derive(Clone, Debug)]
442442
pub struct SigElement {
443443
pub id: DefId,
444444
pub start: usize,

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
139139
let lo_loc = self.span.sess.codemap().lookup_char_pos(c.span.lo);
140140
ExternalCrateData {
141141
name: c.name,
142-
num: CrateNum::from_u32(c.number),
142+
num: c.number,
143143
file_name: SpanUtils::make_path_string(&lo_loc.file.name),
144144
}
145145
}).collect();

0 commit comments

Comments
 (0)