From b7455eb81c1ea3a07e5e0df0d93e7b23ac79104f Mon Sep 17 00:00:00 2001 From: klensy Date: Thu, 9 May 2024 12:09:04 +0300 Subject: [PATCH] Cleanup some deprecated, unused allows (#1067) --- src/lib.rs | 1 - src/windows/com.rs | 51 ++------------------------------------- src/windows/find_tools.rs | 2 +- 3 files changed, 3 insertions(+), 51 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d7122aec..cb2e51ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -217,7 +217,6 @@ #![doc(html_root_url = "https://docs.rs/cc/1.0")] #![cfg_attr(test, deny(warnings))] -#![allow(deprecated)] #![deny(missing_docs)] use std::borrow::Cow; diff --git a/src/windows/com.rs b/src/windows/com.rs index e81bb1d3..0391b5af 100644 --- a/src/windows/com.rs +++ b/src/windows/com.rs @@ -5,8 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. -#![allow(unused)] - use crate::windows::{ winapi::{IUnknown, Interface}, windows_sys::{ @@ -16,10 +14,9 @@ use crate::windows::{ }; use std::{ convert::TryInto, - ffi::{OsStr, OsString}, - mem::ManuallyDrop, + ffi::OsString, ops::Deref, - os::windows::ffi::{OsStrExt, OsStringExt}, + os::windows::ffi::OsStringExt, ptr::{null, null_mut}, slice::from_raw_parts, }; @@ -48,19 +45,6 @@ where assert!(!ptr.is_null()); ComPtr(ptr) } - /// Casts up the inheritance chain - pub fn up(self) -> ComPtr - where - T: Deref, - U: Interface, - { - ComPtr(self.into_raw() as *mut U) - } - /// Extracts the raw pointer. - /// You are now responsible for releasing it yourself. - pub fn into_raw(self) -> *mut T { - ManuallyDrop::new(self).0 - } /// For internal use only. fn as_unknown(&self) -> &IUnknown { unsafe { &*(self.0 as *mut IUnknown) } @@ -124,34 +108,3 @@ impl Drop for BStr { unsafe { SysFreeString(self.0) }; } } - -pub trait ToWide { - fn to_wide(&self) -> Vec; - fn to_wide_null(&self) -> Vec; -} -impl ToWide for T -where - T: AsRef, -{ - fn to_wide(&self) -> Vec { - self.as_ref().encode_wide().collect() - } - fn to_wide_null(&self) -> Vec { - self.as_ref().encode_wide().chain(Some(0)).collect() - } -} -pub trait FromWide -where - Self: Sized, -{ - fn from_wide(wide: &[u16]) -> Self; - fn from_wide_null(wide: &[u16]) -> Self { - let len = wide.iter().take_while(|&&c| c != 0).count(); - Self::from_wide(&wide[..len]) - } -} -impl FromWide for OsString { - fn from_wide(wide: &[u16]) -> OsString { - OsStringExt::from_wide(wide) - } -} diff --git a/src/windows/find_tools.rs b/src/windows/find_tools.rs index b0061948..c4a92bde 100644 --- a/src/windows/find_tools.rs +++ b/src/windows/find_tools.rs @@ -928,7 +928,7 @@ mod impl_ { for subkey in key.iter().filter_map(|k| k.ok()) { let val = subkey .to_str() - .and_then(|s| s.trim_left_matches("v").replace('.', "").parse().ok()); + .and_then(|s| s.trim_start_matches("v").replace('.', "").parse().ok()); let val = match val { Some(s) => s, None => continue,