@@ -46,7 +46,7 @@ mod iter_overeager_cloned;
46
46
mod iter_skip_next;
47
47
mod iter_with_drain;
48
48
mod iterator_step_by_zero;
49
- mod join_absolute_path ;
49
+ mod join_absolute_paths ;
50
50
mod manual_next_back;
51
51
mod manual_ok_or;
52
52
mod manual_saturating_arithmetic;
@@ -2975,8 +2975,8 @@ declare_clippy_lint! {
2975
2975
/// # let mut state = DefaultHasher::new();
2976
2976
/// # let my_enum = Foo::Empty;
2977
2977
/// match my_enum {
2978
- /// Empty => ().hash(&mut state),
2979
- /// WithValue(x) => x.hash(&mut state),
2978
+ /// Empty => ().hash(&mut state),
2979
+ /// WithValue(x) => x.hash(&mut state),
2980
2980
/// }
2981
2981
/// ```
2982
2982
/// Use instead:
@@ -2988,8 +2988,8 @@ declare_clippy_lint! {
2988
2988
/// # let mut state = DefaultHasher::new();
2989
2989
/// # let my_enum = Foo::Empty;
2990
2990
/// match my_enum {
2991
- /// Empty => 0_u8.hash(&mut state),
2992
- /// WithValue(x) => x.hash(&mut state),
2991
+ /// Empty => 0_u8.hash(&mut state),
2992
+ /// WithValue(x) => x.hash(&mut state),
2993
2993
/// }
2994
2994
/// ```
2995
2995
#[ clippy:: version = "1.58.0" ]
@@ -3264,37 +3264,39 @@ declare_clippy_lint! {
3264
3264
3265
3265
declare_clippy_lint ! {
3266
3266
/// ### What it does
3267
- /// Checks for initial `'/ or \\'` in an argument to `.join()` on a `Path` .
3267
+ /// Checks for calls to `Path::join` that start with a path separator, like `\\` or `/`. .
3268
3268
///
3269
3269
/// ### Why is this bad?
3270
- /// `.join()` comments starting with a separator (`/` or `\\`) can replace the entire path.
3271
- /// If this is intentional, prefer creating a new `Path` instead.
3270
+ /// `.join()` arguments starting with a separator (`/` or `\\`) can replace the entire path.
3271
+ /// If this is intentional, prefer using `Path::new() ` instead.
3272
3272
///
3273
3273
/// See [`Path::join()`](https://doc.rust-lang.org/std/path/struct.Path.html#method.join)
3274
3274
///
3275
3275
/// ### Example
3276
3276
/// ```rust
3277
- /// let path = std::path::Path::new("/bin");
3278
- /// let res = path.join("/sh");
3279
- /// assert_eq!(res, std::path::PathBuf::from("/sh"));
3277
+ /// # use std::path::{Path, PathBuf};
3278
+ /// let path = Path::new("/bin");
3279
+ /// let joined_path = path.join("/sh");
3280
+ /// assert_eq!(joined_path, PathBuf::from("/sh"));
3280
3281
/// ```
3281
3282
///
3282
3283
/// Use instead;
3283
3284
/// ```rust
3284
- /// let path = std::path::Path::new("/bin");
3285
+ /// # use std::path::{Path, PathBuf};
3286
+ /// let path = Path::new("/bin");
3285
3287
///
3286
3288
/// // If this was unintentional, remove the leading separator
3287
- /// let extend = path.join("sh");
3288
- /// assert_eq!(extend, std::path:: PathBuf::from("/bin/sh"));
3289
+ /// let joined_path = path.join("sh");
3290
+ /// assert_eq!(joined_path, PathBuf::from("/bin/sh"));
3289
3291
///
3290
3292
/// // If this was intentional, create a new path instead
3291
- /// let new = std::path:: Path::new("/sh");
3292
- /// assert_eq!(new, std::path:: PathBuf::from("/sh"));
3293
+ /// let new = Path::new("/sh");
3294
+ /// assert_eq!(new, PathBuf::from("/sh"));
3293
3295
/// ```
3294
3296
#[ clippy:: version = "1.70.0" ]
3295
- pub JOIN_ABSOLUTE_PATH ,
3296
- pedantic ,
3297
- "arg to .join called on a Path contains '/' at the start "
3297
+ pub JOIN_ABSOLUTE_PATHS ,
3298
+ correctness ,
3299
+ "arg to .join called on a Path contains leading separator "
3298
3300
}
3299
3301
3300
3302
declare_clippy_lint ! {
@@ -3544,7 +3546,7 @@ impl_lint_pass!(Methods => [
3544
3546
NEEDLESS_COLLECT ,
3545
3547
SUSPICIOUS_COMMAND_ARG_SPACE ,
3546
3548
CLEAR_WITH_DRAIN ,
3547
- JOIN_ABSOLUTE_PATH ,
3549
+ JOIN_ABSOLUTE_PATHS ,
3548
3550
MANUAL_NEXT_BACK ,
3549
3551
UNNECESSARY_LITERAL_UNWRAP ,
3550
3552
DRAIN_COLLECT ,
@@ -3869,7 +3871,9 @@ impl Methods {
3869
3871
if let Some ( ( "collect" , _, _, span, _) ) = method_call ( recv) {
3870
3872
unnecessary_join:: check ( cx, expr, recv, join_arg, span) ;
3871
3873
}
3872
- else { join_absolute_path:: check ( cx, expr, join_arg, span) ; }
3874
+ else {
3875
+ join_absolute_paths:: check ( cx, recv, join_arg) ;
3876
+ }
3873
3877
} ,
3874
3878
( "last" , [ ] ) | ( "skip" , [ _] ) => {
3875
3879
if let Some ( ( name2, recv2, args2, _span2, _) ) = method_call ( recv) {
0 commit comments