Avoid storing SymbolStr
in a struct.
It's intended only for very temporary use.
This commit is contained in:
parent
bf3104ec24
commit
62db617e40
@ -8,7 +8,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::{Ident, SymbolStr};
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
declare_clippy_lint! {
|
||||
@ -75,7 +75,7 @@ pub struct NonExpressiveNames {
|
||||
impl_lint_pass!(NonExpressiveNames => [SIMILAR_NAMES, MANY_SINGLE_CHAR_NAMES, JUST_UNDERSCORES_AND_DIGITS]);
|
||||
|
||||
struct ExistingName {
|
||||
interned: SymbolStr,
|
||||
interned: Symbol,
|
||||
span: Span,
|
||||
len: usize,
|
||||
exemptions: &'static [&'static str],
|
||||
@ -218,18 +218,19 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||
let mut split_at = None;
|
||||
match existing_name.len.cmp(&count) {
|
||||
Ordering::Greater => {
|
||||
if existing_name.len - count != 1 || levenstein_not_1(&interned_name, &existing_name.interned) {
|
||||
if existing_name.len - count != 1 || levenstein_not_1(&interned_name, &existing_name.interned.as_str()) {
|
||||
continue;
|
||||
}
|
||||
},
|
||||
Ordering::Less => {
|
||||
if count - existing_name.len != 1 || levenstein_not_1(&existing_name.interned, &interned_name) {
|
||||
if count - existing_name.len != 1 || levenstein_not_1(&existing_name.interned.as_str(), &interned_name) {
|
||||
continue;
|
||||
}
|
||||
},
|
||||
Ordering::Equal => {
|
||||
let mut interned_chars = interned_name.chars();
|
||||
let mut existing_chars = existing_name.interned.chars();
|
||||
let interned_str = existing_name.interned.as_str();
|
||||
let mut existing_chars = interned_str.chars();
|
||||
let first_i = interned_chars.next().expect("we know we have at least one char");
|
||||
let first_e = existing_chars.next().expect("we know we have at least one char");
|
||||
let eq_or_numeric = |(a, b): (char, char)| a == b || a.is_numeric() && b.is_numeric();
|
||||
@ -302,7 +303,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||
}
|
||||
self.0.names.push(ExistingName {
|
||||
exemptions: get_exemptions(&interned_name).unwrap_or(&[]),
|
||||
interned: interned_name,
|
||||
interned: ident.name,
|
||||
span: ident.span,
|
||||
len: count,
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ use rustc_ast::ast::{Item, ItemKind, UseTree, UseTreeKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::symbol::{Ident, SymbolStr};
|
||||
use rustc_span::symbol::Ident;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for imports that remove "unsafe" from an item's
|
||||
@ -73,6 +73,6 @@ fn unsafe_to_safe_check(old_name: Ident, new_name: Ident, cx: &EarlyContext<'_>,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn contains_unsafe(name: &SymbolStr) -> bool {
|
||||
fn contains_unsafe(name: &str) -> bool {
|
||||
name.contains("Unsafe") || name.contains("unsafe")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user