Skip to content

Commit

Permalink
fix incompatible_msrv warning
Browse files Browse the repository at this point in the history
Clippy can't figure out that these cfgs are already version-gated.
  • Loading branch information
sunshowers committed May 14, 2024
1 parent c84a312 commit f314336
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
//! Instead, `camino` allows you to check that your paths are UTF-8 *once*, and then manipulate them
//! as valid UTF-8 from there on, avoiding repeated lossy and confusing conversions.

// General note: we use #[allow(clippy::incompatible_msrv)] for code that's already guarded by a
// version-specific cfg conditional.

use std::{
borrow::{Borrow, Cow},
cmp::Ordering,
Expand Down Expand Up @@ -204,6 +207,7 @@ impl Utf8PathBuf {
///
/// [`with_capacity`]: PathBuf::with_capacity
#[cfg(path_buf_capacity)]
#[allow(clippy::incompatible_msrv)]
#[must_use]
pub fn with_capacity(capacity: usize) -> Utf8PathBuf {
Utf8PathBuf(PathBuf::with_capacity(capacity))
Expand Down Expand Up @@ -391,6 +395,7 @@ impl Utf8PathBuf {
///
/// [`capacity`]: PathBuf::capacity
#[cfg(path_buf_capacity)]
#[allow(clippy::incompatible_msrv)]
#[must_use]
pub fn capacity(&self) -> usize {
self.0.capacity()
Expand All @@ -402,6 +407,7 @@ impl Utf8PathBuf {
///
/// [`clear`]: PathBuf::clear
#[cfg(path_buf_capacity)]
#[allow(clippy::incompatible_msrv)]
pub fn clear(&mut self) {
self.0.clear()
}
Expand All @@ -412,6 +418,7 @@ impl Utf8PathBuf {
///
/// [`reserve`]: PathBuf::reserve
#[cfg(path_buf_capacity)]
#[allow(clippy::incompatible_msrv)]
pub fn reserve(&mut self, additional: usize) {
self.0.reserve(additional)
}
Expand All @@ -422,6 +429,7 @@ impl Utf8PathBuf {
///
/// [`try_reserve`]: PathBuf::try_reserve
#[cfg(try_reserve_2)]
#[allow(clippy::incompatible_msrv)]
#[inline]
pub fn try_reserve(
&mut self,
Expand All @@ -436,6 +444,7 @@ impl Utf8PathBuf {
///
/// [`reserve_exact`]: PathBuf::reserve_exact
#[cfg(path_buf_capacity)]
#[allow(clippy::incompatible_msrv)]
pub fn reserve_exact(&mut self, additional: usize) {
self.0.reserve_exact(additional)
}
Expand All @@ -446,6 +455,7 @@ impl Utf8PathBuf {
///
/// [`try_reserve_exact`]: PathBuf::try_reserve_exact
#[cfg(try_reserve_2)]
#[allow(clippy::incompatible_msrv)]
#[inline]
pub fn try_reserve_exact(
&mut self,
Expand All @@ -460,6 +470,7 @@ impl Utf8PathBuf {
///
/// [`shrink_to_fit`]: PathBuf::shrink_to_fit
#[cfg(path_buf_capacity)]
#[allow(clippy::incompatible_msrv)]
pub fn shrink_to_fit(&mut self) {
self.0.shrink_to_fit()
}
Expand All @@ -470,6 +481,7 @@ impl Utf8PathBuf {
///
/// [`shrink_to`]: PathBuf::shrink_to
#[cfg(shrink_to)]
#[allow(clippy::incompatible_msrv)]
#[inline]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.0.shrink_to(min_capacity)
Expand All @@ -486,6 +498,7 @@ impl Deref for Utf8PathBuf {

/// *Requires Rust 1.68 or newer.*
#[cfg(path_buf_deref_mut)]
#[allow(clippy::incompatible_msrv)]
impl std::ops::DerefMut for Utf8PathBuf {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { Utf8Path::assume_utf8_mut(&mut self.0) }
Expand Down
7 changes: 5 additions & 2 deletions src/proptest_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ impl Arbitrary for Utf8PathBuf {
prop::collection::vec(any_with::<String>(args), 0..8),
)
.prop_map(|(is_relative, components)| {
let initial_component =
is_relative.then(|| format!("{}", std::path::MAIN_SEPARATOR));
let initial_component = if is_relative {
Some(format!("{}", std::path::MAIN_SEPARATOR))
} else {
None
};
initial_component.into_iter().chain(components).collect()
})
.boxed()
Expand Down

0 comments on commit f314336

Please sign in to comment.