Skip to content

Commit 85f4ccc

Browse files
committed
renamed lint
1 parent 1d77675 commit 85f4ccc

File tree

7 files changed

+40
-10
lines changed

7 files changed

+40
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4939,7 +4939,7 @@ Released 2018-09-13
49394939
[`iter_skip_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next
49404940
[`iter_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain
49414941
[`iterator_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iterator_step_by_zero
4942-
[`join_absolute_path`]: https://rust-lang.github.io/rust-clippy/master/index.html#join_absolute_path
4942+
[`join_absolute_paths`]: https://rust-lang.github.io/rust-clippy/master/index.html#join_absolute_paths
49434943
[`just_underscores_and_digits`]: https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
49444944
[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
49454945
[`large_digit_groups`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_digit_groups

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
359359
crate::methods::ITER_OVEREAGER_CLONED_INFO,
360360
crate::methods::ITER_SKIP_NEXT_INFO,
361361
crate::methods::ITER_WITH_DRAIN_INFO,
362-
crate::methods::JOIN_ABSOLUTE_PATH_INFO,
362+
crate::methods::JOIN_ABSOLUTE_PATHS_INFO,
363363
crate::methods::MANUAL_FILTER_MAP_INFO,
364364
crate::methods::MANUAL_FIND_MAP_INFO,
365365
crate::methods::MANUAL_NEXT_BACK_INFO,

clippy_lints/src/methods/join_absolute_path.rs renamed to clippy_lints/src/methods/join_absolute_paths.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{Expr, ExprKind};
55
use rustc_lint::LateContext;
66
use rustc_span::{symbol::sym::Path, Span};
77

8-
use super::JOIN_ABSOLUTE_PATH;
8+
use super::JOIN_ABSOLUTE_PATHS;
99

1010
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, join_arg: &'tcx Expr<'tcx>, span: Span) {
1111
let ty = cx.typeck_results().expr_ty(expr);
@@ -18,7 +18,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, join_a
1818
then {
1919
span_lint_and_sugg(
2020
cx,
21-
JOIN_ABSOLUTE_PATH,
21+
JOIN_ABSOLUTE_PATHS,
2222
span.with_hi(expr.span.hi()),
2323
r#"argument in join called on path contains a starting '/'"#,
2424
"try removing first '/' or '\\'",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use clippy_utils::{diagnostics::span_lint_and_sugg, ty::is_type_diagnostic_item};
2+
use rustc_ast::ast::LitKind;
3+
use rustc_errors::Applicability;
4+
use rustc_hir::{Expr, ExprKind};
5+
use rustc_lint::LateContext;
6+
use rustc_span::{symbol::sym::Path, Span};
7+
8+
use super::JOIN_ABSOLUTE_PATHSS;
9+
10+
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, join_arg: &'tcx Expr<'tcx>, span: Span) {
11+
let ty = cx.typeck_results().expr_ty(expr);
12+
if_chain!(
13+
if is_type_diagnostic_item(cx, ty, Path);
14+
let applicability = Applicability::MachineApplicable;
15+
if let ExprKind::Lit(spanned) = &join_arg.kind;
16+
if let LitKind::Str(symbol, _) = spanned.node;
17+
if symbol.as_str().starts_with('/') || symbol.as_str().starts_with('\\');
18+
then {
19+
span_lint_and_sugg(
20+
cx,
21+
JOIN_ABSOLUTE_PATHSS,
22+
span.with_hi(expr.span.hi()),
23+
r#"argument in join called on path contains a starting '/'"#,
24+
"try removing first '/' or '\\'",
25+
"join(\"your/path/here\")".to_owned(),
26+
applicability
27+
);
28+
}
29+
);
30+
}

clippy_lints/src/methods/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mod iter_overeager_cloned;
4646
mod iter_skip_next;
4747
mod iter_with_drain;
4848
mod iterator_step_by_zero;
49-
mod join_absolute_path;
49+
mod join_absolute_paths;
5050
mod manual_next_back;
5151
mod manual_ok_or;
5252
mod manual_saturating_arithmetic;
@@ -3292,7 +3292,7 @@ declare_clippy_lint! {
32923292
/// assert_eq!(new, std::path::PathBuf::from("/sh"));
32933293
/// ```
32943294
#[clippy::version = "1.70.0"]
3295-
pub JOIN_ABSOLUTE_PATH,
3295+
pub JOIN_ABSOLUTE_PATHS,
32963296
pedantic,
32973297
"arg to .join called on a Path contains '/' at the start"
32983298
}
@@ -3544,7 +3544,7 @@ impl_lint_pass!(Methods => [
35443544
NEEDLESS_COLLECT,
35453545
SUSPICIOUS_COMMAND_ARG_SPACE,
35463546
CLEAR_WITH_DRAIN,
3547-
JOIN_ABSOLUTE_PATH,
3547+
JOIN_ABSOLUTE_PATHS,
35483548
MANUAL_NEXT_BACK,
35493549
UNNECESSARY_LITERAL_UNWRAP,
35503550
DRAIN_COLLECT,
@@ -3869,7 +3869,7 @@ impl Methods {
38693869
if let Some(("collect", _, _, span, _)) = method_call(recv) {
38703870
unnecessary_join::check(cx, expr, recv, join_arg, span);
38713871
}
3872-
else {join_absolute_path::check(cx, expr, join_arg, span);}
3872+
else {join_absolute_paths::check(cx, expr, join_arg, span);}
38733873
},
38743874
("last", []) | ("skip", [_]) => {
38753875
if let Some((name2, recv2, args2, _span2, _)) = method_call(recv) {

tests/ui/join_absolute_path.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@run-rustfix
22
#![allow(unused)]
3-
#![warn(clippy::join_absolute_path)]
3+
#![warn(clippy::join_absolute_paths)]
44
use std::path::Path;
55

66
fn main() {

tests/ui/join_absolute_path.rs renamed to tests/ui/join_absolute_paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@run-rustfix
22
#![allow(unused)]
3-
#![warn(clippy::join_absolute_path)]
3+
#![warn(clippy::join_absolute_paths)]
44
use std::path::Path;
55

66
fn main() {

0 commit comments

Comments
 (0)