File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ impl<'a> CrateReader<'a> {
261
261
let loader:: Library { dylib, rlib, metadata } = lib;
262
262
263
263
let cnum_map = self . resolve_crate_deps ( root, metadata. as_slice ( ) , span) ;
264
+ let staged_api = self . is_staged_api ( metadata. as_slice ( ) ) ;
264
265
265
266
let cmeta = Rc :: new ( cstore:: crate_metadata {
266
267
name : name. to_string ( ) ,
@@ -270,6 +271,7 @@ impl<'a> CrateReader<'a> {
270
271
cnum : cnum,
271
272
codemap_import_info : RefCell :: new ( vec ! [ ] ) ,
272
273
span : span,
274
+ staged_api : staged_api
273
275
} ) ;
274
276
275
277
let source = cstore:: CrateSource {
@@ -283,6 +285,17 @@ impl<'a> CrateReader<'a> {
283
285
( cnum, cmeta, source)
284
286
}
285
287
288
+ fn is_staged_api ( & self , data : & [ u8 ] ) -> bool {
289
+ let attrs = decoder:: get_crate_attributes ( data) ;
290
+ for attr in & attrs {
291
+ if & attr. name ( ) [ ..] == "staged_api" {
292
+ match attr. node . value . node { ast:: MetaWord ( _) => return true , _ => ( /*pass*/ ) }
293
+ }
294
+ }
295
+
296
+ return false ;
297
+ }
298
+
286
299
fn resolve_crate ( & mut self ,
287
300
root : & Option < CratePaths > ,
288
301
ident : & str ,
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ use rbml::reader;
22
22
use std:: rc:: Rc ;
23
23
use syntax:: ast;
24
24
use syntax:: attr;
25
- use syntax:: attr:: AttrMetaMethods ;
26
25
use syntax:: diagnostic:: expect;
27
26
28
27
use std:: collections:: hash_map:: HashMap ;
@@ -386,15 +385,7 @@ pub fn get_stability(cstore: &cstore::CStore,
386
385
}
387
386
388
387
pub fn is_staged_api ( cstore : & cstore:: CStore , krate : ast:: CrateNum ) -> bool {
389
- let cdata = cstore. get_crate_data ( krate) ;
390
- let attrs = decoder:: get_crate_attributes ( cdata. data ( ) ) ;
391
- for attr in & attrs {
392
- if & attr. name ( ) [ ..] == "staged_api" {
393
- match attr. node . value . node { ast:: MetaWord ( _) => return true , _ => ( /*pass*/ ) }
394
- }
395
- }
396
-
397
- return false ;
388
+ cstore. get_crate_data ( krate) . staged_api
398
389
}
399
390
400
391
pub fn get_repr_attrs ( cstore : & cstore:: CStore , def : ast:: DefId )
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ pub struct crate_metadata {
63
63
pub cnum : ast:: CrateNum ,
64
64
pub codemap_import_info : RefCell < Vec < ImportedFileMap > > ,
65
65
pub span : codemap:: Span ,
66
+ pub staged_api : bool
66
67
}
67
68
68
69
#[ derive( Copy , Debug , PartialEq , Clone ) ]
You can’t perform that action at this time.
0 commit comments