Skip to content

Commit cc903c6

Browse files
committed
Auto merge of #52348 - oli-obk:bugfix, r=petrochenkov
Reach the body of functions returning `impl Trait` but don't treat it as public fixes #52128 r? @pnkfelix cc @eddyb
2 parents 7e32059 + 61414fd commit cc903c6

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

src/librustc_privacy/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,6 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
435435

436436
fn ty(&mut self) -> &mut Self {
437437
let ty = self.ev.tcx.type_of(self.item_def_id);
438-
self.walk_ty(ty)
439-
}
440-
441-
fn walk_ty(&mut self, ty: Ty<'tcx>) -> &mut Self {
442438
ty.visit_with(self);
443439
if let ty::TyFnDef(def_id, _) = ty.sty {
444440
if def_id == self.item_def_id {
@@ -1570,7 +1566,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
15701566
// where `X` is the `impl Iterator<Item=T>` itself,
15711567
// stored in `predicates_of`, not in the `Ty` itself.
15721568

1573-
self.check(item.id, self.inner_visibility).predicates();
1569+
self.check(item.id, item_visibility).predicates();
15741570
}
15751571
// Subitems of these items have inherited publicity
15761572
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |

src/test/run-pass/impl-trait/auxiliary/xcrate.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ fn some_internal_fn() -> u32 {
1717
1
1818
}
1919

20+
fn other_internal_fn() -> u32 {
21+
1
22+
}
23+
2024
// See #40839
2125
pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 {
2226
|| {
@@ -25,5 +29,5 @@ pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 {
2529
}
2630

2731
pub fn return_internal_fn() -> impl Fn() -> u32 {
28-
some_internal_fn
32+
other_internal_fn
2933
}

src/test/ui/impl-trait/issue-52128.rs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
#![deny(warnings)]
14+
15+
use std::collections::BTreeMap;
16+
17+
pub struct RangeMap {
18+
map: BTreeMap<Range, u8>,
19+
}
20+
21+
#[derive(Eq, PartialEq, Ord, PartialOrd)]
22+
struct Range;
23+
24+
impl RangeMap {
25+
fn iter_with_range<'a>(&'a self) -> impl Iterator<Item = (&'a Range, &'a u8)> + 'a {
26+
self.map.range(Range..Range)
27+
}
28+
29+
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a u8> + 'a {
30+
self.iter_with_range().map(|(_, data)| data)
31+
}
32+
33+
}
34+
35+
fn main() {}

0 commit comments

Comments
 (0)