Skip to content

Commit 2430e06

Browse files
committed
Run Dogfood for use_self
1 parent 3eab44a commit 2430e06

17 files changed

+44
-39
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.154
5+
* Fix [`use_self`] triggering inside derives
6+
47
## 0.0.153
58
* Update to *rustc 1.21.0-nightly (8c303ed87 2017-08-20)*
69
* New lint: [`use_self`]

clippy_lints/src/blacklisted_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ pub struct BlackListedName {
2626
}
2727

2828
impl BlackListedName {
29-
pub fn new(blacklist: Vec<String>) -> BlackListedName {
30-
BlackListedName { blacklist: blacklist }
29+
pub fn new(blacklist: Vec<String>) -> Self {
30+
Self { blacklist: blacklist }
3131
}
3232
}
3333

clippy_lints/src/consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum FloatWidth {
2323
}
2424

2525
impl From<FloatTy> for FloatWidth {
26-
fn from(ty: FloatTy) -> FloatWidth {
26+
fn from(ty: FloatTy) -> Self {
2727
match ty {
2828
FloatTy::F32 => FloatWidth::F32,
2929
FloatTy::F64 => FloatWidth::F64,
@@ -55,7 +55,7 @@ pub enum Constant {
5555
}
5656

5757
impl PartialEq for Constant {
58-
fn eq(&self, other: &Constant) -> bool {
58+
fn eq(&self, other: &Self) -> bool {
5959
match (self, other) {
6060
(&Constant::Str(ref ls, ref l_sty), &Constant::Str(ref rs, ref r_sty)) => ls == rs && l_sty == r_sty,
6161
(&Constant::Binary(ref l), &Constant::Binary(ref r)) => l == r,
@@ -123,7 +123,7 @@ impl Hash for Constant {
123123
}
124124

125125
impl PartialOrd for Constant {
126-
fn partial_cmp(&self, other: &Constant) -> Option<Ordering> {
126+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
127127
match (self, other) {
128128
(&Constant::Str(ref ls, ref l_sty), &Constant::Str(ref rs, ref r_sty)) => {
129129
if l_sty == r_sty {
@@ -297,7 +297,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
297297
};
298298
let param_env = self.param_env.and((def_id, substs));
299299
if let Some((def_id, substs)) = lookup_const_by_id(self.tcx, param_env) {
300-
let mut cx = ConstEvalLateContext {
300+
let mut cx = Self {
301301
tcx: self.tcx,
302302
tables: self.tcx.typeck_tables_of(def_id),
303303
needed_resolution: false,

clippy_lints/src/cyclomatic_complexity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct CyclomaticComplexity {
3131

3232
impl CyclomaticComplexity {
3333
pub fn new(limit: u64) -> Self {
34-
CyclomaticComplexity { limit: LimitStack::new(limit) }
34+
Self { limit: LimitStack::new(limit) }
3535
}
3636
}
3737

clippy_lints/src/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct Doc {
3737

3838
impl Doc {
3939
pub fn new(valid_idents: Vec<String>) -> Self {
40-
Doc { valid_idents: valid_idents }
40+
Self { valid_idents: valid_idents }
4141
}
4242
}
4343

@@ -62,7 +62,7 @@ struct Parser<'a> {
6262
}
6363

6464
impl<'a> Parser<'a> {
65-
fn new(parser: pulldown_cmark::Parser<'a>) -> Parser<'a> {
65+
fn new(parser: pulldown_cmark::Parser<'a>) -> Self {
6666
Self { parser: parser }
6767
}
6868
}

clippy_lints/src/enum_variants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ pub struct EnumVariantNames {
104104
}
105105

106106
impl EnumVariantNames {
107-
pub fn new(threshold: u64) -> EnumVariantNames {
108-
EnumVariantNames {
107+
pub fn new(threshold: u64) -> Self {
108+
Self {
109109
modules: Vec::new(),
110110
threshold: threshold,
111111
}

clippy_lints/src/functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub struct Functions {
5959
}
6060

6161
impl Functions {
62-
pub fn new(threshold: u64) -> Functions {
63-
Functions { threshold: threshold }
62+
pub fn new(threshold: u64) -> Self {
63+
Self { threshold: threshold }
6464
}
6565
}
6666

clippy_lints/src/large_enum_variant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct LargeEnumVariant {
3434

3535
impl LargeEnumVariant {
3636
pub fn new(maximum_size_difference_allowed: u64) -> Self {
37-
LargeEnumVariant { maximum_size_difference_allowed: maximum_size_difference_allowed }
37+
Self { maximum_size_difference_allowed: maximum_size_difference_allowed }
3838
}
3939
}
4040

clippy_lints/src/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ struct RefVisitor<'a, 'tcx: 'a> {
254254
}
255255

256256
impl<'v, 't> RefVisitor<'v, 't> {
257-
fn new(cx: &'v LateContext<'v, 't>) -> RefVisitor<'v, 't> {
258-
RefVisitor {
257+
fn new(cx: &'v LateContext<'v, 't>) -> Self {
258+
Self {
259259
cx: cx,
260260
lts: Vec::new(),
261261
abort: false,

clippy_lints/src/literal_digit_grouping.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ struct DigitInfo<'a> {
9595
}
9696

9797
impl<'a> DigitInfo<'a> {
98-
pub fn new(lit: &str, float: bool) -> DigitInfo {
98+
pub fn new(lit: &'a str, float: bool) -> Self {
9999
// Determine delimiter for radix prefix, if present, and radix.
100100
let radix = if lit.starts_with("0x") {
101101
Radix::Hexadecimal
@@ -120,7 +120,7 @@ impl<'a> DigitInfo<'a> {
120120
if !float && (d == 'i' || d == 'u') || float && d == 'f' {
121121
let suffix_start = if last_d == '_' { d_idx - 1 } else { d_idx };
122122
let (digits, suffix) = sans_prefix.split_at(suffix_start);
123-
return DigitInfo {
123+
return Self {
124124
digits: digits,
125125
radix: radix,
126126
prefix: prefix,
@@ -132,7 +132,7 @@ impl<'a> DigitInfo<'a> {
132132
}
133133

134134
// No suffix found
135-
DigitInfo {
135+
Self {
136136
digits: sans_prefix,
137137
radix: radix,
138138
prefix: prefix,
@@ -257,7 +257,7 @@ impl LiteralDigitGrouping {
257257
char::to_digit(firstch, 10).is_some()
258258
], {
259259
let digit_info = DigitInfo::new(&src, false);
260-
let _ = LiteralDigitGrouping::do_lint(digit_info.digits).map_err(|warning_type| {
260+
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
261261
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
262262
});
263263
}}
@@ -278,14 +278,14 @@ impl LiteralDigitGrouping {
278278

279279
// Lint integral and fractional parts separately, and then check consistency of digit
280280
// groups if both pass.
281-
let _ = LiteralDigitGrouping::do_lint(parts[0])
281+
let _ = Self::do_lint(parts[0])
282282
.map(|integral_group_size| {
283283
if parts.len() > 1 {
284284
// Lint the fractional part of literal just like integral part, but reversed.
285285
let fractional_part = &parts[1].chars().rev().collect::<String>();
286-
let _ = LiteralDigitGrouping::do_lint(fractional_part)
286+
let _ = Self::do_lint(fractional_part)
287287
.map(|fractional_group_size| {
288-
let consistent = LiteralDigitGrouping::parts_consistent(integral_group_size, fractional_group_size, parts[0].len(), parts[1].len());
288+
let consistent = Self::parts_consistent(integral_group_size, fractional_group_size, parts[0].len(), parts[1].len());
289289
if !consistent {
290290
WarningType::InconsistentDigitGrouping.display(&digit_info.grouping_hint(), cx, &lit.span);
291291
}

clippy_lints/src/missing_doc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ pub struct MissingDoc {
5656
}
5757

5858
impl ::std::default::Default for MissingDoc {
59-
fn default() -> MissingDoc {
60-
MissingDoc::new()
59+
fn default() -> Self {
60+
Self::new()
6161
}
6262
}
6363

6464
impl MissingDoc {
65-
pub fn new() -> MissingDoc {
66-
MissingDoc { doc_hidden_stack: vec![false] }
65+
pub fn new() -> Self {
66+
Self { doc_hidden_stack: vec![false] }
6767
}
6868

6969
fn doc_hidden(&self) -> bool {

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct MovedVariablesCtxt<'a, 'tcx: 'a> {
197197

198198
impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
199199
fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
200-
MovedVariablesCtxt {
200+
Self {
201201
cx: cx,
202202
moved_vars: HashSet::new(),
203203
spans_need_deref: HashMap::new(),

clippy_lints/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ pub struct TypeComplexityPass {
730730

731731
impl TypeComplexityPass {
732732
pub fn new(threshold: u64) -> Self {
733-
TypeComplexityPass { threshold: threshold }
733+
Self { threshold: threshold }
734734
}
735735
}
736736

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
147147

148148
impl PrintVisitor {
149149
fn new(s: &'static str) -> Self {
150-
PrintVisitor {
150+
Self {
151151
ids: HashMap::new(),
152152
current: s.to_owned(),
153153
}

clippy_lints/src/utils/hir_utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ pub struct SpanlessEq<'a, 'tcx: 'a> {
2323

2424
impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
2525
pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
26-
SpanlessEq {
26+
Self {
2727
cx: cx,
2828
ignore_fn: false,
2929
}
3030
}
3131

3232
pub fn ignore_fn(self) -> Self {
33-
SpanlessEq {
33+
Self {
3434
cx: self.cx,
3535
ignore_fn: true,
3636
}
@@ -283,7 +283,7 @@ pub struct SpanlessHash<'a, 'tcx: 'a> {
283283

284284
impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
285285
pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
286-
SpanlessHash {
286+
Self {
287287
cx: cx,
288288
s: DefaultHasher::new(),
289289
}

clippy_lints/src/utils/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,8 @@ impl Drop for LimitStack {
670670
}
671671

672672
impl LimitStack {
673-
pub fn new(limit: u64) -> LimitStack {
674-
LimitStack { stack: vec![limit] }
673+
pub fn new(limit: u64) -> Self {
674+
Self { stack: vec![limit] }
675675
}
676676
pub fn limit(&self) -> u64 {
677677
*self.stack.last().expect(

clippy_lints/src/utils/sugg.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Contains utility functions to generate suggestions.
22
#![deny(missing_docs_in_private_items)]
3+
// currently ignores lifetimes and generics
4+
#![allow(use_self)]
35

46
use rustc::hir;
57
use rustc::lint::{EarlyContext, LateContext, LintContext};
@@ -41,7 +43,7 @@ impl<'a> Display for Sugg<'a> {
4143
#[allow(wrong_self_convention)] // ok, because of the function `as_ty` method
4244
impl<'a> Sugg<'a> {
4345
/// Prepare a suggestion from an expression.
44-
pub fn hir_opt(cx: &LateContext, expr: &hir::Expr) -> Option<Sugg<'a>> {
46+
pub fn hir_opt(cx: &LateContext, expr: &hir::Expr) -> Option<Self> {
4547
snippet_opt(cx, expr.span).map(|snippet| {
4648
let snippet = Cow::Owned(snippet);
4749
match expr.node {
@@ -80,12 +82,12 @@ impl<'a> Sugg<'a> {
8082

8183
/// Convenience function around `hir_opt` for suggestions with a default
8284
/// text.
83-
pub fn hir(cx: &LateContext, expr: &hir::Expr, default: &'a str) -> Sugg<'a> {
85+
pub fn hir(cx: &LateContext, expr: &hir::Expr, default: &'a str) -> Self {
8486
Self::hir_opt(cx, expr).unwrap_or_else(|| Sugg::NonParen(Cow::Borrowed(default)))
8587
}
8688

8789
/// Prepare a suggestion from an expression.
88-
pub fn ast(cx: &EarlyContext, expr: &ast::Expr, default: &'a str) -> Sugg<'a> {
90+
pub fn ast(cx: &EarlyContext, expr: &ast::Expr, default: &'a str) -> Self {
8991
use syntax::ast::RangeLimits;
9092

9193
let snippet = snippet(cx, expr.span, default);
@@ -218,7 +220,7 @@ struct ParenHelper<T> {
218220
impl<T> ParenHelper<T> {
219221
/// Build a `ParenHelper`.
220222
fn new(paren: bool, wrapped: T) -> Self {
221-
ParenHelper {
223+
Self {
222224
paren: paren,
223225
wrapped: wrapped,
224226
}

0 commit comments

Comments
 (0)