#![feature(nll)]
#![recursion_limit = "256"]
-#[macro_use]
-extern crate syntax;
-
use rustc::bug;
-use rustc::hir::def::{DefKind, Res};
-use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
-use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
-use rustc::hir::itemlikevisit::DeepVisitor;
-use rustc::hir::{self, AssocItemKind, Node, PatKind};
+use rustc::hir::intravisit::{self, DeepVisitor, NestedVisitorMap, Visitor};
+use rustc::hir::map::Map;
use rustc::lint;
use rustc::middle::privacy::{AccessLevel, AccessLevels};
use rustc::ty::fold::TypeVisitor;
use rustc::ty::query::Providers;
use rustc::ty::subst::InternalSubsts;
use rustc::ty::{self, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable};
-use rustc::util::nodemap::HirIdSet;
use rustc_data_structures::fx::FxHashSet;
+use rustc_errors::struct_span_err;
+use rustc_hir as hir;
+use rustc_hir::def::{DefKind, Res};
+use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
+use rustc_hir::{AssocItemKind, HirIdSet, Node, PatKind};
+use rustc_span::hygiene::Transparency;
+use rustc_span::symbol::{kw, sym};
+use rustc_span::Span;
use syntax::ast::Ident;
use syntax::attr;
-use syntax::symbol::{kw, sym};
-use syntax_pos::hygiene::Transparency;
-use syntax_pos::Span;
use std::marker::PhantomData;
use std::{cmp, fmt, mem};
}
impl Visitor<'tcx> for PubRestrictedVisitor<'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::All(&self.tcx.hir())
}
- fn visit_vis(&mut self, vis: &'tcx hir::Visibility) {
+ fn visit_vis(&mut self, vis: &'tcx hir::Visibility<'tcx>) {
self.has_pub_restricted = self.has_pub_restricted || vis.node.is_pub_restricted();
}
}
///
/// FIXME: This solution won't work with glob imports and doesn't respect
/// namespaces. See <https://github.com/rust-lang/rust/pull/57922#discussion_r251234202>.
- fn update_visibility_of_intermediate_use_statements(&mut self, segments: &[hir::PathSegment]) {
+ fn update_visibility_of_intermediate_use_statements(
+ &mut self,
+ segments: &[hir::PathSegment<'_>],
+ ) {
if let Some([module, segment]) = segments.rchunks_exact(2).next() {
if let Some(item) = module
.res
}
impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
+ type Map = Map<'tcx>;
+
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.tcx.hir())
}
}
impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
+ type Map = Map<'tcx>;
+
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.tcx.hir())
}
}
impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
+ type Map = Map<'tcx>;
+
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.tcx.hir())
}
self.in_body = orig_in_body;
}
- fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty) {
+ fn visit_ty(&mut self, hir_ty: &'tcx hir::Ty<'tcx>) {
self.span = hir_ty.span;
if self.in_body {
// Types in bodies.
intravisit::walk_ty(self, hir_ty);
}
- fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef) {
+ fn visit_trait_ref(&mut self, trait_ref: &'tcx hir::TraitRef<'tcx>) {
self.span = trait_ref.path.span;
if !self.in_body {
// Avoid calling `hir_trait_to_predicates` in bodies, it will ICE.
// we prohibit access to private statics from other crates, this allows to give
// more code internal visibility at link time. (Access to private functions
// is already prohibited by type privacy for function types.)
- fn visit_qpath(&mut self, qpath: &'tcx hir::QPath, id: hir::HirId, span: Span) {
+ fn visit_qpath(&mut self, qpath: &'tcx hir::QPath<'tcx>, id: hir::HirId, span: Span) {
let def = match self.tables.qpath_res(qpath, id) {
Res::Def(kind, def_id) => Some((kind, def_id)),
_ => None,
}
impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
- fn path_is_private_type(&self, path: &hir::Path) -> bool {
+ fn path_is_private_type(&self, path: &hir::Path<'_>) -> bool {
let did = match path.res {
Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => return false,
res => res.def_id(),
self.access_levels.is_public(trait_id)
}
- fn check_generic_bound(&mut self, bound: &hir::GenericBound) {
+ fn check_generic_bound(&mut self, bound: &hir::GenericBound<'_>) {
if let hir::GenericBound::Trait(ref trait_ref, _) = *bound {
if self.path_is_private_type(&trait_ref.trait_ref.path) {
self.old_error_set.insert(trait_ref.trait_ref.hir_ref_id);
}
}
- fn item_is_public(&self, id: &hir::HirId, vis: &hir::Visibility) -> bool {
+ fn item_is_public(&self, id: &hir::HirId, vis: &hir::Visibility<'_>) -> bool {
self.access_levels.is_reachable(*id) || vis.node.is_pub()
}
}
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
+ type Map = Map<'v>;
+
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
- fn visit_ty(&mut self, ty: &hir::Ty) {
+ fn visit_ty(&mut self, ty: &hir::Ty<'_>) {
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = ty.kind {
if self.inner.path_is_private_type(path) {
self.contains_private = true;
}
impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
+ type Map = Map<'tcx>;
+
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::All(&self.tcx.hir())
}
intravisit::walk_item(self, item);
}
- fn visit_generics(&mut self, generics: &'tcx hir::Generics) {
- for param in &generics.params {
- for bound in ¶m.bounds {
+ fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
+ for param in generics.params {
+ for bound in param.bounds {
self.check_generic_bound(bound);
}
}
- for predicate in &generics.where_clause.predicates {
+ for predicate in generics.where_clause.predicates {
match predicate {
hir::WherePredicate::BoundPredicate(bound_pred) => {
for bound in bound_pred.bounds.iter() {
}
}
- fn visit_ty(&mut self, t: &'tcx hir::Ty) {
+ fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) {
if let hir::TyKind::Path(hir::QPath::Resolved(_, ref path)) = t.kind {
if self.path_is_private_type(path) {
self.old_error_set.insert(t.hir_id);
fn visit_variant(
&mut self,
v: &'tcx hir::Variant<'tcx>,
- g: &'tcx hir::Generics,
+ g: &'tcx hir::Generics<'tcx>,
item_id: hir::HirId,
) {
if self.access_levels.is_reachable(v.id) {
}
impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'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())
}