Skip to content

Commit 39fc3fb

Browse files
committed
---
yaml --- r: 277429 b: refs/heads/try c: e7b8c5e h: refs/heads/master i: 277427: ee58206
1 parent 9a13752 commit 39fc3fb

File tree

9 files changed

+145
-70
lines changed

9 files changed

+145
-70
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 40963c47f833f1c9a44861a5f7eb762c54257254
4+
refs/heads/try: e7b8c5e3ab49e11d0d1ca60d843c90abf213fb4d
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir
120120
log syntax serialize rustc_llvm rustc_platform_intrinsics \
121121
rustc_const_math rustc_const_eval rustc_incremental
122122
DEPS_rustc_incremental := rbml rustc serialize rustc_data_structures
123-
DEPS_rustc_save_analysis := rustc log syntax
123+
DEPS_rustc_save_analysis := rustc log syntax serialize
124124
DEPS_rustc_typeck := rustc syntax rustc_platform_intrinsics rustc_const_math \
125125
rustc_const_eval
126126

branches/try/src/librustc_save_analysis/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ crate-type = ["dylib"]
1212
log = { path = "../liblog" }
1313
rustc = { path = "../librustc" }
1414
syntax = { path = "../libsyntax" }
15+
serialize = { path = "../librustc_serialize" }

branches/try/src/librustc_save_analysis/csv_dumper.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,20 @@ impl<'a, 'b, W: Write> CsvDumper<'a, 'b, W> {
4242
}
4343

4444
impl<'a, 'b, W: Write + 'b> Dump for CsvDumper<'a, 'b, W> {
45-
fn crate_prelude(&mut self, span: Span, data: CratePreludeData) {
46-
let crate_root = data.crate_root.unwrap_or("<no source>".to_owned());
47-
45+
fn crate_prelude(&mut self, data: CratePreludeData) {
4846
let values = make_values_str(&[
4947
("name", &data.crate_name),
50-
("crate_root", &crate_root)
48+
("crate_root", &data.crate_root)
5149
]);
5250

53-
self.record("crate", span, values);
51+
self.record("crate", data.span, values);
5452

5553
for c in data.external_crates {
5654
let num = c.num.to_string();
57-
let lo_loc = self.span.sess.codemap().lookup_char_pos(span.lo);
58-
let file_name = SpanUtils::make_path_string(&lo_loc.file.name);
5955
let values = make_values_str(&[
6056
("name", &c.name),
6157
("crate", &num),
62-
("file_name", &file_name)
58+
("file_name", &c.file_name)
6359
]);
6460

6561
self.record_raw(&format!("external_crate{}\n", values));

branches/try/src/librustc_save_analysis/data.rs

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ use syntax::codemap::Span;
2323
pub struct CrateData {
2424
pub name: String,
2525
pub number: u32,
26+
pub span: Span,
2627
}
2728

2829
/// Data for any entity in the Rust language. The actual data contained varies
2930
/// with the kind of entity being queried. See the nested structs for details.
30-
#[derive(Debug)]
31+
#[derive(Debug, RustcEncodable)]
3132
pub enum Data {
3233
/// Data for Enums.
3334
EnumData(EnumData),
@@ -79,22 +80,24 @@ pub enum Data {
7980
}
8081

8182
/// Data for the prelude of a crate.
82-
#[derive(Debug)]
83+
#[derive(Debug, RustcEncodable)]
8384
pub struct CratePreludeData {
8485
pub crate_name: String,
85-
pub crate_root: Option<String>,
86-
pub external_crates: Vec<ExternalCrateData>
86+
pub crate_root: String,
87+
pub external_crates: Vec<ExternalCrateData>,
88+
pub span: Span,
8789
}
8890

8991
/// Data for external crates in the prelude of a crate.
90-
#[derive(Debug)]
92+
#[derive(Debug, RustcEncodable)]
9193
pub struct ExternalCrateData {
9294
pub name: String,
93-
pub num: CrateNum
95+
pub num: CrateNum,
96+
pub file_name: String,
9497
}
9598

9699
/// Data for enum declarations.
97-
#[derive(Clone, Debug)]
100+
#[derive(Clone, Debug, RustcEncodable)]
98101
pub struct EnumData {
99102
pub id: NodeId,
100103
pub value: String,
@@ -104,7 +107,7 @@ pub struct EnumData {
104107
}
105108

106109
/// Data for extern crates.
107-
#[derive(Debug)]
110+
#[derive(Debug, RustcEncodable)]
108111
pub struct ExternCrateData {
109112
pub id: NodeId,
110113
pub name: String,
@@ -115,15 +118,15 @@ pub struct ExternCrateData {
115118
}
116119

117120
/// Data about a function call.
118-
#[derive(Debug)]
121+
#[derive(Debug, RustcEncodable)]
119122
pub struct FunctionCallData {
120123
pub span: Span,
121124
pub scope: NodeId,
122125
pub ref_id: DefId,
123126
}
124127

125128
/// Data for all kinds of functions and methods.
126-
#[derive(Clone, Debug)]
129+
#[derive(Clone, Debug, RustcEncodable)]
127130
pub struct FunctionData {
128131
pub id: NodeId,
129132
pub name: String,
@@ -134,14 +137,14 @@ pub struct FunctionData {
134137
}
135138

136139
/// Data about a function call.
137-
#[derive(Debug)]
140+
#[derive(Debug, RustcEncodable)]
138141
pub struct FunctionRefData {
139142
pub span: Span,
140143
pub scope: NodeId,
141144
pub ref_id: DefId,
142145
}
143146

144-
#[derive(Debug)]
147+
#[derive(Debug, RustcEncodable)]
145148
pub struct ImplData {
146149
pub id: NodeId,
147150
pub span: Span,
@@ -150,7 +153,7 @@ pub struct ImplData {
150153
pub self_ref: Option<DefId>,
151154
}
152155

153-
#[derive(Debug)]
156+
#[derive(Debug, RustcEncodable)]
154157
// FIXME: this struct should not exist. However, removing it requires heavy
155158
// refactoring of dump_visitor.rs. See PR 31838 for more info.
156159
pub struct ImplData2 {
@@ -164,23 +167,23 @@ pub struct ImplData2 {
164167
pub self_ref: Option<TypeRefData>,
165168
}
166169

167-
#[derive(Debug)]
170+
#[derive(Debug, RustcEncodable)]
168171
pub struct InheritanceData {
169172
pub span: Span,
170173
pub base_id: DefId,
171174
pub deriv_id: NodeId
172175
}
173176

174177
/// Data about a macro declaration.
175-
#[derive(Debug)]
178+
#[derive(Debug, RustcEncodable)]
176179
pub struct MacroData {
177180
pub span: Span,
178181
pub name: String,
179182
pub qualname: String,
180183
}
181184

182185
/// Data about a macro use.
183-
#[derive(Debug)]
186+
#[derive(Debug, RustcEncodable)]
184187
pub struct MacroUseData {
185188
pub span: Span,
186189
pub name: String,
@@ -193,7 +196,7 @@ pub struct MacroUseData {
193196
}
194197

195198
/// Data about a method call.
196-
#[derive(Debug)]
199+
#[derive(Debug, RustcEncodable)]
197200
pub struct MethodCallData {
198201
pub span: Span,
199202
pub scope: NodeId,
@@ -202,7 +205,7 @@ pub struct MethodCallData {
202205
}
203206

204207
/// Data for method declarations (methods with a body are treated as functions).
205-
#[derive(Clone, Debug)]
208+
#[derive(Clone, Debug, RustcEncodable)]
206209
pub struct MethodData {
207210
pub id: NodeId,
208211
pub qualname: String,
@@ -211,7 +214,7 @@ pub struct MethodData {
211214
}
212215

213216
/// Data for modules.
214-
#[derive(Debug)]
217+
#[derive(Debug, RustcEncodable)]
215218
pub struct ModData {
216219
pub id: NodeId,
217220
pub name: String,
@@ -222,15 +225,15 @@ pub struct ModData {
222225
}
223226

224227
/// Data for a reference to a module.
225-
#[derive(Debug)]
228+
#[derive(Debug, RustcEncodable)]
226229
pub struct ModRefData {
227230
pub span: Span,
228231
pub scope: NodeId,
229232
pub ref_id: Option<DefId>,
230233
pub qualname: String
231234
}
232235

233-
#[derive(Debug)]
236+
#[derive(Debug, RustcEncodable)]
234237
pub struct StructData {
235238
pub span: Span,
236239
pub id: NodeId,
@@ -240,7 +243,7 @@ pub struct StructData {
240243
pub value: String
241244
}
242245

243-
#[derive(Debug)]
246+
#[derive(Debug, RustcEncodable)]
244247
pub struct StructVariantData {
245248
pub span: Span,
246249
pub id: NodeId,
@@ -250,7 +253,7 @@ pub struct StructVariantData {
250253
pub scope: NodeId
251254
}
252255

253-
#[derive(Debug)]
256+
#[derive(Debug, RustcEncodable)]
254257
pub struct TraitData {
255258
pub span: Span,
256259
pub id: NodeId,
@@ -259,7 +262,7 @@ pub struct TraitData {
259262
pub value: String
260263
}
261264

262-
#[derive(Debug)]
265+
#[derive(Debug, RustcEncodable)]
263266
pub struct TupleVariantData {
264267
pub span: Span,
265268
pub id: NodeId,
@@ -271,7 +274,7 @@ pub struct TupleVariantData {
271274
}
272275

273276
/// Data for a typedef.
274-
#[derive(Debug)]
277+
#[derive(Debug, RustcEncodable)]
275278
pub struct TypedefData {
276279
pub id: NodeId,
277280
pub span: Span,
@@ -280,15 +283,15 @@ pub struct TypedefData {
280283
}
281284

282285
/// Data for a reference to a type or trait.
283-
#[derive(Clone, Debug)]
286+
#[derive(Clone, Debug, RustcEncodable)]
284287
pub struct TypeRefData {
285288
pub span: Span,
286289
pub scope: NodeId,
287290
pub ref_id: Option<DefId>,
288291
pub qualname: String,
289292
}
290293

291-
#[derive(Debug)]
294+
#[derive(Debug, RustcEncodable)]
292295
pub struct UseData {
293296
pub id: NodeId,
294297
pub span: Span,
@@ -297,7 +300,7 @@ pub struct UseData {
297300
pub scope: NodeId
298301
}
299302

300-
#[derive(Debug)]
303+
#[derive(Debug, RustcEncodable)]
301304
pub struct UseGlobData {
302305
pub id: NodeId,
303306
pub span: Span,
@@ -306,7 +309,7 @@ pub struct UseGlobData {
306309
}
307310

308311
/// Data for local and global variables (consts and statics).
309-
#[derive(Debug)]
312+
#[derive(Debug, RustcEncodable)]
310313
pub struct VariableData {
311314
pub id: NodeId,
312315
pub name: String,
@@ -319,7 +322,7 @@ pub struct VariableData {
319322

320323
/// Data for the use of some item (e.g., the use of a local variable, which
321324
/// will refer to that variables declaration (by ref_id)).
322-
#[derive(Debug)]
325+
#[derive(Debug, RustcEncodable)]
323326
pub struct VariableRefData {
324327
pub name: String,
325328
pub span: Span,

branches/try/src/librustc_save_analysis/dump.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,31 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use syntax::codemap::Span;
12-
1311
use super::data::*;
1412

1513
pub trait Dump {
16-
fn crate_prelude(&mut self, _: Span, _: CratePreludeData) {}
17-
fn enum_data(&mut self, EnumData) {}
18-
fn extern_crate(&mut self, ExternCrateData) {}
19-
fn impl_data(&mut self, ImplData) {}
20-
fn inheritance(&mut self, InheritanceData) {}
21-
fn function(&mut self, FunctionData) {}
22-
fn function_ref(&mut self, FunctionRefData) {}
23-
fn function_call(&mut self, FunctionCallData) {}
24-
fn method(&mut self, MethodData) {}
25-
fn method_call(&mut self, MethodCallData) {}
26-
fn macro_data(&mut self, MacroData) {}
27-
fn macro_use(&mut self, MacroUseData) {}
28-
fn mod_data(&mut self, ModData) {}
29-
fn mod_ref(&mut self, ModRefData) {}
30-
fn struct_data(&mut self, StructData) {}
31-
fn struct_variant(&mut self, StructVariantData) {}
32-
fn trait_data(&mut self, TraitData) {}
33-
fn tuple_variant(&mut self, TupleVariantData) {}
34-
fn type_ref(&mut self, TypeRefData) {}
35-
fn typedef(&mut self, TypedefData) {}
36-
fn use_data(&mut self, UseData) {}
37-
fn use_glob(&mut self, UseGlobData) {}
38-
fn variable(&mut self, VariableData) {}
39-
fn variable_ref(&mut self, VariableRefData) {}
14+
fn crate_prelude(&mut self, CratePreludeData);
15+
fn enum_data(&mut self, EnumData);
16+
fn extern_crate(&mut self, ExternCrateData);
17+
fn impl_data(&mut self, ImplData);
18+
fn inheritance(&mut self, InheritanceData);
19+
fn function(&mut self, FunctionData);
20+
fn function_ref(&mut self, FunctionRefData);
21+
fn function_call(&mut self, FunctionCallData);
22+
fn method(&mut self, MethodData);
23+
fn method_call(&mut self, MethodCallData);
24+
fn macro_data(&mut self, MacroData);
25+
fn macro_use(&mut self, MacroUseData);
26+
fn mod_data(&mut self, ModData);
27+
fn mod_ref(&mut self, ModRefData);
28+
fn struct_data(&mut self, StructData);
29+
fn struct_variant(&mut self, StructVariantData);
30+
fn trait_data(&mut self, TraitData);
31+
fn tuple_variant(&mut self, TupleVariantData);
32+
fn type_ref(&mut self, TypeRefData);
33+
fn typedef(&mut self, TypedefData);
34+
fn use_data(&mut self, UseData);
35+
fn use_glob(&mut self, UseGlobData);
36+
fn variable(&mut self, VariableData);
37+
fn variable_ref(&mut self, VariableRefData);
4038
}

branches/try/src/librustc_save_analysis/dump_visitor.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,23 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
119119

120120
// Info about all the external crates referenced from this crate.
121121
let external_crates = self.save_ctxt.get_external_crates().into_iter().map(|c| {
122+
let lo_loc = self.span.sess.codemap().lookup_char_pos(c.span.lo);
122123
ExternalCrateData {
123124
name: c.name,
124-
num: c.number
125+
num: c.number,
126+
file_name: SpanUtils::make_path_string(&lo_loc.file.name),
125127
}
126128
}).collect();
127129

128130
// The current crate.
129131
let data = CratePreludeData {
130132
crate_name: name.into(),
131-
crate_root: crate_root,
132-
external_crates: external_crates
133+
crate_root: crate_root.unwrap_or("<no source>".to_owned()),
134+
external_crates: external_crates,
135+
span: krate.span,
133136
};
134137

135-
self.dumper.crate_prelude(krate.span, data);
138+
self.dumper.crate_prelude(data);
136139
}
137140

138141
// Return all non-empty prefixes of a path.

0 commit comments

Comments
 (0)