Skip to content

Commit dedc380

Browse files
committed
Apply fixes from lint
1 parent 6b1779b commit dedc380

27 files changed

+50
-50
lines changed

clippy_lints/src/casts/cast_ptr_alignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
2020
);
2121
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
2222
} else if let ExprKind::MethodCall(method_path, self_arg, [], _) = &expr.kind {
23-
if method_path.ident.name == sym!(cast)
23+
if method_path.ident.name.as_str() == "cast"
2424
&& let Some(generic_args) = method_path.args
2525
&& let [GenericArg::Type(cast_to)] = generic_args.args
2626
// There probably is no obvious reason to do this, just to be consistent with `as` cases.

clippy_lints/src/explicit_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
5858
// match call to write_fmt
5959
&& let ExprKind::MethodCall(write_fun, write_recv, [write_arg], _) = *look_in_block(cx, &write_call.kind)
6060
&& let ExprKind::Call(write_recv_path, []) = write_recv.kind
61-
&& write_fun.ident.name == sym!(write_fmt)
61+
&& write_fun.ident.name.as_str() == "write_fmt"
6262
&& let Some(def_id) = path_def_id(cx, write_recv_path)
6363
{
6464
// match calls to std::io::stdout() / std::io::stderr ()

clippy_lints/src/from_raw_with_void_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl LateLintPass<'_> for FromRawWithVoidPtr {
4141
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
4242
if let ExprKind::Call(box_from_raw, [arg]) = expr.kind
4343
&& let ExprKind::Path(QPath::TypeRelative(ty, seg)) = box_from_raw.kind
44-
&& seg.ident.name == sym!(from_raw)
44+
&& seg.ident.name.as_str() == "from_raw"
4545
&& let Some(type_str) = path_def_id(cx, ty).and_then(|id| def_id_matches_type(cx, id))
4646
&& let arg_kind = cx.typeck_results().expr_ty(arg).kind()
4747
&& let ty::RawPtr(ty, _) = arg_kind

clippy_lints/src/implicit_hasher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'_, '_, 'tcx> {
340340
if self.cx.tcx.is_diagnostic_item(sym::HashMap, ty_did) {
341341
if method.ident.name == sym::new {
342342
self.suggestions.insert(e.span, "HashMap::default()".to_string());
343-
} else if method.ident.name == sym!(with_capacity) {
343+
} else if method.ident.name.as_str() == "with_capacity" {
344344
self.suggestions.insert(
345345
e.span,
346346
format!(
@@ -352,7 +352,7 @@ impl<'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'_, '_, 'tcx> {
352352
} else if self.cx.tcx.is_diagnostic_item(sym::HashSet, ty_did) {
353353
if method.ident.name == sym::new {
354354
self.suggestions.insert(e.span, "HashSet::default()".to_string());
355-
} else if method.ident.name == sym!(with_capacity) {
355+
} else if method.ident.name.as_str() == "with_capacity" {
356356
self.suggestions.insert(
357357
e.span,
358358
format!(

clippy_lints/src/infinite_iter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
157157
.and(cap);
158158
}
159159
}
160-
if method.ident.name == sym!(flat_map) && args.len() == 1 {
160+
if method.ident.name.as_str() == "flat_map" && args.len() == 1 {
161161
if let ExprKind::Closure(&Closure { body, .. }) = args[0].kind {
162162
let body = cx.tcx.hir().body(body);
163163
return is_infinite(cx, body.value);
@@ -224,7 +224,7 @@ fn complete_infinite_iter(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
224224
return MaybeInfinite.and(is_infinite(cx, receiver));
225225
}
226226
}
227-
if method.ident.name == sym!(last) && args.is_empty() {
227+
if method.ident.name.as_str() == "last" && args.is_empty() {
228228
let not_double_ended = cx
229229
.tcx
230230
.get_diagnostic_item(sym::DoubleEndedIterator)
@@ -234,7 +234,7 @@ fn complete_infinite_iter(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
234234
if not_double_ended {
235235
return is_infinite(cx, receiver);
236236
}
237-
} else if method.ident.name == sym!(collect) {
237+
} else if method.ident.name.as_str() == "collect" {
238238
let ty = cx.typeck_results().expr_ty(expr);
239239
if matches!(
240240
get_type_diagnostic_name(cx, ty),

clippy_lints/src/iter_without_into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl LateLintPass<'_> for IterWithoutIntoIter {
142142
ty.peel_refs().is_slice() || get_adt_inherent_method(cx, ty, expected_method_name).is_some()
143143
})
144144
&& let Some(iter_assoc_span) = imp.items.iter().find_map(|item| {
145-
if item.ident.name == sym!(IntoIter) {
145+
if item.ident.name.as_str() == "IntoIter" {
146146
Some(cx.tcx.hir().impl_item(item.id).expect_type().span)
147147
} else {
148148
None

clippy_lints/src/manual_hash_one.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl LateLintPass<'_> for ManualHashOne {
6868
&& let Some(init) = local.init
6969
&& !init.span.from_expansion()
7070
&& let ExprKind::MethodCall(seg, build_hasher, [], _) = init.kind
71-
&& seg.ident.name == sym!(build_hasher)
71+
&& seg.ident.name.as_str() == "build_hasher"
7272

7373
&& let Node::Stmt(local_stmt) = cx.tcx.parent_hir_node(local.hir_id)
7474
&& let Node::Block(block) = cx.tcx.parent_hir_node(local_stmt.hir_id)
@@ -96,7 +96,7 @@ impl LateLintPass<'_> for ManualHashOne {
9696
&& let Node::Expr(finish_expr) = cx.tcx.parent_hir_node(path_expr.hir_id)
9797
&& !finish_expr.span.from_expansion()
9898
&& let ExprKind::MethodCall(seg, _, [], _) = finish_expr.kind
99-
&& seg.ident.name == sym!(finish)
99+
&& seg.ident.name.as_str() == "finish"
100100

101101
&& self.msrv.meets(msrvs::BUILD_HASHER_HASH_ONE)
102102
{

clippy_lints/src/manual_is_ascii_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualIsAsciiCheck {
105105
check_is_ascii(cx, macro_call.span, recv, &range, None);
106106
}
107107
} else if let ExprKind::MethodCall(path, receiver, [arg], ..) = expr.kind
108-
&& path.ident.name == sym!(contains)
108+
&& path.ident.name.as_str() == "contains"
109109
&& let Some(higher::Range {
110110
start: Some(start),
111111
end: Some(end),

clippy_lints/src/matches/redundant_guards.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::{Arm, BinOpKind, Expr, ExprKind, MatchSource, Node, PatKind, UnOp};
1111
use rustc_lint::LateContext;
1212
use rustc_span::symbol::Ident;
13-
use rustc_span::{Span, Symbol, sym};
13+
use rustc_span::{Span, sym};
1414
use std::borrow::Cow;
1515
use std::ops::ControlFlow;
1616

@@ -95,15 +95,15 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'tcx>], msrv:
9595
} else if let ExprKind::MethodCall(path, recv, args, ..) = guard.kind
9696
&& let Some(binding) = get_pat_binding(cx, recv, outer_arm)
9797
{
98-
check_method_calls(cx, outer_arm, path.ident.name, recv, args, guard, &binding);
98+
check_method_calls(cx, outer_arm, path.ident.name.as_str(), recv, args, guard, &binding);
9999
}
100100
}
101101
}
102102

103103
fn check_method_calls<'tcx>(
104104
cx: &LateContext<'tcx>,
105105
arm: &Arm<'tcx>,
106-
method: Symbol,
106+
method: &str,
107107
recv: &Expr<'_>,
108108
args: &[Expr<'_>],
109109
if_expr: &Expr<'_>,
@@ -112,7 +112,7 @@ fn check_method_calls<'tcx>(
112112
let ty = cx.typeck_results().expr_ty(recv).peel_refs();
113113
let slice_like = ty.is_slice() || ty.is_array();
114114

115-
let sugg = if method == sym!(is_empty) {
115+
let sugg = if method == "is_empty" {
116116
// `s if s.is_empty()` becomes ""
117117
// `arr if arr.is_empty()` becomes []
118118

@@ -137,9 +137,9 @@ fn check_method_calls<'tcx>(
137137

138138
if needles.is_empty() {
139139
sugg.insert_str(1, "..");
140-
} else if method == sym!(starts_with) {
140+
} else if method == "starts_with" {
141141
sugg.insert_str(sugg.len() - 1, ", ..");
142-
} else if method == sym!(ends_with) {
142+
} else if method == "ends_with" {
143143
sugg.insert_str(1, ".., ");
144144
} else {
145145
return;

clippy_lints/src/methods/filter_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ impl<'tcx> OffendingFilterExpr<'tcx> {
234234
// the latter only calls `effect` once
235235
let side_effect_expr_span = receiver.can_have_side_effects().then_some(receiver.span);
236236

237-
if cx.tcx.is_diagnostic_item(sym::Option, recv_ty.did()) && path.ident.name == sym!(is_some) {
237+
if cx.tcx.is_diagnostic_item(sym::Option, recv_ty.did()) && path.ident.name.as_str() == "is_some" {
238238
Some(Self::IsSome {
239239
receiver,
240240
side_effect_expr_span,
241241
})
242-
} else if cx.tcx.is_diagnostic_item(sym::Result, recv_ty.did()) && path.ident.name == sym!(is_ok) {
242+
} else if cx.tcx.is_diagnostic_item(sym::Result, recv_ty.did()) && path.ident.name.as_str() == "is_ok" {
243243
Some(Self::IsOk {
244244
receiver,
245245
side_effect_expr_span,

0 commit comments

Comments
 (0)