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

lazy_type_alias: breaks visibility: private type alias .. in public interface #114213

Closed
matthiaskrgr opened this issue Jul 29, 2023 · 2 comments
Closed
Labels
A-visibility Area: Visibility / privacy. C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

I tried this code:

#![allow(nonstandard_style)]
#![allow(clippy::missing_safety_doc, unused)]

type pid_t = i32;
pub unsafe fn getpid() -> pid_t {
    pid_t::from(0)
}
pub fn getpid_SAFE_TRUTH() -> pid_t {
    unsafe { getpid() }
}

without `-Zcrate-attr=feature(lazy_type_alias)´: no warnings

with -Zcrate-attr=feature(lazy_type_alias):

error[E0446]: private type alias `pid_t` in public interface
 --> src/tools/clippy/tests/ui/auxiliary/extern_fake_libc.rs:5:1
  |
4 | type pid_t = i32;
  | ---------- `pid_t` declared as private
5 | pub unsafe fn getpid() -> pid_t {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type alias

error[E0446]: private type alias `pid_t` in public interface
 --> src/tools/clippy/tests/ui/auxiliary/extern_fake_libc.rs:8:1
  |
4 | type pid_t = i32;
  | ---------- `pid_t` declared as private
...
8 | pub fn getpid_SAFE_TRUTH() -> pid_t {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type alias

error: aborting due to 2 previous errors
rustc 1.73.0-nightly (04abc370b 2023-07-28)
binary: rustc
commit-hash: 04abc370b9f3855b28172b65a7f7d5a433f41412
commit-date: 2023-07-28
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5
@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` labels Jul 29, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 29, 2023
@compiler-errors compiler-errors added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 29, 2023
@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Jul 29, 2023

#![feature(lazy_type_alias)]

type pid_t = i32;
pub unsafe fn getpid() -> pid_t {
    pid_t::from(0)
}

@compiler-errors compiler-errors removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jul 29, 2023
@fmease fmease added the A-visibility Area: Visibility / privacy. label Feb 19, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Feb 19, 2024

This behaviour is expected of lazy type aliases. We document fn getpid() -> pid_t with exactly that signature, mentioning the type alias. That would be problematic if the type alias weren't publicly available.

@oli-obk oli-obk closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-visibility Area: Visibility / privacy. C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` requires-nightly This issue requires a nightly compiler in some way. 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

5 participants