Skip to content

Commit 621fdcc

Browse files
committed
Dogfood new trivially_copy_pass_by_ref lint
1 parent 700ece5 commit 621fdcc

15 files changed

+91
-91
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
7171

7272
fn check_lit(cx: &LateContext, lit: &Lit, e: &Expr) {
7373
match lit.node {
74-
LitKind::Float(ref s, FloatTy::F32) => check_known_consts(cx, e, s, "f32"),
75-
LitKind::Float(ref s, FloatTy::F64) => check_known_consts(cx, e, s, "f64"),
76-
LitKind::FloatUnsuffixed(ref s) => check_known_consts(cx, e, s, "f{32, 64}"),
74+
LitKind::Float(s, FloatTy::F32) => check_known_consts(cx, e, s, "f32"),
75+
LitKind::Float(s, FloatTy::F64) => check_known_consts(cx, e, s, "f64"),
76+
LitKind::FloatUnsuffixed(s) => check_known_consts(cx, e, s, "f{32, 64}"),
7777
_ => (),
7878
}
7979
}
8080

81-
fn check_known_consts(cx: &LateContext, e: &Expr, s: &symbol::Symbol, module: &str) {
81+
fn check_known_consts(cx: &LateContext, e: &Expr, s: symbol::Symbol, module: &str) {
8282
let s = s.as_str();
8383
if s.parse::<f64>().is_ok() {
8484
for &(constant, name, min_digits) in KNOWN_CONSTS {

clippy_lints/src/attrs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
151151

152152
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
153153
if is_relevant_item(cx.tcx, item) {
154-
check_attrs(cx, item.span, &item.name, &item.attrs)
154+
check_attrs(cx, item.span, item.name, &item.attrs)
155155
}
156156
match item.node {
157157
ItemExternCrate(_) | ItemUse(_, _) => {
@@ -195,13 +195,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
195195

196196
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
197197
if is_relevant_impl(cx.tcx, item) {
198-
check_attrs(cx, item.span, &item.name, &item.attrs)
198+
check_attrs(cx, item.span, item.name, &item.attrs)
199199
}
200200
}
201201

202202
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
203203
if is_relevant_trait(cx.tcx, item) {
204-
check_attrs(cx, item.span, &item.name, &item.attrs)
204+
check_attrs(cx, item.span, item.name, &item.attrs)
205205
}
206206
}
207207
}
@@ -260,7 +260,7 @@ fn is_relevant_expr(tcx: TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool
260260
}
261261
}
262262

263-
fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
263+
fn check_attrs(cx: &LateContext, span: Span, name: Name, attrs: &[Attribute]) {
264264
if in_macro(span) {
265265
return;
266266
}

clippy_lints/src/bit_mask.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
112112
if let ExprBinary(ref cmp, ref left, ref right) = e.node {
113113
if cmp.node.is_comparison() {
114114
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
115-
check_compare(cx, left, cmp.node, cmp_opt, &e.span)
115+
check_compare(cx, left, cmp.node, cmp_opt, e.span)
116116
} else if let Some(cmp_val) = fetch_int_literal(cx, left) {
117-
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, &e.span)
117+
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span)
118118
}
119119
}
120120
}
@@ -156,7 +156,7 @@ fn invert_cmp(cmp: BinOp_) -> BinOp_ {
156156
}
157157

158158

159-
fn check_compare(cx: &LateContext, bit_op: &Expr, cmp_op: BinOp_, cmp_value: u128, span: &Span) {
159+
fn check_compare(cx: &LateContext, bit_op: &Expr, cmp_op: BinOp_, cmp_value: u128, span: Span) {
160160
if let ExprBinary(ref op, ref left, ref right) = bit_op.node {
161161
if op.node != BiBitAnd && op.node != BiBitOr {
162162
return;
@@ -167,15 +167,15 @@ fn check_compare(cx: &LateContext, bit_op: &Expr, cmp_op: BinOp_, cmp_value: u12
167167
}
168168
}
169169

170-
fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value: u128, cmp_value: u128, span: &Span) {
170+
fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value: u128, cmp_value: u128, span: Span) {
171171
match cmp_op {
172172
BiEq | BiNe => match bit_op {
173173
BiBitAnd => if mask_value & cmp_value != cmp_value {
174174
if cmp_value != 0 {
175175
span_lint(
176176
cx,
177177
BAD_BIT_MASK,
178-
*span,
178+
span,
179179
&format!(
180180
"incompatible bit mask: `_ & {}` can never be equal to `{}`",
181181
mask_value,
@@ -184,13 +184,13 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
184184
);
185185
}
186186
} else if mask_value == 0 {
187-
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
187+
span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero");
188188
},
189189
BiBitOr => if mask_value | cmp_value != cmp_value {
190190
span_lint(
191191
cx,
192192
BAD_BIT_MASK,
193-
*span,
193+
span,
194194
&format!(
195195
"incompatible bit mask: `_ | {}` can never be equal to `{}`",
196196
mask_value,
@@ -205,63 +205,63 @@ fn check_bit_mask(cx: &LateContext, bit_op: BinOp_, cmp_op: BinOp_, mask_value:
205205
span_lint(
206206
cx,
207207
BAD_BIT_MASK,
208-
*span,
208+
span,
209209
&format!(
210210
"incompatible bit mask: `_ & {}` will always be lower than `{}`",
211211
mask_value,
212212
cmp_value
213213
),
214214
);
215215
} else if mask_value == 0 {
216-
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
216+
span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero");
217217
},
218218
BiBitOr => if mask_value >= cmp_value {
219219
span_lint(
220220
cx,
221221
BAD_BIT_MASK,
222-
*span,
222+
span,
223223
&format!(
224224
"incompatible bit mask: `_ | {}` will never be lower than `{}`",
225225
mask_value,
226226
cmp_value
227227
),
228228
);
229229
} else {
230-
check_ineffective_lt(cx, *span, mask_value, cmp_value, "|");
230+
check_ineffective_lt(cx, span, mask_value, cmp_value, "|");
231231
},
232-
BiBitXor => check_ineffective_lt(cx, *span, mask_value, cmp_value, "^"),
232+
BiBitXor => check_ineffective_lt(cx, span, mask_value, cmp_value, "^"),
233233
_ => (),
234234
},
235235
BiLe | BiGt => match bit_op {
236236
BiBitAnd => if mask_value <= cmp_value {
237237
span_lint(
238238
cx,
239239
BAD_BIT_MASK,
240-
*span,
240+
span,
241241
&format!(
242242
"incompatible bit mask: `_ & {}` will never be higher than `{}`",
243243
mask_value,
244244
cmp_value
245245
),
246246
);
247247
} else if mask_value == 0 {
248-
span_lint(cx, BAD_BIT_MASK, *span, "&-masking with zero");
248+
span_lint(cx, BAD_BIT_MASK, span, "&-masking with zero");
249249
},
250250
BiBitOr => if mask_value > cmp_value {
251251
span_lint(
252252
cx,
253253
BAD_BIT_MASK,
254-
*span,
254+
span,
255255
&format!(
256256
"incompatible bit mask: `_ | {}` will always be higher than `{}`",
257257
mask_value,
258258
cmp_value
259259
),
260260
);
261261
} else {
262-
check_ineffective_gt(cx, *span, mask_value, cmp_value, "|");
262+
check_ineffective_gt(cx, span, mask_value, cmp_value, "|");
263263
},
264-
BiBitXor => check_ineffective_gt(cx, *span, mask_value, cmp_value, "^"),
264+
BiBitXor => check_ineffective_gt(cx, span, mask_value, cmp_value, "^"),
265265
_ => (),
266266
},
267267
_ => (),

clippy_lints/src/eq_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl LintPass for EqOp {
5252

5353
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
5454
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
55-
if let ExprBinary(ref op, ref left, ref right) = e.node {
55+
if let ExprBinary(op, ref left, ref right) = e.node {
5656
if in_macro(e.span) {
5757
return;
5858
}
@@ -157,7 +157,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
157157
}
158158

159159

160-
fn is_valid_operator(op: &BinOp) -> bool {
160+
fn is_valid_operator(op: BinOp) -> bool {
161161
match op.node {
162162
BiSub | BiDiv | BiEq | BiLt | BiLe | BiGt | BiGe | BiNe | BiAnd | BiOr | BiBitXor | BiBitAnd | BiBitOr => true,
163163
_ => false,

clippy_lints/src/excessive_precision.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
4646
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
4747
if_chain! {
4848
let ty = cx.tables.expr_ty(expr);
49-
if let TypeVariants::TyFloat(ref fty) = ty.sty;
49+
if let TypeVariants::TyFloat(fty) = ty.sty;
5050
if let hir::ExprLit(ref lit) = expr.node;
51-
if let LitKind::Float(ref sym, _) | LitKind::FloatUnsuffixed(ref sym) = lit.node;
51+
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
5252
if let Some(sugg) = self.check(sym, fty);
5353
then {
5454
span_lint_and_sugg(
@@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
6666

6767
impl ExcessivePrecision {
6868
// None if nothing to lint, Some(suggestion) if lint neccessary
69-
fn check(&self, sym: &Symbol, fty: &FloatTy) -> Option<String> {
69+
fn check(&self, sym: Symbol, fty: FloatTy) -> Option<String> {
7070
let max = max_digits(fty);
7171
let sym_str = sym.as_str();
7272
if dot_zero_exclusion(&sym_str) {
@@ -79,7 +79,7 @@ impl ExcessivePrecision {
7979
let digits = count_digits(&sym_str);
8080
if digits > max as usize {
8181
let formatter = FloatFormat::new(&sym_str);
82-
let sr = match *fty {
82+
let sr = match fty {
8383
FloatTy::F32 => sym_str.parse::<f32>().map(|f| formatter.format(f)),
8484
FloatTy::F64 => sym_str.parse::<f64>().map(|f| formatter.format(f)),
8585
};
@@ -115,7 +115,7 @@ fn dot_zero_exclusion(s: &str) -> bool {
115115
}
116116
}
117117

118-
fn max_digits(fty: &FloatTy) -> u32 {
118+
fn max_digits(fty: FloatTy) -> u32 {
119119
match fty {
120120
FloatTy::F32 => f32::DIGITS,
121121
FloatTy::F64 => f64::DIGITS,

clippy_lints/src/functions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
126126
}
127127

128128
impl<'a, 'tcx> Functions {
129-
fn check_arg_number(&self, cx: &LateContext, decl: &hir::FnDecl, span: Span) {
129+
fn check_arg_number(self, cx: &LateContext, decl: &hir::FnDecl, span: Span) {
130130
let args = decl.inputs.len() as u64;
131131
if args > self.threshold {
132132
span_lint(
@@ -139,7 +139,7 @@ impl<'a, 'tcx> Functions {
139139
}
140140

141141
fn check_raw_ptr(
142-
&self,
142+
self,
143143
cx: &LateContext<'a, 'tcx>,
144144
unsafety: hir::Unsafety,
145145
decl: &'tcx hir::FnDecl,

clippy_lints/src/inline_fn_without_body.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ impl LintPass for Pass {
3838
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
3939
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
4040
if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.node {
41-
check_attrs(cx, &item.name, &item.attrs);
41+
check_attrs(cx, item.name, &item.attrs);
4242
}
4343
}
4444
}
4545

46-
fn check_attrs(cx: &LateContext, name: &Name, attrs: &[Attribute]) {
46+
fn check_attrs(cx: &LateContext, name: Name, attrs: &[Attribute]) {
4747
for attr in attrs {
4848
if attr.name() != "inline" {
4949
continue;

clippy_lints/src/literal_representation.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,36 +227,36 @@ enum WarningType {
227227
}
228228

229229
impl WarningType {
230-
pub fn display(&self, grouping_hint: &str, cx: &EarlyContext, span: &syntax_pos::Span) {
231-
match *self {
230+
pub fn display(&self, grouping_hint: &str, cx: &EarlyContext, span: syntax_pos::Span) {
231+
match self {
232232
WarningType::UnreadableLiteral => span_lint_and_sugg(
233233
cx,
234234
UNREADABLE_LITERAL,
235-
*span,
235+
span,
236236
"long literal lacking separators",
237237
"consider",
238238
grouping_hint.to_owned(),
239239
),
240240
WarningType::LargeDigitGroups => span_lint_and_sugg(
241241
cx,
242242
LARGE_DIGIT_GROUPS,
243-
*span,
243+
span,
244244
"digit groups should be smaller",
245245
"consider",
246246
grouping_hint.to_owned(),
247247
),
248248
WarningType::InconsistentDigitGrouping => span_lint_and_sugg(
249249
cx,
250250
INCONSISTENT_DIGIT_GROUPING,
251-
*span,
251+
span,
252252
"digits grouped inconsistently by underscores",
253253
"consider",
254254
grouping_hint.to_owned(),
255255
),
256256
WarningType::DecimalRepresentation => span_lint_and_sugg(
257257
cx,
258258
DECIMAL_LITERAL_REPRESENTATION,
259-
*span,
259+
span,
260260
"integer literal has a better hexadecimal representation",
261261
"consider",
262262
grouping_hint.to_owned(),
@@ -291,7 +291,7 @@ impl EarlyLintPass for LiteralDigitGrouping {
291291
}
292292

293293
impl LiteralDigitGrouping {
294-
fn check_lit(&self, cx: &EarlyContext, lit: &Lit) {
294+
fn check_lit(self, cx: &EarlyContext, lit: &Lit) {
295295
match lit.node {
296296
LitKind::Int(..) => {
297297
// Lint integral literals.
@@ -302,7 +302,7 @@ impl LiteralDigitGrouping {
302302
then {
303303
let digit_info = DigitInfo::new(&src, false);
304304
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
305-
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
305+
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
306306
});
307307
}
308308
}
@@ -337,15 +337,15 @@ impl LiteralDigitGrouping {
337337
if !consistent {
338338
WarningType::InconsistentDigitGrouping.display(&digit_info.grouping_hint(),
339339
cx,
340-
&lit.span);
340+
lit.span);
341341
}
342342
})
343343
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(),
344344
cx,
345-
&lit.span));
345+
lit.span));
346346
}
347347
})
348-
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(), cx, &lit.span));
348+
.map_err(|warning_type| warning_type.display(&digit_info.grouping_hint(), cx, lit.span));
349349
}
350350
}
351351
},
@@ -436,7 +436,7 @@ impl LiteralRepresentation {
436436
threshold,
437437
}
438438
}
439-
fn check_lit(&self, cx: &EarlyContext, lit: &Lit) {
439+
fn check_lit(self, cx: &EarlyContext, lit: &Lit) {
440440
// Lint integral literals.
441441
if_chain! {
442442
if let LitKind::Int(..) = lit.node;
@@ -457,7 +457,7 @@ impl LiteralRepresentation {
457457
let hex = format!("{:#X}", val);
458458
let digit_info = DigitInfo::new(&hex[..], false);
459459
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
460-
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
460+
warning_type.display(&digit_info.grouping_hint(), cx, lit.span)
461461
});
462462
}
463463
}

0 commit comments

Comments
 (0)