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

No error for private type in public async fn #64692

Open
CryZe opened this issue Sep 22, 2019 · 4 comments
Open

No error for private type in public async fn #64692

CryZe opened this issue Sep 22, 2019 · 4 comments

Comments

@CryZe
Copy link
Contributor

@CryZe CryZe commented Sep 22, 2019

Playground

mod foo {
    struct Bar;
    
    pub async fn bar() -> Bar {
        Bar
    }
}

This compiles just fine, despite the async fn returning a private type. There is a warning, but that's about it.

warning: private type `foo::Bar` in public interface (error E0446)
 --> src/lib.rs:4:5
  |
4 | /     pub async fn bar() -> Bar {
5 | |         Bar
6 | |     }
  | |_____^
  |
  = note: `#[warn(private_in_public)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>

I don't think the warning was intended for async fn. This seems like it slipped through for async fn.

@cramertj
Copy link
Member

@cramertj cramertj commented Sep 24, 2019

We should look into turning the future-compat warning into a hard error for uses inside async fn, but given that we do already issue a future-compat warning I don't think this is a blocking issue.

@Centril
Copy link
Contributor

@Centril Centril commented Oct 8, 2019

cc @petrochenkov re. @cramertj's idea and the feasibility of doing this specially for async fn.

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Oct 8, 2019

We discussed briefly in the meeting and we were saying that maybe this future-compat warning should just go away entirely, in light of rust-lang/rfcs#2145

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Oct 8, 2019

So, the plan is not to make this a hard error, but rather removing it and replacing with a different similarly (but more intuitively) behaving lint.

In the meantime, private-in-public being a warning for async functions is ok, async functions returning private types will be unusable outside of those types' modules anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants