Skip to content

Commit 6b0796d

Browse files
committed
fmt and docs
1 parent 6ca627f commit 6b0796d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clippy_lints/src/path_from_format.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
2-
use clippy_utils::ty::is_type_diagnostic_item;
3-
use clippy_utils::{match_qpath, paths, peel_hir_expr_refs};
4-
use rustc_hir::{StmtKind,BorrowKind, Mutability, BindingAnnotation, PatKind, Expr, ExprKind};
2+
use clippy_utils::match_qpath;
3+
use rustc_hir::{Expr, ExprKind};
54
use rustc_lint::{LateContext, LateLintPass};
65
use rustc_session::{declare_lint_pass, declare_tool_lint};
76
use rustc_span::sym;
87

98
declare_clippy_lint! {
109
/// ### What it does
10+
/// Checks for `PathBuf::From(format!(..))` calls.
1111
///
1212
/// ### Why is this bad?
13+
/// It is not OS-agnostic, and can be harder to read.
1314
///
1415
/// ### Example
1516
/// ```rust
16-
/// // example code where clippy issues a warning
17+
/// PathBuf::from(format!("{}/foo/bar", base_path));
1718
/// ```
1819
/// Use instead:
1920
/// ```rust
20-
/// // example code which does not raise clippy warning
21+
/// Path::new(base_path).join("foo").join("bar")
2122
/// ```
2223
#[clippy::version = "1.62.0"]
2324
pub PATH_FROM_FORMAT,
2425
pedantic,
25-
"default lint description"
26+
"builds a `PathBuf` from a format macro"
2627
}
2728

2829
declare_lint_pass!(PathFromFormat => [PATH_FROM_FORMAT]);
@@ -66,7 +67,7 @@ impl<'tcx> LateLintPass<'tcx> for PathFromFormat {
6667
// if let Some(trailing_expr) = block.expr;
6768
// if let ExprKind::Path(ref qpath5) = trailing_expr.kind;
6869
// if match_qpath(qpath5, &["res"]);
69-
then {
70+
then {
7071
span_lint_and_help(
7172
cx,
7273
PATH_FROM_FORMAT,
@@ -79,4 +80,4 @@ impl<'tcx> LateLintPass<'tcx> for PathFromFormat {
7980
}
8081
}
8182
}
82-
}
83+
}

0 commit comments

Comments
 (0)