Skip to content

Commit 36d33d6

Browse files
committed
rustc_privacy: visit Ty instead of HIR types in EmbargoVisitor.
1 parent 9aaf26e commit 36d33d6

File tree

8 files changed

+218
-158
lines changed

8 files changed

+218
-158
lines changed

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
298298
// Nothing to recurse on for these
299299
ast_map::NodeForeignItem(_) |
300300
ast_map::NodeVariant(_) |
301-
ast_map::NodeStructCtor(_) => {}
301+
ast_map::NodeStructCtor(_) |
302+
ast_map::NodeTy(_) => {}
302303
_ => {
303304
bug!("found unexpected thingy in worklist: {}",
304305
self.tcx.map.node_to_string(search_item))

src/librustc/ty/fold.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ pub trait TypeVisitor<'tcx> : Sized {
191191
t.super_visit_with(self)
192192
}
193193

194+
fn visit_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>) -> bool {
195+
trait_ref.super_visit_with(self)
196+
}
197+
194198
fn visit_region(&mut self, r: &'tcx ty::Region) -> bool {
195199
r.super_visit_with(self)
196200
}

src/librustc/ty/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,8 +1280,13 @@ impl<'a, 'tcx> ParameterEnvironment<'tcx> {
12801280
}
12811281
Some(ast_map::NodeExpr(expr)) => {
12821282
// This is a convenience to allow closures to work.
1283-
if let hir::ExprClosure(..) = expr.node {
1284-
ParameterEnvironment::for_item(tcx, tcx.map.get_parent(id))
1283+
if let hir::ExprClosure(.., ref body, _) = expr.node {
1284+
let def_id = tcx.map.local_def_id(id);
1285+
let base_def_id = tcx.closure_base_def_id(def_id);
1286+
tcx.construct_parameter_environment(
1287+
expr.span,
1288+
base_def_id,
1289+
tcx.region_maps.call_site_extent(id, body.id))
12851290
} else {
12861291
tcx.empty_parameter_environment()
12871292
}

src/librustc/ty/structural_impls.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
599599
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
600600
self.substs.visit_with(visitor)
601601
}
602+
603+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
604+
visitor.visit_trait_ref(*self)
605+
}
602606
}
603607

604608
impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialTraitRef<'tcx> {
@@ -766,6 +770,36 @@ impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef<'tcx> {
766770
}
767771
}
768772

773+
impl<'tcx> TypeFoldable<'tcx> for ty::Generics<'tcx> {
774+
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
775+
ty::Generics {
776+
parent: self.parent,
777+
parent_regions: self.parent_regions,
778+
parent_types: self.parent_types,
779+
regions: self.regions.fold_with(folder),
780+
types: self.types.fold_with(folder),
781+
has_self: self.has_self,
782+
}
783+
}
784+
785+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
786+
self.regions.visit_with(visitor) || self.types.visit_with(visitor)
787+
}
788+
}
789+
790+
impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> {
791+
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
792+
ty::GenericPredicates {
793+
parent: self.parent,
794+
predicates: self.predicates.fold_with(folder),
795+
}
796+
}
797+
798+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
799+
self.predicates.visit_with(visitor)
800+
}
801+
}
802+
769803
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
770804
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
771805
match *self {

0 commit comments

Comments
 (0)