Skip to content

Commit d716129

Browse files
committed
Fix ugly fallout
1 parent abaf961 commit d716129

16 files changed

+34
-34
lines changed

clippy_lints/src/blacklisted_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl LintPass for BlackListedName {
4040
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
4141
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
4242
if let PatKind::Binding(_, _, ref ident, _) = pat.node {
43-
if self.blacklist.iter().any(|s| s == &*ident.node.as_str()) {
43+
if self.blacklist.iter().any(|s| *s == *ident.node.as_str()) {
4444
span_lint(cx,
4545
BLACKLISTED_NAME,
4646
pat.span,

clippy_lints/src/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn check_cond<'a, 'tcx, 'b>(
8585
if_let_chain! {[
8686
let ExprMethodCall(ref name, _, ref params) = check.node,
8787
params.len() >= 2,
88-
&*name.node.as_str() == "contains_key",
88+
*name.node.as_str() == *"contains_key",
8989
let ExprAddrOf(_, ref key) = params[1].node
9090
], {
9191
let map = &params[0];
@@ -119,7 +119,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
119119
if_let_chain! {[
120120
let ExprMethodCall(ref name, _, ref params) = expr.node,
121121
params.len() == 3,
122-
&*name.node.as_str() == "insert",
122+
*name.node.as_str() == *"insert",
123123
get_item_name(self.cx, self.map) == get_item_name(self.cx, &params[0]),
124124
SpanlessEq::new(self.cx).eq_expr(self.key, &params[1])
125125
], {

clippy_lints/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Exp
7979
let StmtDecl(ref decl, _) = block.stmts[0].node,
8080
let DeclItem(ref decl) = decl.node,
8181
let Some(NodeItem(decl)) = cx.tcx.hir.find(decl.id),
82-
&*decl.name.as_str() == "__STATIC_FMTSTR",
82+
*decl.name.as_str() == *"__STATIC_FMTSTR",
8383
let ItemStatic(_, _, ref expr) = decl.node,
8484
let ExprAddrOf(_, ref expr) = cx.tcx.hir.body(*expr).value.node, // &["…", "…", …]
8585
let ExprArray(ref exprs) = expr.node,

clippy_lints/src/len_zero.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
8989

9090
fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]) {
9191
fn is_named_self(cx: &LateContext, item: &TraitItemRef, name: &str) -> bool {
92-
&*item.name.as_str() == name &&
92+
*item.name.as_str() == *name &&
9393
if let AssociatedItemKind::Method { has_self } = item.kind {
9494
has_self &&
9595
{
@@ -116,7 +116,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
116116

117117
fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
118118
fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
119-
&*item.name.as_str() == name &&
119+
*item.name.as_str() == *name &&
120120
if let AssociatedItemKind::Method { has_self } = item.kind {
121121
has_self &&
122122
{
@@ -155,7 +155,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
155155
fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) {
156156
// check if we are in an is_empty() method
157157
if let Some(name) = get_item_name(cx, left) {
158-
if &*name.as_str() == "is_empty" {
158+
if *name.as_str() == *"is_empty" {
159159
return;
160160
}
161161
}
@@ -170,7 +170,7 @@ fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str)
170170

171171
fn check_len_zero(cx: &LateContext, span: Span, name: &Name, args: &[Expr], lit: &Lit, op: &str) {
172172
if let Spanned { node: LitKind::Int(0, _), .. } = *lit {
173-
if &*name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
173+
if *name.as_str() == *"len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
174174
span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| {
175175
db.span_suggestion(span,
176176
"consider using `is_empty`",
@@ -185,7 +185,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
185185
/// Get an `AssociatedItem` and return true if it matches `is_empty(self)`.
186186
fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
187187
if let ty::AssociatedKind::Method = item.kind {
188-
if &*item.name.as_str() == "is_empty" {
188+
if *item.name.as_str() == *"is_empty" {
189189
let sig = cx.tcx.item_type(item.def_id).fn_sig();
190190
let ty = sig.skip_binder();
191191
ty.inputs().len() == 1

clippy_lints/src/lifetimes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {
199199

200200
fn lts_from_bounds<'a, T: Iterator<Item = &'a Lifetime>>(mut vec: Vec<RefLt>, bounds_lts: T) -> Vec<RefLt> {
201201
for lt in bounds_lts {
202-
if &*lt.name.as_str() != "'static" {
202+
if *lt.name.as_str() != *"'static" {
203203
vec.push(RefLt::Named(lt.name));
204204
}
205205
}
@@ -228,7 +228,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
228228

229229
fn record(&mut self, lifetime: &Option<Lifetime>) {
230230
if let Some(ref lt) = *lifetime {
231-
if &*lt.name.as_str() == "'static" {
231+
if *lt.name.as_str() == *"'static" {
232232
self.lts.push(RefLt::Static);
233233
} else if lt.is_elided() {
234234
self.lts.push(RefLt::Unnamed);

clippy_lints/src/loops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
389389
&ExprMethodCall(method_name, _, ref method_args)) = (pat, &match_expr.node) {
390390
let iter_expr = &method_args[0];
391391
let lhs_constructor = last_path_segment(qpath);
392-
if &*method_name.node.as_str() == "next" && match_trait_method(cx, match_expr, &paths::ITERATOR) &&
393-
&*lhs_constructor.name.as_str() == "Some" && !is_refutable(cx, &pat_args[0]) &&
392+
if *method_name.node.as_str() == *"next" && match_trait_method(cx, match_expr, &paths::ITERATOR) &&
393+
*lhs_constructor.name.as_str() == *"Some" && !is_refutable(cx, &pat_args[0]) &&
394394
!is_iterator_used_after_while_let(cx, iter_expr) {
395395
let iterator = snippet(cx, method_args[0].span, "_");
396396
let loop_var = snippet(cx, pat_args[0].span, "_");
@@ -409,7 +409,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
409409
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
410410
if let StmtSemi(ref expr, _) = stmt.node {
411411
if let ExprMethodCall(ref method, _, ref args) = expr.node {
412-
if args.len() == 1 && &*method.node.as_str() == "collect" &&
412+
if args.len() == 1 && *method.node.as_str() == *"collect" &&
413413
match_trait_method(cx, expr, &paths::ITERATOR) {
414414
span_lint(cx,
415415
UNUSED_COLLECT,
@@ -579,10 +579,10 @@ fn is_len_call(expr: &Expr, var: &Name) -> bool {
579579
if_let_chain! {[
580580
let ExprMethodCall(method, _, ref len_args) = expr.node,
581581
len_args.len() == 1,
582-
&*method.node.as_str() == "len",
582+
*method.node.as_str() == *"len",
583583
let ExprPath(QPath::Resolved(_, ref path)) = len_args[0].node,
584584
path.segments.len() == 1,
585-
&path.segments[0].name == var
585+
path.segments[0].name == *var
586586
], {
587587
return true;
588588
}}

clippy_lints/src/map_clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
2828
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
2929
// call to .map()
3030
if let ExprMethodCall(name, _, ref args) = expr.node {
31-
if &*name.node.as_str() == "map" && args.len() == 2 {
31+
if *name.node.as_str() == *"map" && args.len() == 2 {
3232
match args[1].node {
3333
ExprClosure(_, ref decl, closure_eid, _) => {
3434
let body = cx.tcx.hir.body(closure_eid);
@@ -53,7 +53,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
5353
}
5454
// explicit clone() calls ( .map(|x| x.clone()) )
5555
else if let ExprMethodCall(clone_call, _, ref clone_args) = closure_expr.node {
56-
if &*clone_call.node.as_str() == "clone" &&
56+
if *clone_call.node.as_str() == *"clone" &&
5757
clone_args.len() == 1 &&
5858
match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) &&
5959
expr_eq_name(&clone_args[0], arg_ident)

clippy_lints/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ fn check_single_match_opt_like(
257257
};
258258

259259
for &(ty_path, pat_path) in candidates {
260-
if &path == pat_path && match_type(cx, ty, ty_path) {
260+
if path == *pat_path && match_type(cx, ty, ty_path) {
261261
report_single_match_single_pattern(cx, ex, arms, expr, els);
262262
}
263263
}

clippy_lints/src/methods.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
607607
lint_or_fun_call(cx, expr, &name.node.as_str(), args);
608608

609609
let self_ty = cx.tables.expr_ty_adjusted(&args[0]);
610-
if args.len() == 1 && &*name.node.as_str() == "clone" {
610+
if args.len() == 1 && *name.node.as_str() == *"clone" {
611611
lint_clone_on_copy(cx, expr, &args[0], self_ty);
612612
}
613613

614614
match self_ty.sty {
615615
ty::TyRef(_, ty) if ty.ty.sty == ty::TyStr => {
616616
for &(method, pos) in &PATTERN_METHODS {
617-
if &*name.node.as_str() == method && args.len() > pos {
617+
if *name.node.as_str() == *method && args.len() > pos {
618618
lint_single_char_pattern(cx, expr, &args[pos]);
619619
}
620620
}
@@ -646,7 +646,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
646646
], {
647647
// check missing trait implementations
648648
for &(method_name, n_args, self_kind, out_type, trait_name) in &TRAIT_METHODS {
649-
if &*name.as_str() == method_name &&
649+
if *name.as_str() == *method_name &&
650650
sig.decl.inputs.len() == n_args &&
651651
out_type.matches(&sig.decl.output) &&
652652
self_kind.matches(&first_arg_ty, &first_arg, &self_ty, false) {
@@ -683,7 +683,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
683683
}
684684

685685
let ret_ty = return_ty(cx, implitem.id);
686-
if &*name.as_str() == "new" &&
686+
if *name.as_str() == *"new" &&
687687
!ret_ty.walk().any(|t| same_tys(cx, t, ty, implitem.id)) {
688688
span_lint(cx,
689689
NEW_RET_NO_SELF,
@@ -991,7 +991,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: ty::Ty) -> Option<sug
991991
}
992992

993993
if let hir::ExprMethodCall(name, _, ref args) = expr.node {
994-
if &*name.node.as_str() == "iter" && may_slice(cx, cx.tables.expr_ty(&args[0])) {
994+
if *name.node.as_str() == *"iter" && may_slice(cx, cx.tables.expr_ty(&args[0])) {
995995
sugg::Sugg::hir_opt(cx, &args[0]).map(|sugg| sugg.addr())
996996
} else {
997997
None
@@ -1209,7 +1209,7 @@ fn lint_chars_next(cx: &LateContext, expr: &hir::Expr, chain: &hir::Expr, other:
12091209
arg_char.len() == 1,
12101210
let hir::ExprPath(ref qpath) = fun.node,
12111211
let Some(segment) = single_segment_path(qpath),
1212-
&*segment.name.as_str() == "Some"
1212+
*segment.name.as_str() == *"Some"
12131213
], {
12141214
let self_ty = walk_ptrs_ty(cx.tables.expr_ty_adjusted(&args[0][0]));
12151215

clippy_lints/src/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
335335
let binding = last_path_segment(qpath).name.as_str();
336336
if binding.starts_with('_') &&
337337
!binding.starts_with("__") &&
338-
&*binding != "_result" && // FIXME: #944
338+
*binding != *"_result" && // FIXME: #944
339339
is_used(cx, expr) &&
340340
// don't lint if the declaration is in a macro
341341
non_macro_local(cx, &cx.tables.qpath_def(qpath, expr.id)) {
@@ -378,7 +378,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
378378

379379
fn check_nan(cx: &LateContext, path: &Path, expr: &Expr) {
380380
if !in_constant(cx, expr.id) {
381-
path.segments.last().map(|seg| if &*seg.name.as_str() == "NAN" {
381+
path.segments.last().map(|seg| if *seg.name.as_str() == *"NAN" {
382382
span_lint(cx,
383383
CMP_NAN,
384384
expr.span,

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
126126
match_type(cx, ty, &paths::VEC),
127127
let TyPath(QPath::Resolved(_, ref path)) = input.node,
128128
let Some(elem_ty) = path.segments.iter()
129-
.find(|seg| &*seg.name.as_str() == "Vec")
129+
.find(|seg| *seg.name.as_str() == *"Vec")
130130
.map(|ps| ps.parameters.types()[0]),
131131
], {
132132
let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_"));

clippy_lints/src/new_without_default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
108108
// can't be implemented by default
109109
return;
110110
}
111-
if decl.inputs.is_empty() && &*name.as_str() == "new" && cx.access_levels.is_reachable(id) {
111+
if decl.inputs.is_empty() && *name.as_str() == *"new" && cx.access_levels.is_reachable(id) {
112112
let self_ty = cx.tcx
113113
.item_type(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));
114114
if_let_chain!{[

clippy_lints/src/open_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSensical {
3636
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
3737
if let ExprMethodCall(ref name, _, ref arguments) = e.node {
3838
let (obj_ty, _) = walk_ptrs_ty_depth(cx.tables.expr_ty(&arguments[0]));
39-
if &*name.node.as_str() == "open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
39+
if *name.node.as_str() == *"open" && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
4040
let mut options = Vec::new();
4141
get_open_options(cx, &arguments[0], &mut options);
4242
check_open_options(cx, &options, e.span);

clippy_lints/src/partialeq_ne_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
4343
trait_ref.path.def.def_id() == cx.tcx.lang_items.eq_trait().unwrap(),
4444
], {
4545
for impl_item in impl_items {
46-
if &*impl_item.name.as_str() == "ne" {
46+
if *impl_item.name.as_str() == *"ne" {
4747
span_lint(cx,
4848
PARTIALEQ_NE_IMPL,
4949
impl_item.span,

clippy_lints/src/ranges.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StepByZero {
6464
if_let_chain! {[
6565
// .iter() call
6666
let ExprMethodCall( Spanned { node: ref iter_name, .. }, _, ref iter_args ) = *iter,
67-
&*iter_name.as_str() == "iter",
67+
*iter_name.as_str() == *"iter",
6868
// range expression in .zip() call: 0..x.len()
6969
let Some(higher::Range { start: Some(ref start), end: Some(ref end), .. }) = higher::range(zip_arg),
7070
is_integer_literal(start, 0),
7171
// .len() call
7272
let ExprMethodCall(Spanned { node: ref len_name, .. }, _, ref len_args) = end.node,
73-
&*len_name.as_str() == "len" && len_args.len() == 1,
73+
*len_name.as_str() == *"len" && len_args.len() == 1,
7474
// .iter() and .len() called on same Path
7575
let ExprPath(QPath::Resolved(_, ref iter_path)) = iter_args[0].node,
7676
let ExprPath(QPath::Resolved(_, ref len_path)) = len_args[0].node,

clippy_lints/src/strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
143143
use utils::{snippet, in_macro};
144144

145145
if let ExprMethodCall(ref name, _, ref args) = e.node {
146-
if &*name.node.as_str() == "as_bytes" {
146+
if *name.node.as_str() == *"as_bytes" {
147147
if let ExprLit(ref lit) = args[0].node {
148148
if let LitKind::Str(ref lit_content, _) = lit.node {
149149
if lit_content.as_str().chars().all(|c| c.is_ascii()) && !in_macro(cx, args[0].span) {

0 commit comments

Comments
 (0)