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

Cannot impl std::os::windows::fs::MetadataExt in stable rust #118795

Open
Berrysoft opened this issue Dec 10, 2023 · 2 comments
Open

Cannot impl std::os::windows::fs::MetadataExt in stable rust #118795

Berrysoft opened this issue Dec 10, 2023 · 2 comments
Labels
A-io Area: std::io, std::fs, std::net and std::path C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Berrysoft
Copy link
Contributor

The 3 methods added in #63010 makes MetadataExt cannot be implemented in stable rust.

error[E0046]: not all trait items implemented, missing: `volume_serial_number`, `number_of_links`, `file_index`
   --> compio-fs\src\metadata\windows.rs:149:1
    |
149 | impl MetadataExt for Metadata {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `volume_serial_number`, `number_of_links`, `file_index` in implementation
    |
    = help: implement the missing item: `fn volume_serial_number(&self) -> Option<u32> { todo!() }`
    = help: implement the missing item: `fn number_of_links(&self) -> Option<u32> { todo!() }`
    = help: implement the missing item: `fn file_index(&self) -> Option<u64> { todo!() }`

The trait should provide default impls for them.

@Berrysoft Berrysoft added the C-bug Category: This is a bug. label Dec 10, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 10, 2023
@ChrisDenton
Copy link
Contributor

You're not really meant to implement such extension traits on your own type. They're just used as a mechanism to add platform-specific functions to std types. Nowadays such traits are usually sealed (e.g. OsStrExt, ChildExt, etc) specifically to prevent this.

@ChrisDenton ChrisDenton added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-io Area: std::io, std::fs, std::net and std::path and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 10, 2023
@the8472
Copy link
Member

the8472 commented Dec 10, 2023

Might as well seal this one too while it's unimplementable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io Area: std::io, std::fs, std::net and std::path C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants