Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 05dcfe3

Browse files
committed
name_without_tool Now takes a &str instead of String
1 parent 91e79d3 commit 05dcfe3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

compiler/rustc_lint/src/late.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>(
386386
.filter(|pass| {
387387
let pass = LintPass::get_lints(pass);
388388
pass.iter().any(|&lint| {
389-
let lint_name = name_without_tool(lint.name.to_lowercase());
389+
let lint_name = name_without_tool(&lint.name.to_lowercase()).to_string();
390390
lints_to_emit.contains(&lint_name)
391391
|| (!lints_allowed.contains(&lint_name)
392392
&& lint.default_level != crate::Level::Allow)
@@ -486,7 +486,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) {
486486

487487
/// Format name ignoring the name, useful for filtering non-used lints.
488488
/// For example, 'clippy::my_lint' will turn into 'my_lint'
489-
pub(crate) fn name_without_tool(name: String) -> String {
489+
pub(crate) fn name_without_tool(name: &str) -> &str {
490490
// Doing some calculations here to account for those separators
491-
name[name.find("::").unwrap_or(name.len() - 2) + 2..].to_string()
491+
name.rsplit("::").next().unwrap_or(name)
492492
}

compiler/rustc_lint/src/levels.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,15 @@ pub fn lints_that_can_emit(tcx: TyCtxt<'_>, (): ()) -> Lrc<(Vec<String>, Vec<Str
129129

130130
let lint_groups = store.get_lint_groups();
131131
for group in lint_groups {
132-
let group_name = name_without_tool(group.0.to_lowercase());
132+
let binding = group.0.to_lowercase();
133+
let group_name = name_without_tool(&binding).to_string();
133134
if visitor.lints_to_emit.contains(&group_name) {
134135
for lint in group.1 {
135-
visitor.lints_to_emit.push(name_without_tool(lint.to_string()));
136+
visitor.lints_to_emit.push(name_without_tool(&lint.to_string()).to_string());
136137
}
137138
} else if visitor.lints_allowed.contains(&group_name) {
138139
for lint in &group.1 {
139-
visitor.lints_allowed.push(name_without_tool(lint.to_string()));
140+
visitor.lints_allowed.push(name_without_tool(&lint.to_string()).to_string());
140141
}
141142
}
142143
}

0 commit comments

Comments
 (0)