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

Resolve dead code warnings on various platforms #1423

Merged
merged 7 commits into from
Dec 8, 2024

Conversation

dtolnay
Copy link
Contributor

@dtolnay dtolnay commented Dec 7, 2024

warning: unused variable: `processes_to_update`
   --> src/unix/apple/system.rs:234:9
    |
234 |         processes_to_update: ProcessesToUpdate<'_>,
    |         ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_processes_to_update`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: field `bsd_name` is never read
  --> src/unix/apple/disk.rs:28:5
   |
25 | pub(crate) struct DiskInner {
   |                   --------- field in this struct
...
28 |     bsd_name: Option<Vec<u8>>,
   |     ^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: type alias `RetainedCFString` is never used
   --> src/unix/apple/disk.rs:341:17
    |
341 | pub(crate) type RetainedCFString = CFReleaser<core_foundation_sys::string::__CFString>;
    |                 ^^^^^^^^^^^^^^^^

warning: constant `KIO_RETURN_SUCCESS` is never used
   --> src/unix/apple/macos/ffi.rs:171:11
    |
171 | pub const KIO_RETURN_SUCCESS: i32 = 0;
    |           ^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: function `IOServiceMatching` is never used
   --> src/unix/apple/macos/ffi.rs:133:12
    |
133 |     pub fn IOServiceMatching(a: *const c_char) -> CFMutableDictionaryRef;
    |            ^^^^^^^^^^^^^^^^^

warning: function `IORegistryEntryGetName` is never used
   --> src/unix/apple/macos/ffi.rs:159:12
    |
159 |     pub fn IORegistryEntryGetName(entry: io_registry_entry_t, name: io_name_t) -> kern_return_t;
    |            ^^^^^^^^^^^^^^^^^^^^^^

warning: function `get_all_utf8_data_from_file` is never used
  --> src/unix/linux/utils.rs:15:15
   |
15 | pub(crate) fn get_all_utf8_data_from_file(file: &mut File, size: usize) -> io::Result<String> {
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: function `get_all_utf8_data` is never used
  --> src/unix/linux/utils.rs:22:15
   |
22 | pub(crate) fn get_all_utf8_data<P: AsRef<Path>>(file_path: P, size: usize) -> io::Result<String> {
   |               ^^^^^^^^^^^^^^^^^

warning: function `to_cpath` is never used
  --> src/unix/linux/utils.rs:88:15
   |
88 | pub(crate) fn to_cpath(path: &std::path::Path) -> Vec<u8> {
   |               ^^^^^^^^

warning: unused import: `self::ios as inner`
  --> src/unix/apple/mod.rs:15:24
   |
15 |         pub(crate) use self::ios as inner;
   |                        ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: function `display_ntstatus_error` is never used
   --> src/windows/process.rs:229:11
    |
229 | unsafe fn display_ntstatus_error(ntstatus: windows::core::HRESULT) {
    |           ^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: method `account_name` is never used
  --> src/windows/sid.rs:59:19
   |
20 | impl Sid {
   | -------- method in this implementation
...
59 |     pub(crate) fn account_name(&self) -> Option<String> {
   |                   ^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

@dtolnay dtolnay force-pushed the warnings branch 2 times, most recently from 2be51d1 to 9a089f5 Compare December 7, 2024 22:30
@dtolnay dtolnay changed the title Resolve warnings on iOS Resolve dead code warnings on various platforms Dec 7, 2024
`cargo check --target=aarch64-apple-ios`

    warning: unused variable: `processes_to_update`
       --> src/unix/apple/system.rs:234:9
        |
    234 |         processes_to_update: ProcessesToUpdate<'_>,
        |         ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_processes_to_update`
        |
        = note: `#[warn(unused_variables)]` on by default

    warning: field `bsd_name` is never read
      --> src/unix/apple/disk.rs:28:5
       |
    25 | pub(crate) struct DiskInner {
       |                   --------- field in this struct
    ...
    28 |     bsd_name: Option<Vec<u8>>,
       |     ^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

    warning: type alias `RetainedCFString` is never used
       --> src/unix/apple/disk.rs:341:17
        |
    341 | pub(crate) type RetainedCFString = CFReleaser<core_foundation_sys::string::__CFString>;
        |                 ^^^^^^^^^^^^^^^^
`cargo check --target=x86_64-apple-darwin --features=apple-sandbox`

    warning: constant `KIO_RETURN_SUCCESS` is never used
       --> src/unix/apple/macos/ffi.rs:171:11
        |
    171 | pub const KIO_RETURN_SUCCESS: i32 = 0;
        |           ^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(dead_code)]` on by default

    warning: function `IOServiceMatching` is never used
       --> src/unix/apple/macos/ffi.rs:133:12
        |
    133 |     pub fn IOServiceMatching(a: *const c_char) -> CFMutableDictionaryRef;
        |            ^^^^^^^^^^^^^^^^^

    warning: function `IORegistryEntryGetName` is never used
       --> src/unix/apple/macos/ffi.rs:159:12
        |
    159 |     pub fn IORegistryEntryGetName(entry: io_registry_entry_t, name: io_name_t) -> kern_return_t;
        |            ^^^^^^^^^^^^^^^^^^^^^^
`cargo check --target=x86_64-unknown-linux-gnu --no-default-features`

    warning: function `get_all_utf8_data_from_file` is never used
      --> src/unix/linux/utils.rs:15:15
       |
    15 | pub(crate) fn get_all_utf8_data_from_file(file: &mut File, size: usize) -> io::Result<String> {
       |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default

    warning: function `get_all_utf8_data` is never used
      --> src/unix/linux/utils.rs:22:15
       |
    22 | pub(crate) fn get_all_utf8_data<P: AsRef<Path>>(file_path: P, size: usize) -> io::Result<String> {
       |               ^^^^^^^^^^^^^^^^^

    warning: function `to_cpath` is never used
      --> src/unix/linux/utils.rs:88:15
       |
    88 | pub(crate) fn to_cpath(path: &std::path::Path) -> Vec<u8> {
       |               ^^^^^^^^
`cargo check --target=aarch64-apple-ios --no-default-features --features=disk`

    warning: unused import: `self::ios as inner`
      --> src/unix/apple/mod.rs:15:24
       |
    15 |         pub(crate) use self::ios as inner;
       |                        ^^^^^^^^^^^^^^^^^^
       |
       = note: `#[warn(unused_imports)]` on by default
`cargo check --target=x86_64-pc-windows-msvc --features=debug`

    warning: function `display_ntstatus_error` is never used
       --> src/windows/process.rs:229:11
        |
    229 | unsafe fn display_ntstatus_error(ntstatus: windows::core::HRESULT) {
        |           ^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `#[warn(dead_code)]` on by default
`cargo check --target=x86_64-pc-windows-msvc --no-default-features --features=system`

    warning: method `account_name` is never used
      --> src/windows/sid.rs:59:19
       |
    20 | impl Sid {
       | -------- method in this implementation
    ...
    59 |     pub(crate) fn account_name(&self) -> Option<String> {
       |                   ^^^^^^^^^^^^
       |
       = note: `#[warn(dead_code)]` on by default
@@ -225,17 +225,6 @@ fn windows_8_1_or_newer() -> &'static bool {
})
}

#[cfg(feature = "debug")]
unsafe fn display_ntstatus_error(ntstatus: windows::core::HRESULT) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last use of this function was deleted in #1316.

@GuillaumeGomez
Copy link
Owner

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit c840eac into GuillaumeGomez:master Dec 8, 2024
67 checks passed
@dtolnay dtolnay deleted the warnings branch December 8, 2024 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants