//! A pass that annotates every item and method with its stability level,
//! propagating default levels lexically from parent to children ast nodes.
-use errors::struct_span_err;
-use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
+use rustc::hir::map::Map;
use rustc::lint;
use rustc::middle::privacy::AccessLevels;
use rustc::middle::stability::{DeprecationEntry, Index};
+use rustc::session::parse::feature_err;
use rustc::session::Session;
use rustc::traits::misc::can_type_implement_copy;
use rustc::ty::query::Providers;
use rustc::ty::TyCtxt;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
+use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::{Generics, HirId, Item, StructField, Variant};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use syntax::ast::Attribute;
use syntax::attr::{self, Stability};
-use syntax::feature_gate::feature_err;
use std::cmp::Ordering;
use std::mem::replace;
// deprecated_since and its reason.
if let Some(parent_stab) = self.parent_stab {
if parent_stab.rustc_depr.is_some() && stab.rustc_depr.is_none() {
- stab.rustc_depr = parent_stab.rustc_depr.clone()
+ stab.rustc_depr = parent_stab.rustc_depr
}
}
/// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable
/// deep-walking.
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ type Map = Map<'tcx>;
+
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.tcx.hir())
}
// they don't have their own stability. They still can be annotated as unstable
// and propagate this unstability to children, but this annotation is completely
// optional. They inherit stability from their parents when unannotated.
- hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {
+ hir::ItemKind::Impl { of_trait: None, .. } | hir::ItemKind::ForeignMod(..) => {
self.in_trait_impl = false;
kind = AnnotationKind::Container;
}
- hir::ItemKind::Impl(.., Some(_), _, _) => {
+ hir::ItemKind::Impl { of_trait: Some(_), .. } => {
self.in_trait_impl = true;
}
hir::ItemKind::Struct(ref sd, _) => {
}
impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ type Map = Map<'tcx>;
+
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}
// they don't have their own stability. They still can be annotated as unstable
// and propagate this unstability to children, but this annotation is completely
// optional. They inherit stability from their parents when unannotated.
- hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {}
+ hir::ItemKind::Impl { of_trait: None, .. } | hir::ItemKind::ForeignMod(..) => {}
_ => self.check_missing_stability(i.hir_id, i.span, i.kind.descriptive_variant()),
}
}
impl Visitor<'tcx> for Checker<'tcx> {
+ type Map = Map<'tcx>;
+
/// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable
/// deep-walking.
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}
// For implementations of traits, check the stability of each item
// individually as it's possible to have a stable trait with unstable
// items.
- hir::ItemKind::Impl(.., Some(ref t), _, impl_item_refs) => {
+ hir::ItemKind::Impl { of_trait: Some(ref t), items, .. } => {
if let Res::Def(DefKind::Trait, trait_did) = t.path.res {
- for impl_item_ref in impl_item_refs {
+ for impl_item_ref in items {
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
let trait_item_def_id = self
.tcx