Skip to content

Commit 73b0059

Browse files
committed
Move rustc_middle::middle::lib_features to rustc_crate.
1 parent 6c48bb0 commit 73b0059

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

compiler/rustc_crate/src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,33 @@ extern crate bitflags;
77
#[macro_use]
88
extern crate rustc_macros;
99

10+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
11+
use rustc_span::symbol::Symbol;
12+
1013
pub mod codegen_fn_attrs;
1114
pub mod cstore;
1215
pub mod dependency_format;
1316

17+
#[derive(HashStable_Generic)]
18+
pub struct LibFeatures {
19+
// A map from feature to stabilisation version.
20+
pub stable: FxHashMap<Symbol, Symbol>,
21+
pub unstable: FxHashSet<Symbol>,
22+
}
23+
24+
impl LibFeatures {
25+
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
26+
let mut all_features: Vec<_> = self
27+
.stable
28+
.iter()
29+
.map(|(f, s)| (*f, Some(*s)))
30+
.chain(self.unstable.iter().map(|f| (*f, None)))
31+
.collect();
32+
all_features.sort_unstable_by_key(|f| f.0.as_str());
33+
all_features
34+
}
35+
}
36+
1437
/// Requirements for a `StableHashingContext` to be used in this crate.
1538
/// This is a hack to allow using the `HashStable_Generic` derive macro
1639
/// instead of implementing everything in librustc_middle.

compiler/rustc_middle/src/middle/mod.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,6 @@ use rustc_span::def_id::{CrateNum, LOCAL_CRATE};
44

55
pub mod exported_symbols;
66
pub mod lang_items;
7-
pub mod lib_features {
8-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
9-
use rustc_span::symbol::Symbol;
10-
11-
#[derive(HashStable)]
12-
pub struct LibFeatures {
13-
// A map from feature to stabilisation version.
14-
pub stable: FxHashMap<Symbol, Symbol>,
15-
pub unstable: FxHashSet<Symbol>,
16-
}
17-
18-
impl LibFeatures {
19-
pub fn to_vec(&self) -> Vec<(Symbol, Option<Symbol>)> {
20-
let mut all_features: Vec<_> = self
21-
.stable
22-
.iter()
23-
.map(|(f, s)| (*f, Some(*s)))
24-
.chain(self.unstable.iter().map(|f| (*f, None)))
25-
.collect();
26-
all_features.sort_unstable_by_key(|f| f.0.as_str());
27-
all_features
28-
}
29-
}
30-
}
317
pub mod limits;
328
pub mod privacy;
339
pub mod region;

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::hir::exports::ExportMap;
66
use crate::ich::{NodeIdHashingMode, StableHashingContext};
77
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
88
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintSource};
9-
use crate::middle;
109
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
1110
use crate::middle::stability;
1211
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
@@ -1188,7 +1187,7 @@ impl<'tcx> TyCtxt<'tcx> {
11881187
self.sess.consider_optimizing(&cname, msg)
11891188
}
11901189

1191-
pub fn lib_features(self) -> &'tcx middle::lib_features::LibFeatures {
1190+
pub fn lib_features(self) -> &'tcx rustc_crate::LibFeatures {
11921191
self.get_lib_features(LOCAL_CRATE)
11931192
}
11941193

compiler/rustc_middle/src/ty/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::hir::map;
44
use crate::infer::canonical::{self, Canonical};
55
use crate::lint::LintLevelMap;
66
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
7-
use crate::middle::lib_features::LibFeatures;
87
use crate::middle::privacy::AccessLevels;
98
use crate::middle::region;
109
use crate::middle::resolve_lifetime::{ObjectLifetimeDefault, Region, ResolveLifetimes};
@@ -32,6 +31,7 @@ use rustc_crate::codegen_fn_attrs::CodegenFnAttrs;
3231
use rustc_crate::cstore::{
3332
CrateDepKind, CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
3433
};
34+
use rustc_crate::LibFeatures;
3535
use rustc_data_structures::fingerprint::Fingerprint;
3636
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
3737
use rustc_data_structures::stable_hasher::StableVec;

compiler/rustc_passes/src/lib_features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// (unlike lang features), which means we need to collect them instead.
66

77
use rustc_ast::{Attribute, MetaItem, MetaItemKind};
8+
use rustc_crate::LibFeatures;
89
use rustc_errors::struct_span_err;
910
use rustc_hir::def_id::LOCAL_CRATE;
1011
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
1112
use rustc_middle::hir::map::Map;
12-
use rustc_middle::middle::lib_features::LibFeatures;
1313
use rustc_middle::ty::query::Providers;
1414
use rustc_middle::ty::TyCtxt;
1515
use rustc_span::symbol::Symbol;

0 commit comments

Comments
 (0)