Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private in public lint wrong in presence of impl trait #52128

Closed
bjorn3 opened this issue Jul 7, 2018 · 1 comment · Fixed by #52348
Closed

Private in public lint wrong in presence of impl trait #52128

bjorn3 opened this issue Jul 7, 2018 · 1 comment · Fixed by #52348
Assignees
Labels
P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jul 7, 2018

https://play.rust-lang.org/?gist=6cba607fa159813cf9ba964e5780541e&version=nightly&mode=debug&edition=2015

Works on beta, but not on nightly.

This breaks miri.

use std::collections::BTreeMap;

pub struct RangeMap {
    map: BTreeMap<Range, u8>,
}

#[derive(Eq, PartialEq, Ord, PartialOrd)]
struct Range;

impl RangeMap {
    fn iter_with_range<'a>(&'a self) -> impl Iterator<Item = (&'a Range, &'a u8)> + 'a {
        self.map.range(Range..Range)
    }

    pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a u8> + 'a {
        self.iter_with_range().map(|(_, data)| data)
    }

}

fn main() {}
error[E0446]: private type `Range` in public interface
  --> src/main.rs:11:41
   |
8  | struct Range;
   | - `Range` declared as private
...
11 |     fn iter_with_range<'a>(&'a self) -> impl Iterator<Item = (&'a Range, &'a u8)> + 'a {
   |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type

error: aborting due to previous error
@oli-obk
Copy link
Contributor

oli-obk commented Jul 7, 2018

That was probably me. I'll have a look

@oli-obk oli-obk added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jul 7, 2018
@oli-obk oli-obk self-assigned this Jul 7, 2018
@pnkfelix pnkfelix added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. P-high High priority labels Jul 12, 2018
bors added a commit that referenced this issue Jul 15, 2018
Reach the body of functions returning `impl Trait` but don't treat it as public

fixes #52128

r? @pnkfelix

cc @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants