Skip to content

Commit 037b978

Browse files
committed
[Clippy] Swap manual_main_separator_str to use diagnostic item instead of path
1 parent afe7907 commit 037b978

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,7 @@ symbols! {
14251425
pat_param,
14261426
patchable_function_entry,
14271427
path,
1428+
path_main_separator,
14281429
path_to_pathbuf,
14291430
pathbuf_as_path,
14301431
pattern_complexity,

library/std/src/path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ pub fn is_separator(c: char) -> bool {
263263
///
264264
/// For example, `/` on Unix and `\` on Windows.
265265
#[stable(feature = "rust1", since = "1.0.0")]
266+
#[cfg_attr(not(test), rustc_diagnostic_item = "path_main_separator")]
266267
pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP;
267268

268269
/// The primary separator of path components for the current platform.

src/tools/clippy/clippy_lints/src/manual_main_separator_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_config::msrvs::{self, Msrv};
22
use clippy_config::Conf;
33
use clippy_utils::diagnostics::span_lint_and_sugg;
4-
use clippy_utils::{is_trait_method, match_def_path, paths, peel_hir_expr_refs};
4+
use clippy_utils::{is_trait_method, peel_hir_expr_refs};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::{Expr, ExprKind, Mutability, QPath};
@@ -56,7 +56,7 @@ impl LateLintPass<'_> for ManualMainSeparatorStr {
5656
&& let Res::Def(DefKind::Const, receiver_def_id) = path.res
5757
&& is_trait_method(cx, target, sym::ToString)
5858
&& self.msrv.meets(msrvs::PATH_MAIN_SEPARATOR_STR)
59-
&& match_def_path(cx, receiver_def_id, &paths::PATH_MAIN_SEPARATOR)
59+
&& cx.tcx.is_diagnostic_item(sym::path_main_separator, receiver_def_id)
6060
&& let ty::Ref(_, ty, Mutability::Not) = cx.typeck_results().expr_ty_adjusted(expr).kind()
6161
&& ty.is_str()
6262
{

src/tools/clippy/clippy_utils/src/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub const OPEN_OPTIONS_NEW: [&str; 4] = ["std", "fs", "OpenOptions", "new"];
4040
pub const PARKING_LOT_MUTEX_GUARD: [&str; 3] = ["lock_api", "mutex", "MutexGuard"];
4141
pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockReadGuard"];
4242
pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockWriteGuard"];
43-
pub const PATH_MAIN_SEPARATOR: [&str; 3] = ["std", "path", "MAIN_SEPARATOR"];
4443
#[cfg_attr(not(unix), allow(clippy::invalid_paths))]
4544
pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"];
4645
pub const PUSH_STR: [&str; 4] = ["alloc", "string", "String", "push_str"];

0 commit comments

Comments
 (0)