Skip to content

Commit

Permalink
Introduce librustc/middle/mod.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Dec 29, 2019
1 parent 5768162 commit f5c63e7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 39 deletions.
40 changes: 1 addition & 39 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,45 +95,7 @@ pub mod hir;
pub mod ich;
pub mod infer;
pub mod lint;

pub mod middle {
pub mod cstore;
pub mod dependency_format;
pub mod exported_symbols;
pub mod free_region;
pub mod lang_items;
pub mod lib_features {
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use syntax::symbol::Symbol;

#[derive(HashStable)]
pub struct LibFeatures {
// A map from feature to stabilisation version.
pub stable: FxHashMap<Symbol, Symbol>,
pub unstable: FxHashSet<Symbol>,
}

impl LibFeatures {
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
let mut all_features: Vec<_> = self
.stable
.iter()
.map(|(f, s)| (*f, Some(*s)))
.chain(self.unstable.iter().map(|f| (*f, None)))
.collect();
all_features.sort_unstable_by_key(|f| f.0.as_str());
all_features
}
}
}
pub mod privacy;
pub mod recursion_limit;
pub mod region;
pub mod resolve_lifetime;
pub mod stability;
pub mod weak_lang_items;
}

pub mod middle;
pub mod mir;
pub use rustc_session as session;
pub mod traits;
Expand Down
35 changes: 35 additions & 0 deletions src/librustc/middle/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pub mod cstore;
pub mod dependency_format;
pub mod exported_symbols;
pub mod free_region;
pub mod lang_items;
pub mod lib_features {
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use syntax::symbol::Symbol;

#[derive(HashStable)]
pub struct LibFeatures {
// A map from feature to stabilisation version.
pub stable: FxHashMap<Symbol, Symbol>,
pub unstable: FxHashSet<Symbol>,
}

impl LibFeatures {
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
let mut all_features: Vec<_> = self
.stable
.iter()
.map(|(f, s)| (*f, Some(*s)))
.chain(self.unstable.iter().map(|f| (*f, None)))
.collect();
all_features.sort_unstable_by_key(|f| f.0.as_str());
all_features
}
}
}
pub mod privacy;
pub mod recursion_limit;
pub mod region;
pub mod resolve_lifetime;
pub mod stability;
pub mod weak_lang_items;

0 comments on commit f5c63e7

Please sign in to comment.