From 2be51d1c5c0f4c4b7c555af17768b122a2c6f082 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 7 Dec 2024 14:15:18 -0800 Subject: [PATCH] Resolve warnings on Linux with no default features `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 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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>(file_path: P, size: usize) -> io::Result { | ^^^^^^^^^^^^^^^^^ 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 { | ^^^^^^^^ --- src/unix/linux/utils.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unix/linux/utils.rs b/src/unix/linux/utils.rs index 7b30e2513..678333372 100644 --- a/src/unix/linux/utils.rs +++ b/src/unix/linux/utils.rs @@ -1,7 +1,10 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#[cfg(any(feature = "disk", feature = "system"))] use std::fs::File; +#[cfg(any(feature = "disk", feature = "system"))] use std::io::{self, Read, Seek}; +#[cfg(any(feature = "disk", feature = "system"))] use std::path::Path; #[cfg(feature = "system")] @@ -12,6 +15,7 @@ pub(crate) fn get_all_data_from_file(file: &mut File, size: usize) -> io::Result Ok(buf) } +#[cfg(any(feature = "disk", feature = "system"))] pub(crate) fn get_all_utf8_data_from_file(file: &mut File, size: usize) -> io::Result { let mut buf = String::with_capacity(size); file.rewind()?; @@ -19,6 +23,7 @@ pub(crate) fn get_all_utf8_data_from_file(file: &mut File, size: usize) -> io::R Ok(buf) } +#[cfg(any(feature = "disk", feature = "system"))] pub(crate) fn get_all_utf8_data>(file_path: P, size: usize) -> io::Result { let mut file = File::open(file_path.as_ref())?; get_all_utf8_data_from_file(&mut file, size) @@ -85,6 +90,7 @@ pub(crate) fn to_u64(v: &[u8]) -> u64 { } /// Converts a path to a NUL-terminated `Vec` suitable for use with C functions. +#[cfg(feature = "disk")] pub(crate) fn to_cpath(path: &std::path::Path) -> Vec { use std::{ffi::OsStr, os::unix::ffi::OsStrExt};