Skip to content

No error for private type in public async fn #64692

New issue

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

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

Already on GitHub? # to your account

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
Labels
A-async-await Area: Async & Await A-visibility Area: Visibility / privacy AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CryZe
Copy link
Contributor

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.

@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-visibility Area: Visibility / privacy AsyncAwait-Unclear C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 22, 2019
@cramertj
Copy link
Member

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.

@cramertj cramertj added AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. and removed AsyncAwait-Unclear labels Sep 24, 2019
@Centril
Copy link
Contributor

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

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

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-async-await Area: Async & Await A-visibility Area: Visibility / privacy AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants