Skip to content

Commit ecd4919

Browse files
committed
Remove unnecessary sigils around Symbol::as_str() calls.
1 parent a89a063 commit ecd4919

24 files changed

+34
-34
lines changed

clippy_lints/src/attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
486486

487487
fn check_semver(cx: &LateContext<'_>, span: Span, lit: &Lit) {
488488
if let LitKind::Str(is, _) = lit.kind {
489-
if Version::parse(&is.as_str()).is_ok() {
489+
if Version::parse(is.as_str()).is_ok() {
490490
return;
491491
}
492492
}
@@ -619,7 +619,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
619619
MetaItemKind::Word => {
620620
if_chain! {
621621
if let Some(ident) = meta.ident();
622-
if let Some(os) = find_os(&*ident.name.as_str());
622+
if let Some(os) = find_os(ident.name.as_str());
623623
then {
624624
mismatched.push((os, ident.span));
625625
}

clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
272272
.copied()
273273
.flat_map(|(a, b)| vec![(a, b), (b, a)])
274274
.find(|&(a, _)| {
275-
let path: &str = &path.ident.name.as_str();
275+
let path: &str = path.ident.name.as_str();
276276
a == path
277277
})
278278
.and_then(|(_, neg_method)| Some(format!("{}.{}()", snippet_opt(cx, args[0].span)?, neg_method)))

clippy_lints/src/checked_conversions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ fn get_implementing_type<'a>(path: &QPath<'_>, candidates: &'a [&str], function:
321321
if let TyKind::Path(QPath::Resolved(None, tp)) = &ty.kind;
322322
if let [int] = &*tp.segments;
323323
then {
324-
let name = &int.ident.name.as_str();
325-
candidates.iter().find(|c| name == *c).copied()
324+
let name = int.ident.name.as_str();
325+
candidates.iter().find(|c| &name == *c).copied()
326326
} else {
327327
None
328328
}
@@ -335,8 +335,8 @@ fn int_ty_to_sym<'tcx>(path: &QPath<'_>) -> Option<&'tcx str> {
335335
if let QPath::Resolved(_, path) = *path;
336336
if let [ty] = &*path.segments;
337337
then {
338-
let name = &ty.ident.name.as_str();
339-
INTS.iter().find(|c| name == *c).copied()
338+
let name = ty.ident.name.as_str();
339+
INTS.iter().find(|c| &name == *c).copied()
340340
} else {
341341
None
342342
}

clippy_lints/src/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs
437437

438438
for attr in attrs {
439439
if let AttrKind::DocComment(comment_kind, comment) = attr.kind {
440-
let (comment, current_spans) = strip_doc_comment_decoration(&comment.as_str(), comment_kind, attr.span);
440+
let (comment, current_spans) = strip_doc_comment_decoration(comment.as_str(), comment_kind, attr.span);
441441
spans.extend_from_slice(&current_spans);
442442
doc.push_str(&comment);
443443
} else if attr.has_name(sym::doc) {

clippy_lints/src/enum_variants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn check_variant(
153153
);
154154
}
155155
}
156-
let first = &def.variants[0].ident.name.as_str();
156+
let first = def.variants[0].ident.name.as_str();
157157
let mut pre = &first[..str_utils::camel_case_until(&*first).byte_index];
158158
let mut post = &first[str_utils::camel_case_start(&*first).byte_index..];
159159
for var in def.variants {

clippy_lints/src/float_literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
6868
if let LitKind::Float(sym, lit_float_ty) = lit.node;
6969
then {
7070
let sym_str = sym.as_str();
71-
let formatter = FloatFormat::new(&sym_str);
71+
let formatter = FloatFormat::new(sym_str);
7272
// Try to bail out if the float is for sure fine.
7373
// If its within the 2 decimal digits of being out of precision we
7474
// check if the parsed representation is the same as the string

clippy_lints/src/floating_point_arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatingPointArithmetic {
696696
let recv_ty = cx.typeck_results().expr_ty(&args[0]);
697697

698698
if recv_ty.is_floating_point() {
699-
match &*path.ident.name.as_str() {
699+
match path.ident.name.as_str() {
700700
"ln" => check_ln1p(cx, expr, args),
701701
"log" => check_log_base(cx, expr, args),
702702
"powf" => check_powf(cx, expr, args),

clippy_lints/src/iter_not_returning_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare_lint_pass!(IterNotReturningIterator => [ITER_NOT_RETURNING_ITERATOR]);
4242

4343
impl LateLintPass<'_> for IterNotReturningIterator {
4444
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'tcx>) {
45-
let name: &str = &impl_item.ident.name.as_str();
45+
let name = impl_item.ident.name.as_str();
4646
if_chain! {
4747
if let ImplItemKind::Fn(fn_sig, _) = &impl_item.kind;
4848
let ret_ty = return_ty(cx, impl_item.hir_id());

clippy_lints/src/loops/needless_collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
3131
let ty = cx.typeck_results().expr_ty(&args[0]);
3232
let mut applicability = Applicability::MaybeIncorrect;
3333
let is_empty_sugg = "next().is_none()".to_string();
34-
let method_name = &*method.ident.name.as_str();
34+
let method_name = method.ident.name.as_str();
3535
let sugg = if is_type_diagnostic_item(cx, ty, sym::Vec) ||
3636
is_type_diagnostic_item(cx, ty, sym::VecDeque) ||
3737
is_type_diagnostic_item(cx, ty, sym::LinkedList) ||
@@ -210,7 +210,7 @@ impl<'tcx> Visitor<'tcx> for IterFunctionVisitor<'_, 'tcx> {
210210
if let Some(hir_id) = self.current_statement_hir_id {
211211
self.hir_id_uses_map.insert(hir_id, self.uses.len());
212212
}
213-
match &*method_name.ident.name.as_str() {
213+
match method_name.ident.name.as_str() {
214214
"into_iter" => self.uses.push(Some(IterFunction {
215215
func: IterFunctionKind::IntoIter,
216216
span: expr.span,

clippy_lints/src/matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ fn check_wild_err_arm<'tcx>(cx: &LateContext<'tcx>, ex: &Expr<'tcx>, arms: &[Arm
966966
for pat in inner.iter() {
967967
if let PatKind::Binding(_, id, ident, None) = pat.kind {
968968
if ident.as_str().starts_with('_') && !is_local_used(cx, arm.body, id) {
969-
ident_bind_name = (&ident.name.as_str()).to_string();
969+
ident_bind_name = ident.name.as_str().to_string();
970970
matching_wild = true;
971971
}
972972
}

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
21542154
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty().skip_binder();
21552155
wrong_self_convention::check(
21562156
cx,
2157-
&item.ident.name.as_str(),
2157+
item.ident.name.as_str(),
21582158
self_ty,
21592159
first_arg_ty,
21602160
first_arg_span,

clippy_lints/src/missing_enforced_import_rename.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl LateLintPass<'_> for ImportRename {
7575
if let Some(import) = match snip.split_once(" as ") {
7676
None => Some(snip.as_str()),
7777
Some((import, rename)) => {
78-
if rename.trim() == &*name.as_str() {
78+
if rename.trim() == name.as_str() {
7979
None
8080
} else {
8181
Some(import.trim())

clippy_lints/src/non_expressive_names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
224224
match existing_name.len.cmp(&count) {
225225
Ordering::Greater => {
226226
if existing_name.len - count != 1
227-
|| levenstein_not_1(&interned_name, &existing_name.interned.as_str())
227+
|| levenstein_not_1(&interned_name, existing_name.interned.as_str())
228228
{
229229
continue;
230230
}
231231
},
232232
Ordering::Less => {
233233
if count - existing_name.len != 1
234-
|| levenstein_not_1(&existing_name.interned.as_str(), &interned_name)
234+
|| levenstein_not_1(existing_name.interned.as_str(), &interned_name)
235235
{
236236
continue;
237237
}

clippy_lints/src/nonstandard_macro_braces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn is_offending_macro<'a>(cx: &EarlyContext<'_>, span: Span, mac_braces: &'a Mac
104104
};
105105
if_chain! {
106106
if let ExpnKind::Macro(MacroKind::Bang, mac_name) = span.ctxt().outer_expn_data().kind;
107-
let name = &*mac_name.as_str();
107+
let name = mac_name.as_str();
108108
if let Some(braces) = mac_braces.macro_braces.get(name);
109109
if let Some(snip) = snippet_opt(cx, span.ctxt().outer_expn_data().call_site);
110110
// we must check only invocation sites

clippy_lints/src/path_buf_push_overwrite.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for PathBufPushOverwrite {
5353
if let Some(get_index_arg) = args.get(1);
5454
if let ExprKind::Lit(ref lit) = get_index_arg.kind;
5555
if let LitKind::Str(ref path_lit, _) = lit.node;
56-
if let pushed_path = Path::new(&*path_lit.as_str());
56+
if let pushed_path = Path::new(path_lit.as_str());
5757
if let Some(pushed_path_lit) = pushed_path.to_str();
5858
if pushed_path.has_root();
5959
if let Some(root) = pushed_path.components().next();

clippy_lints/src/regex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) {
150150

151151
if let ExprKind::Lit(ref lit) = expr.kind {
152152
if let LitKind::Str(ref r, style) = lit.node {
153-
let r = &r.as_str();
153+
let r = r.as_str();
154154
let offset = if let StrStyle::Raw(n) = style { 2 + n } else { 1 };
155155
match parser.parse(r) {
156156
Ok(r) => {

clippy_lints/src/stable_sort_primitive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn detect_stable_sort_primitive(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option
8989
if_chain! {
9090
if let ExprKind::MethodCall(method_name, _, args, _) = &expr.kind;
9191
if let Some(slice) = &args.get(0);
92-
if let Some(method) = SortingKind::from_stable_name(&method_name.ident.name.as_str());
92+
if let Some(method) = SortingKind::from_stable_name(method_name.ident.name.as_str());
9393
if let Some(slice_type) = is_slice_of_primitives(cx, slice);
9494
then {
9595
let args_str = args.iter().skip(1).map(|arg| Sugg::hir(cx, arg, "..").to_string()).collect::<Vec<String>>().join(", ");

clippy_lints/src/strings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes {
330330
if let ExprKind::MethodCall(path, _, [recv], _) = &e.kind;
331331
if path.ident.name == sym!(into_bytes);
332332
if let ExprKind::MethodCall(path, _, [recv], _) = &recv.kind;
333-
if matches!(&*path.ident.name.as_str(), "to_owned" | "to_string");
333+
if matches!(path.ident.name.as_str(), "to_owned" | "to_string");
334334
if let ExprKind::Lit(lit) = &recv.kind;
335335
if let LitKind::Str(lit_content, _) = &lit.node;
336336

clippy_lints/src/unit_types/unit_cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
1212
if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
1313
let op = cmp.node;
1414
if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
15-
let result = match &*symbol.as_str() {
15+
let result = match symbol.as_str() {
1616
"assert_eq" | "debug_assert_eq" => "succeed",
1717
"assert_ne" | "debug_assert_ne" => "fail",
1818
_ => return,

clippy_lints/src/unused_unit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl EarlyLintPass for UnusedUnit {
9494

9595
if_chain! {
9696
if segments.len() == 1;
97-
if ["Fn", "FnMut", "FnOnce"].contains(&&*segments[0].ident.name.as_str());
97+
if ["Fn", "FnMut", "FnOnce"].contains(&segments[0].ident.name.as_str());
9898
if let Some(args) = &segments[0].args;
9999
if let ast::GenericArgs::Parenthesized(generic_args) = &**args;
100100
if let ast::FnRetTy::Ty(ty) = &generic_args.output;

clippy_lints/src/write.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ impl EarlyLintPass for Write {
371371
/// Return this and a boolean indicating whether it only consisted of a newline.
372372
fn newline_span(fmtstr: &StrLit) -> (Span, bool) {
373373
let sp = fmtstr.span;
374-
let contents = &fmtstr.symbol.as_str();
374+
let contents = fmtstr.symbol.as_str();
375375

376-
if *contents == r"\n" {
376+
if contents == r"\n" {
377377
return (sp, true);
378378
}
379379

@@ -484,7 +484,7 @@ impl Write {
484484
StrStyle::Raw(n) => Some(n as usize),
485485
};
486486

487-
let mut parser = Parser::new(&str_sym, style, snippet_opt(cx, str_lit.span), false, ParseMode::Format);
487+
let mut parser = Parser::new(str_sym, style, snippet_opt(cx, str_lit.span), false, ParseMode::Format);
488488
let mut args = SimpleFormatArgs::default();
489489

490490
while let Some(arg) = parser.next() {
@@ -589,7 +589,7 @@ impl Write {
589589
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
590590
},
591591
LitKind::StrRaw(_) | LitKind::Str | LitKind::ByteStrRaw(_) | LitKind::ByteStr => continue,
592-
LitKind::Byte | LitKind::Char => match &*lit.token.symbol.as_str() {
592+
LitKind::Byte | LitKind::Char => match lit.token.symbol.as_str() {
593593
"\"" if matches!(fmtstr.style, StrStyle::Cooked) => "\\\"",
594594
"\"" if matches!(fmtstr.style, StrStyle::Raw(0)) => continue,
595595
"\\\\" if matches!(fmtstr.style, StrStyle::Raw(_)) => "\\",
@@ -671,7 +671,7 @@ fn check_newlines(fmtstr: &StrLit) -> bool {
671671
let mut last_was_cr = false;
672672
let mut should_lint = false;
673673

674-
let contents = &fmtstr.symbol.as_str();
674+
let contents = fmtstr.symbol.as_str();
675675

676676
let mut cb = |r: Range<usize>, c: Result<char, EscapeError>| {
677677
let c = c.unwrap();

clippy_utils/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn get_attr<'a>(
113113
fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'static str, mut f: F) {
114114
for attr in get_attr(sess, attrs, name) {
115115
if let Some(ref value) = attr.value_str() {
116-
if let Ok(value) = FromStr::from_str(&value.as_str()) {
116+
if let Ok(value) = FromStr::from_str(value.as_str()) {
117117
f(value);
118118
} else {
119119
sess.span_err(attr.span, "not a number");

clippy_utils/src/eager_or_lazy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl ops::BitOrAssign for EagernessSuggestion {
4747
/// Determine the eagerness of the given function call.
4848
fn fn_eagerness(cx: &LateContext<'tcx>, fn_id: DefId, name: Symbol, args: &'tcx [Expr<'_>]) -> EagernessSuggestion {
4949
use EagernessSuggestion::{Eager, Lazy, NoChange};
50-
let name = &*name.as_str();
50+
let name = name.as_str();
5151

5252
let ty = match cx.tcx.impl_of_method(fn_id) {
5353
Some(id) => cx.tcx.type_of(id),

clippy_utils/src/qualify_min_const_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: Option<&RustcVersion>) -> b
372372
// as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262.
373373
crate::meets_msrv(
374374
msrv,
375-
&RustcVersion::parse(&since.as_str())
375+
&RustcVersion::parse(since.as_str())
376376
.expect("`rustc_attr::StabilityLevel::Stable::since` is ill-formatted"),
377377
)
378378
} else {

0 commit comments

Comments
 (0)