pub use self::StabilityLevel::*;
use dep_graph::DepNode;
-use front::map as hir_map;
+use hir::map as hir_map;
use session::Session;
use lint;
use middle::cstore::{CrateStore, LOCAL_CRATE};
-use middle::def::Def;
-use middle::def_id::{CRATE_DEF_INDEX, DefId};
-use middle::ty;
+use hir::def::Def;
+use hir::def_id::{CRATE_DEF_INDEX, DefId};
+use ty::{self, TyCtxt};
use middle::privacy::AccessLevels;
use syntax::parse::token::InternedString;
use syntax::codemap::{Span, DUMMY_SP};
use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods};
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};
-use rustc_front::hir;
-use rustc_front::hir::{Item, Generics, StructField, Variant, PatKind};
-use rustc_front::intravisit::{self, Visitor};
+use hir;
+use hir::{Item, Generics, StructField, Variant, PatKind};
+use hir::intravisit::{self, Visitor};
use std::mem::replace;
use std::cmp::Ordering;
// A private tree-walker for producing an Index.
struct Annotator<'a, 'tcx: 'a> {
- tcx: &'a ty::ctxt<'tcx>,
+ tcx: &'a TyCtxt<'tcx>,
index: &'a mut Index<'tcx>,
parent_stab: Option<&'tcx Stability>,
parent_depr: Option<Deprecation>,
}
fn visit_struct_field(&mut self, s: &StructField) {
- self.annotate(s.node.id, &s.node.attrs, s.span, AnnotationKind::Required, |v| {
+ self.annotate(s.id, &s.attrs, s.span, AnnotationKind::Required, |v| {
intravisit::walk_struct_field(v, s);
});
}
impl<'tcx> Index<'tcx> {
/// Construct the stability index for a crate being compiled.
- pub fn build(&mut self, tcx: &ty::ctxt<'tcx>, access_levels: &AccessLevels) {
+ pub fn build(&mut self, tcx: &TyCtxt<'tcx>, access_levels: &AccessLevels) {
let _task = tcx.dep_graph.in_task(DepNode::StabilityIndex);
let krate = tcx.map.krate();
let mut annotator = Annotator {
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors. Returns a list of all
/// features used.
-pub fn check_unstable_api_usage(tcx: &ty::ctxt)
+pub fn check_unstable_api_usage(tcx: &TyCtxt)
-> FnvHashMap<InternedString, StabilityLevel> {
let _task = tcx.dep_graph.in_task(DepNode::StabilityCheck);
let ref active_lib_features = tcx.sess.features.borrow().declared_lib_features;
}
struct Checker<'a, 'tcx: 'a> {
- tcx: &'a ty::ctxt<'tcx>,
+ tcx: &'a TyCtxt<'tcx>,
active_features: FnvHashSet<InternedString>,
used_features: FnvHashMap<InternedString, StabilityLevel>,
// Within a block where feature gate checking can be skipped.
}
/// Helper for discovering nodes to check for stability
-pub fn check_item(tcx: &ty::ctxt, item: &hir::Item, warn_about_defns: bool,
+pub fn check_item(tcx: &TyCtxt, item: &hir::Item, warn_about_defns: bool,
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
match item.node {
hir::ItemExternCrate(_) => {
}
/// Helper for discovering nodes to check for stability
-pub fn check_expr(tcx: &ty::ctxt, e: &hir::Expr,
+pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
let span;
let id = match e.node {
span = field.span;
match tcx.expr_ty_adjusted(base_e).sty {
ty::TyStruct(def, _) => def.struct_variant().field_named(field.node).did,
- _ => tcx.sess.span_bug(e.span,
- "stability::check_expr: named field access on non-struct")
+ _ => span_bug!(e.span,
+ "stability::check_expr: named field access on non-struct")
}
}
hir::ExprTupField(ref base_e, ref field) => {
match tcx.expr_ty_adjusted(base_e).sty {
ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
ty::TyTuple(..) => return,
- _ => tcx.sess.span_bug(e.span,
- "stability::check_expr: unnamed field access on \
- something other than a tuple or struct")
+ _ => span_bug!(e.span,
+ "stability::check_expr: unnamed field access on \
+ something other than a tuple or struct")
}
}
hir::ExprStruct(_, ref expr_fields, _) => {
// a bug to have construct one.
ty::TyEnum(..) => return,
_ => {
- tcx.sess.span_bug(e.span,
- &format!("stability::check_expr: struct construction \
- of non-struct, type {:?}",
- type_));
+ span_bug!(e.span,
+ "stability::check_expr: struct construction \
+ of non-struct, type {:?}",
+ type_);
}
}
}
maybe_do_stability_check(tcx, id, span, cb);
}
-pub fn check_path(tcx: &ty::ctxt, path: &hir::Path, id: ast::NodeId,
+pub fn check_path(tcx: &TyCtxt, path: &hir::Path, id: ast::NodeId,
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
match tcx.def_map.borrow().get(&id).map(|d| d.full_def()) {
Some(Def::PrimTy(..)) => {}
}
}
-pub fn check_path_list_item(tcx: &ty::ctxt, item: &hir::PathListItem,
+pub fn check_path_list_item(tcx: &TyCtxt, item: &hir::PathListItem,
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
match tcx.def_map.borrow().get(&item.node.id()).map(|d| d.full_def()) {
Some(Def::PrimTy(..)) => {}
}
}
-pub fn check_pat(tcx: &ty::ctxt, pat: &hir::Pat,
+pub fn check_pat(tcx: &TyCtxt, pat: &hir::Pat,
cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option<Deprecation>)) {
debug!("check_pat(pat = {:?})", pat);
if is_internal(tcx, pat.span) { return; }
}
}
-fn maybe_do_stability_check(tcx: &ty::ctxt, id: DefId, span: Span,
+fn maybe_do_stability_check(tcx: &TyCtxt, id: DefId, span: Span,
cb: &mut FnMut(DefId, Span,
&Option<&Stability>, &Option<Deprecation>)) {
if is_internal(tcx, span) {
cb(id, span, &stability, &deprecation);
}
-fn is_internal(tcx: &ty::ctxt, span: Span) -> bool {
+fn is_internal(tcx: &TyCtxt, span: Span) -> bool {
tcx.sess.codemap().span_allows_unstable(span)
}
-fn is_staged_api(tcx: &ty::ctxt, id: DefId) -> bool {
+fn is_staged_api(tcx: &TyCtxt, id: DefId) -> bool {
match tcx.trait_item_of_item(id) {
Some(ty::MethodTraitItemId(trait_method_id))
if trait_method_id != id => {
/// Lookup the stability for a node, loading external crate
/// metadata as necessary.
-pub fn lookup_stability<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
+pub fn lookup_stability<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
if let Some(st) = tcx.stability.borrow().stab_map.get(&id) {
return *st;
}
st
}
-pub fn lookup_deprecation<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Deprecation> {
+pub fn lookup_deprecation<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<Deprecation> {
if let Some(depr) = tcx.stability.borrow().depr_map.get(&id) {
return depr.clone();
}
depr
}
-fn lookup_stability_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
+fn lookup_stability_uncached<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<&'tcx Stability> {
debug!("lookup(id={:?})", id);
if id.is_local() {
None // The stability cache is filled partially lazily
}
}
-fn lookup_deprecation_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<Deprecation> {
+fn lookup_deprecation_uncached<'tcx>(tcx: &TyCtxt<'tcx>, id: DefId) -> Option<Deprecation> {
debug!("lookup(id={:?})", id);
if id.is_local() {
None // The stability cache is filled partially lazily