Skip to content

Commit a83c935

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

16 files changed

+20
-20
lines changed

clippy_lints/src/duration_subsec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for DurationSubsec {
4949
if match_type(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), &paths::DURATION);
5050
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.typeck_results(), right);
5151
then {
52-
let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {
52+
let suggested_fn = match (method_path.ident.as_str(), divisor) {
5353
("subsec_micros", 1_000) | ("subsec_nanos", 1_000_000) => "subsec_millis",
5454
("subsec_nanos", 1_000) => "subsec_micros",
5555
_ => return,

clippy_lints/src/floating_point_arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ fn are_same_base_logs(cx: &LateContext<'_>, expr_a: &Expr<'_>, expr_b: &Expr<'_>
599599
return method_name_a.as_str() == method_name_b.as_str() &&
600600
args_a.len() == args_b.len() &&
601601
(
602-
["ln", "log2", "log10"].contains(&&*method_name_a.as_str()) ||
602+
["ln", "log2", "log10"].contains(&method_name_a.as_str()) ||
603603
method_name_a.as_str() == "log" && args_a.len() == 2 && eq_expr_value(cx, &args_a[1], &args_b[1])
604604
);
605605
}

clippy_lints/src/loops/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) {
659659
let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used
660660

661661
if let ExprKind::MethodCall(method, _, [self_arg], _) = arg.kind {
662-
let method_name = &*method.ident.as_str();
662+
let method_name = method.ident.as_str();
663663
// check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
664664
match method_name {
665665
"iter" | "iter_mut" => explicit_iter_loop::check(cx, self_arg, arg, method_name),

clippy_lints/src/match_str_case_mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchExprVisitor<'a, 'tcx> {
9595
fn visit_expr(&mut self, ex: &'tcx Expr<'_>) {
9696
match ex.kind {
9797
ExprKind::MethodCall(segment, _, [receiver], _)
98-
if self.case_altered(&*segment.ident.as_str(), receiver) => {},
98+
if self.case_altered(segment.ident.as_str(), receiver) => {},
9999
_ => walk_expr(self, ex),
100100
}
101101
}

clippy_lints/src/matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>])
11271127
if let CommonPrefixSearcher::Path(path_prefix) = path_prefix {
11281128
let mut s = String::new();
11291129
for seg in path_prefix {
1130-
s.push_str(&seg.ident.as_str());
1130+
s.push_str(seg.ident.as_str());
11311131
s.push_str("::");
11321132
}
11331133
s

clippy_lints/src/methods/manual_saturating_arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn is_min_or_max<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) -> Option<M
8181
if args.is_empty();
8282
if let hir::ExprKind::Path(hir::QPath::TypeRelative(_, segment)) = &func.kind;
8383
then {
84-
match &*segment.ident.as_str() {
84+
match segment.ident.as_str() {
8585
"max_value" => return Some(MinMax::Max),
8686
"min_value" => return Some(MinMax::Min),
8787
_ => {}

clippy_lints/src/methods/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
19991999
from_iter_instead_of_collect::check(cx, expr, args, func);
20002000
},
20012001
hir::ExprKind::MethodCall(method_call, ref method_span, args, _) => {
2002-
or_fun_call::check(cx, expr, *method_span, &method_call.ident.as_str(), args);
2003-
expect_fun_call::check(cx, expr, *method_span, &method_call.ident.as_str(), args);
2002+
or_fun_call::check(cx, expr, *method_span, method_call.ident.as_str(), args);
2003+
expect_fun_call::check(cx, expr, *method_span, method_call.ident.as_str(), args);
20042004
clone_on_copy::check(cx, expr, method_call.ident.name, args);
20052005
clone_on_ref_ptr::check(cx, expr, method_call.ident.name, args);
20062006
inefficient_to_string::check(cx, expr, method_call.ident.name, args);

clippy_lints/src/methods/str_splitn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn parse_iter_usage(
140140
let did = cx.typeck_results().type_dependent_def_id(e.hir_id)?;
141141
let iter_id = cx.tcx.get_diagnostic_item(sym::Iterator)?;
142142

143-
match (&*name.ident.as_str(), args) {
143+
match (name.ident.as_str(), args) {
144144
("next", []) if cx.tcx.trait_of_item(did) == Some(iter_id) => {
145145
if reverse {
146146
(IterUsageKind::Second, e.span)
@@ -298,7 +298,7 @@ fn check_iter(
298298
if let Some(did) = cx.typeck_results().type_dependent_def_id(e.hir_id);
299299
if let Some(iter_id) = cx.tcx.get_diagnostic_item(sym::Iterator);
300300
then {
301-
match (&*name.ident.as_str(), args) {
301+
match (name.ident.as_str(), args) {
302302
("next", []) if cx.tcx.trait_of_item(did) == Some(iter_id) => {
303303
return true;
304304
},

clippy_lints/src/mut_reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed {
4949
let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap();
5050
let substs = cx.typeck_results().node_substs(e.hir_id);
5151
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
52-
check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method");
52+
check_arguments(cx, arguments, method_type, path.ident.as_str(), "method");
5353
},
5454
_ => (),
5555
}

clippy_lints/src/needless_option_as_deref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for OptionNeedlessDeref {
4848
if is_type_diagnostic_item(cx,outer_ty,sym::Option);
4949
if let ExprKind::MethodCall(path, _, [sub_expr], _) = expr.kind;
5050
let symbol = path.ident.as_str();
51-
if symbol=="as_deref" || symbol=="as_deref_mut";
51+
if symbol == "as_deref" || symbol == "as_deref_mut";
5252
if TyS::same_type( outer_ty, typeck.expr_ty(sub_expr) );
5353
then{
5454
span_lint_and_sugg(

clippy_lints/src/open_options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn get_open_options(cx: &LateContext<'_>, argument: &Expr<'_>, options: &mut Vec
8282
_ => Argument::Unknown,
8383
};
8484

85-
match &*path.ident.as_str() {
85+
match path.ident.as_str() {
8686
"create" => {
8787
options.push((OpenOption::Create, argument_option));
8888
},

clippy_lints/src/serde_api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'tcx> LateLintPass<'tcx> for SerdeApi {
3737
let mut seen_str = None;
3838
let mut seen_string = None;
3939
for item in items {
40-
match &*item.ident.as_str() {
40+
match item.ident.as_str() {
4141
"visit_str" => seen_str = Some(item.span),
4242
"visit_string" => seen_string = Some(item.span),
4343
_ => {},

clippy_lints/src/unused_io_amount.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
5757
check_map_error(cx, res, expr);
5858
}
5959
},
60-
hir::ExprKind::MethodCall(path, _, [ref arg_0, ..], _) => match &*path.ident.as_str() {
60+
hir::ExprKind::MethodCall(path, _, [ref arg_0, ..], _) => match path.ident.as_str() {
6161
"expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => {
6262
check_map_error(cx, arg_0, expr);
6363
},
@@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
7171
fn check_map_error(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>) {
7272
let mut call = call;
7373
while let hir::ExprKind::MethodCall(path, _, args, _) = call.kind {
74-
if matches!(&*path.ident.as_str(), "or" | "or_else" | "ok") {
74+
if matches!(path.ident.as_str(), "or" | "or_else" | "ok") {
7575
call = &args[0];
7676
} else {
7777
break;
@@ -82,7 +82,7 @@ fn check_map_error(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<
8282

8383
fn check_method_call(cx: &LateContext<'_>, call: &hir::Expr<'_>, expr: &hir::Expr<'_>) {
8484
if let hir::ExprKind::MethodCall(path, _, _, _) = call.kind {
85-
let symbol = &*path.ident.as_str();
85+
let symbol = path.ident.as_str();
8686
let read_trait = match_trait_method(cx, call, &paths::IO_READ);
8787
let write_trait = match_trait_method(cx, call, &paths::IO_WRITE);
8888

clippy_lints/src/unwrap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn collect_unwrap_info<'tcx>(
158158
if let Some(local_id) = path_to_local(&args[0]);
159159
let ty = cx.typeck_results().expr_ty(&args[0]);
160160
let name = method_name.ident.as_str();
161-
if is_relevant_option_call(cx, ty, &name) || is_relevant_result_call(cx, ty, &name);
161+
if is_relevant_option_call(cx, ty, name) || is_relevant_result_call(cx, ty, name);
162162
then {
163163
assert!(args.len() == 1);
164164
let unwrappable = match name.as_ref() {

clippy_lints/src/upper_case_acronyms.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn correct_ident(ident: &str) -> String {
7979

8080
fn check_ident(cx: &LateContext<'_>, ident: &Ident, be_aggressive: bool) {
8181
let span = ident.span;
82-
let ident = &ident.as_str();
82+
let ident = ident.as_str();
8383
let corrected = correct_ident(ident);
8484
// warn if we have pure-uppercase idents
8585
// assume that two-letter words are some kind of valid abbreviation like FP for false positive

clippy_lints/src/useless_conversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
6464
},
6565

6666
ExprKind::MethodCall(name, .., args, _) => {
67-
if is_trait_method(cx, e, sym::Into) && &*name.ident.as_str() == "into" {
67+
if is_trait_method(cx, e, sym::Into) && name.ident.as_str() == "into" {
6868
let a = cx.typeck_results().expr_ty(e);
6969
let b = cx.typeck_results().expr_ty(&args[0]);
7070
if same_type_and_consts(a, b) {

0 commit comments

Comments
 (0)