From 61414fd6c1cdc9bee06018fccf5e58ebdb508905 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 13 Jul 2018 20:43:08 +0200 Subject: [PATCH] Use the correct visibility --- src/librustc_privacy/lib.rs | 6 +--- .../run-pass/impl-trait/auxiliary/xcrate.rs | 6 +++- src/test/ui/impl-trait/issue-52128.rs | 35 +++++++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/impl-trait/issue-52128.rs diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 3919ba13076..ad70c86eb15 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -433,10 +433,6 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> { fn ty(&mut self) -> &mut Self { let ty = self.ev.tcx.type_of(self.item_def_id); - self.walk_ty(ty) - } - - fn walk_ty(&mut self, ty: Ty<'tcx>) -> &mut Self { ty.visit_with(self); if let ty::TyFnDef(def_id, _) = ty.sty { if def_id == self.item_def_id { @@ -1568,7 +1564,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> // where `X` is the `impl Iterator` itself, // stored in `predicates_of`, not in the `Ty` itself. - self.check(item.id, self.inner_visibility).predicates(); + self.check(item.id, item_visibility).predicates(); } // Subitems of these items have inherited publicity hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) | diff --git a/src/test/run-pass/impl-trait/auxiliary/xcrate.rs b/src/test/run-pass/impl-trait/auxiliary/xcrate.rs index 6e2944e8400..c57c1cfe74f 100644 --- a/src/test/run-pass/impl-trait/auxiliary/xcrate.rs +++ b/src/test/run-pass/impl-trait/auxiliary/xcrate.rs @@ -17,6 +17,10 @@ fn some_internal_fn() -> u32 { 1 } +fn other_internal_fn() -> u32 { + 1 +} + // See #40839 pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 { || { @@ -25,5 +29,5 @@ pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 { } pub fn return_internal_fn() -> impl Fn() -> u32 { - some_internal_fn + other_internal_fn } diff --git a/src/test/ui/impl-trait/issue-52128.rs b/src/test/ui/impl-trait/issue-52128.rs new file mode 100644 index 00000000000..e68637b35d1 --- /dev/null +++ b/src/test/ui/impl-trait/issue-52128.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![deny(warnings)] + +use std::collections::BTreeMap; + +pub struct RangeMap { + map: BTreeMap, +} + +#[derive(Eq, PartialEq, Ord, PartialOrd)] +struct Range; + +impl RangeMap { + fn iter_with_range<'a>(&'a self) -> impl Iterator + 'a { + self.map.range(Range..Range) + } + + pub fn iter<'a>(&'a self) -> impl Iterator + 'a { + self.iter_with_range().map(|(_, data)| data) + } + +} + +fn main() {}