Skip to content

Commit a07c9a2

Browse files
jonasbbalexcrichton
authored andcommitted
Export attributes in save-analysis data
Some annotations like the "test" annotations might be of interest for other projects, especially rls. Export all attributes in a new attributes item.
1 parent f573db4 commit a07c9a2

File tree

5 files changed

+171
-6
lines changed

5 files changed

+171
-6
lines changed

src/librustc_save_analysis/data.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
use rustc::hir;
1717
use rustc::hir::def_id::{CrateNum, DefId};
18-
use syntax::ast::{self, NodeId};
18+
use syntax::ast::{self, Attribute, NodeId};
1919
use syntax_pos::Span;
2020

2121
pub struct CrateData {
@@ -136,6 +136,7 @@ pub struct EnumData {
136136
pub visibility: Visibility,
137137
pub docs: String,
138138
pub sig: Signature,
139+
pub attributes: Vec<Attribute>,
139140
}
140141

141142
/// Data for extern crates.
@@ -171,6 +172,7 @@ pub struct FunctionData {
171172
pub parent: Option<DefId>,
172173
pub docs: String,
173174
pub sig: Signature,
175+
pub attributes: Vec<Attribute>,
174176
}
175177

176178
/// Data about a function call.
@@ -256,6 +258,7 @@ pub struct MethodData {
256258
pub visibility: Visibility,
257259
pub docs: String,
258260
pub sig: Signature,
261+
pub attributes: Vec<Attribute>,
259262
}
260263

261264
/// Data for modules.
@@ -271,6 +274,7 @@ pub struct ModData {
271274
pub visibility: Visibility,
272275
pub docs: String,
273276
pub sig: Signature,
277+
pub attributes: Vec<Attribute>,
274278
}
275279

276280
/// Data for a reference to a module.
@@ -295,6 +299,7 @@ pub struct StructData {
295299
pub visibility: Visibility,
296300
pub docs: String,
297301
pub sig: Signature,
302+
pub attributes: Vec<Attribute>,
298303
}
299304

300305
#[derive(Debug, RustcEncodable)]
@@ -309,6 +314,7 @@ pub struct StructVariantData {
309314
pub parent: Option<DefId>,
310315
pub docs: String,
311316
pub sig: Signature,
317+
pub attributes: Vec<Attribute>,
312318
}
313319

314320
#[derive(Debug, RustcEncodable)]
@@ -323,6 +329,7 @@ pub struct TraitData {
323329
pub visibility: Visibility,
324330
pub docs: String,
325331
pub sig: Signature,
332+
pub attributes: Vec<Attribute>,
326333
}
327334

328335
#[derive(Debug, RustcEncodable)]
@@ -337,6 +344,7 @@ pub struct TupleVariantData {
337344
pub parent: Option<DefId>,
338345
pub docs: String,
339346
pub sig: Signature,
347+
pub attributes: Vec<Attribute>,
340348
}
341349

342350
/// Data for a typedef.
@@ -351,6 +359,7 @@ pub struct TypeDefData {
351359
pub parent: Option<DefId>,
352360
pub docs: String,
353361
pub sig: Option<Signature>,
362+
pub attributes: Vec<Attribute>,
354363
}
355364

356365
/// Data for a reference to a type or trait.
@@ -396,6 +405,7 @@ pub struct VariableData {
396405
pub visibility: Visibility,
397406
pub docs: String,
398407
pub sig: Option<Signature>,
408+
pub attributes: Vec<Attribute>,
399409
}
400410

401411
#[derive(Debug, RustcEncodable)]

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ use syntax::ptr::P;
4747
use syntax::codemap::Spanned;
4848
use syntax_pos::*;
4949

50-
use super::{escape, generated_code, SaveContext, PathCollector, docs_for_attrs};
50+
use super::{escape, generated_code, SaveContext, PathCollector, docs_for_attrs,
51+
remove_docs_from_attrs};
5152
use super::data::*;
5253
use super::dump::Dump;
5354
use super::external_data::{Lower, make_def_id};
@@ -373,6 +374,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
373374
visibility: Visibility::Inherited,
374375
docs: String::new(),
375376
sig: None,
377+
attributes: vec![],
376378
}.lower(self.tcx));
377379
}
378380
}
@@ -448,6 +450,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
448450
visibility: vis,
449451
docs: docs_for_attrs(attrs),
450452
sig: method_data.sig,
453+
attributes: remove_docs_from_attrs(attrs),
451454
}.lower(self.tcx));
452455
}
453456

@@ -519,6 +522,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
519522
parent: None,
520523
docs: String::new(),
521524
sig: None,
525+
attributes: vec![],
522526
}.lower(self.tcx));
523527
}
524528
}
@@ -592,6 +596,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
592596
visibility: vis,
593597
docs: docs_for_attrs(attrs),
594598
sig: None,
599+
attributes: remove_docs_from_attrs(attrs),
595600
}.lower(self.tcx));
596601
}
597602

@@ -636,6 +641,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
636641
visibility: From::from(&item.vis),
637642
docs: docs_for_attrs(&item.attrs),
638643
sig: self.save_ctxt.sig_base(item),
644+
attributes: remove_docs_from_attrs(&item.attrs),
639645
}.lower(self.tcx));
640646
}
641647

@@ -701,6 +707,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
701707
parent: Some(make_def_id(item.id, &self.tcx.hir)),
702708
docs: docs_for_attrs(&variant.node.attrs),
703709
sig: sig,
710+
attributes: remove_docs_from_attrs(&variant.node.attrs),
704711
}.lower(self.tcx));
705712
}
706713
}
@@ -727,6 +734,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
727734
parent: Some(make_def_id(item.id, &self.tcx.hir)),
728735
docs: docs_for_attrs(&variant.node.attrs),
729736
sig: sig,
737+
attributes: remove_docs_from_attrs(&variant.node.attrs),
730738
}.lower(self.tcx));
731739
}
732740
}
@@ -798,6 +806,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
798806
visibility: From::from(&item.vis),
799807
docs: docs_for_attrs(&item.attrs),
800808
sig: self.save_ctxt.sig_base(item),
809+
attributes: remove_docs_from_attrs(&item.attrs),
801810
}.lower(self.tcx));
802811
}
803812

@@ -1064,6 +1073,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10641073
visibility: Visibility::Inherited,
10651074
docs: String::new(),
10661075
sig: None,
1076+
attributes: vec![],
10671077
}.lower(self.tcx));
10681078
}
10691079
}
@@ -1305,6 +1315,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
13051315
parent: None,
13061316
docs: docs_for_attrs(&item.attrs),
13071317
sig: Some(self.save_ctxt.sig_base(item)),
1318+
attributes: remove_docs_from_attrs(&item.attrs),
13081319
}.lower(self.tcx));
13091320
}
13101321

@@ -1527,6 +1538,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll,
15271538
visibility: Visibility::Inherited,
15281539
docs: String::new(),
15291540
sig: None,
1541+
attributes: vec![],
15301542
}.lower(self.tcx));
15311543
}
15321544
}

0 commit comments

Comments
 (0)