Run Dogfood for use_self
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## 0.0.154
|
||||||
|
* Fix [`use_self`] triggering inside derives
|
||||||
|
|
||||||
## 0.0.153
|
## 0.0.153
|
||||||
* Update to *rustc 1.21.0-nightly (8c303ed87 2017-08-20)*
|
* Update to *rustc 1.21.0-nightly (8c303ed87 2017-08-20)*
|
||||||
* New lint: [`use_self`]
|
* New lint: [`use_self`]
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ pub struct BlackListedName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BlackListedName {
|
impl BlackListedName {
|
||||||
pub fn new(blacklist: Vec<String>) -> BlackListedName {
|
pub fn new(blacklist: Vec<String>) -> Self {
|
||||||
BlackListedName { blacklist: blacklist }
|
Self { blacklist: blacklist }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub enum FloatWidth {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<FloatTy> for FloatWidth {
|
impl From<FloatTy> for FloatWidth {
|
||||||
fn from(ty: FloatTy) -> FloatWidth {
|
fn from(ty: FloatTy) -> Self {
|
||||||
match ty {
|
match ty {
|
||||||
FloatTy::F32 => FloatWidth::F32,
|
FloatTy::F32 => FloatWidth::F32,
|
||||||
FloatTy::F64 => FloatWidth::F64,
|
FloatTy::F64 => FloatWidth::F64,
|
||||||
@@ -55,7 +55,7 @@ pub enum Constant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for Constant {
|
impl PartialEq for Constant {
|
||||||
fn eq(&self, other: &Constant) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(&Constant::Str(ref ls, ref l_sty), &Constant::Str(ref rs, ref r_sty)) => ls == rs && l_sty == r_sty,
|
(&Constant::Str(ref ls, ref l_sty), &Constant::Str(ref rs, ref r_sty)) => ls == rs && l_sty == r_sty,
|
||||||
(&Constant::Binary(ref l), &Constant::Binary(ref r)) => l == r,
|
(&Constant::Binary(ref l), &Constant::Binary(ref r)) => l == r,
|
||||||
@@ -123,7 +123,7 @@ impl Hash for Constant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PartialOrd for Constant {
|
impl PartialOrd for Constant {
|
||||||
fn partial_cmp(&self, other: &Constant) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(&Constant::Str(ref ls, ref l_sty), &Constant::Str(ref rs, ref r_sty)) => {
|
(&Constant::Str(ref ls, ref l_sty), &Constant::Str(ref rs, ref r_sty)) => {
|
||||||
if l_sty == r_sty {
|
if l_sty == r_sty {
|
||||||
@@ -297,7 +297,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||||||
};
|
};
|
||||||
let param_env = self.param_env.and((def_id, substs));
|
let param_env = self.param_env.and((def_id, substs));
|
||||||
if let Some((def_id, substs)) = lookup_const_by_id(self.tcx, param_env) {
|
if let Some((def_id, substs)) = lookup_const_by_id(self.tcx, param_env) {
|
||||||
let mut cx = ConstEvalLateContext {
|
let mut cx = Self {
|
||||||
tcx: self.tcx,
|
tcx: self.tcx,
|
||||||
tables: self.tcx.typeck_tables_of(def_id),
|
tables: self.tcx.typeck_tables_of(def_id),
|
||||||
needed_resolution: false,
|
needed_resolution: false,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub struct CyclomaticComplexity {
|
|||||||
|
|
||||||
impl CyclomaticComplexity {
|
impl CyclomaticComplexity {
|
||||||
pub fn new(limit: u64) -> Self {
|
pub fn new(limit: u64) -> Self {
|
||||||
CyclomaticComplexity { limit: LimitStack::new(limit) }
|
Self { limit: LimitStack::new(limit) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub struct Doc {
|
|||||||
|
|
||||||
impl Doc {
|
impl Doc {
|
||||||
pub fn new(valid_idents: Vec<String>) -> Self {
|
pub fn new(valid_idents: Vec<String>) -> Self {
|
||||||
Doc { valid_idents: valid_idents }
|
Self { valid_idents: valid_idents }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ struct Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
fn new(parser: pulldown_cmark::Parser<'a>) -> Parser<'a> {
|
fn new(parser: pulldown_cmark::Parser<'a>) -> Self {
|
||||||
Self { parser: parser }
|
Self { parser: parser }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ pub struct EnumVariantNames {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EnumVariantNames {
|
impl EnumVariantNames {
|
||||||
pub fn new(threshold: u64) -> EnumVariantNames {
|
pub fn new(threshold: u64) -> Self {
|
||||||
EnumVariantNames {
|
Self {
|
||||||
modules: Vec::new(),
|
modules: Vec::new(),
|
||||||
threshold: threshold,
|
threshold: threshold,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ pub struct Functions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Functions {
|
impl Functions {
|
||||||
pub fn new(threshold: u64) -> Functions {
|
pub fn new(threshold: u64) -> Self {
|
||||||
Functions { threshold: threshold }
|
Self { threshold: threshold }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub struct LargeEnumVariant {
|
|||||||
|
|
||||||
impl LargeEnumVariant {
|
impl LargeEnumVariant {
|
||||||
pub fn new(maximum_size_difference_allowed: u64) -> Self {
|
pub fn new(maximum_size_difference_allowed: u64) -> Self {
|
||||||
LargeEnumVariant { maximum_size_difference_allowed: maximum_size_difference_allowed }
|
Self { maximum_size_difference_allowed: maximum_size_difference_allowed }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -254,8 +254,8 @@ struct RefVisitor<'a, 'tcx: 'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'v, 't> RefVisitor<'v, 't> {
|
impl<'v, 't> RefVisitor<'v, 't> {
|
||||||
fn new(cx: &'v LateContext<'v, 't>) -> RefVisitor<'v, 't> {
|
fn new(cx: &'v LateContext<'v, 't>) -> Self {
|
||||||
RefVisitor {
|
Self {
|
||||||
cx: cx,
|
cx: cx,
|
||||||
lts: Vec::new(),
|
lts: Vec::new(),
|
||||||
abort: false,
|
abort: false,
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ struct DigitInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DigitInfo<'a> {
|
impl<'a> DigitInfo<'a> {
|
||||||
pub fn new(lit: &str, float: bool) -> DigitInfo {
|
pub fn new(lit: &'a str, float: bool) -> Self {
|
||||||
// Determine delimiter for radix prefix, if present, and radix.
|
// Determine delimiter for radix prefix, if present, and radix.
|
||||||
let radix = if lit.starts_with("0x") {
|
let radix = if lit.starts_with("0x") {
|
||||||
Radix::Hexadecimal
|
Radix::Hexadecimal
|
||||||
@@ -120,7 +120,7 @@ impl<'a> DigitInfo<'a> {
|
|||||||
if !float && (d == 'i' || d == 'u') || float && d == 'f' {
|
if !float && (d == 'i' || d == 'u') || float && d == 'f' {
|
||||||
let suffix_start = if last_d == '_' { d_idx - 1 } else { d_idx };
|
let suffix_start = if last_d == '_' { d_idx - 1 } else { d_idx };
|
||||||
let (digits, suffix) = sans_prefix.split_at(suffix_start);
|
let (digits, suffix) = sans_prefix.split_at(suffix_start);
|
||||||
return DigitInfo {
|
return Self {
|
||||||
digits: digits,
|
digits: digits,
|
||||||
radix: radix,
|
radix: radix,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
@@ -132,7 +132,7 @@ impl<'a> DigitInfo<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No suffix found
|
// No suffix found
|
||||||
DigitInfo {
|
Self {
|
||||||
digits: sans_prefix,
|
digits: sans_prefix,
|
||||||
radix: radix,
|
radix: radix,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
@@ -257,7 +257,7 @@ impl LiteralDigitGrouping {
|
|||||||
char::to_digit(firstch, 10).is_some()
|
char::to_digit(firstch, 10).is_some()
|
||||||
], {
|
], {
|
||||||
let digit_info = DigitInfo::new(&src, false);
|
let digit_info = DigitInfo::new(&src, false);
|
||||||
let _ = LiteralDigitGrouping::do_lint(digit_info.digits).map_err(|warning_type| {
|
let _ = Self::do_lint(digit_info.digits).map_err(|warning_type| {
|
||||||
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
|
warning_type.display(&digit_info.grouping_hint(), cx, &lit.span)
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -278,14 +278,14 @@ impl LiteralDigitGrouping {
|
|||||||
|
|
||||||
// Lint integral and fractional parts separately, and then check consistency of digit
|
// Lint integral and fractional parts separately, and then check consistency of digit
|
||||||
// groups if both pass.
|
// groups if both pass.
|
||||||
let _ = LiteralDigitGrouping::do_lint(parts[0])
|
let _ = Self::do_lint(parts[0])
|
||||||
.map(|integral_group_size| {
|
.map(|integral_group_size| {
|
||||||
if parts.len() > 1 {
|
if parts.len() > 1 {
|
||||||
// Lint the fractional part of literal just like integral part, but reversed.
|
// Lint the fractional part of literal just like integral part, but reversed.
|
||||||
let fractional_part = &parts[1].chars().rev().collect::<String>();
|
let fractional_part = &parts[1].chars().rev().collect::<String>();
|
||||||
let _ = LiteralDigitGrouping::do_lint(fractional_part)
|
let _ = Self::do_lint(fractional_part)
|
||||||
.map(|fractional_group_size| {
|
.map(|fractional_group_size| {
|
||||||
let consistent = LiteralDigitGrouping::parts_consistent(integral_group_size, fractional_group_size, parts[0].len(), parts[1].len());
|
let consistent = Self::parts_consistent(integral_group_size, fractional_group_size, parts[0].len(), parts[1].len());
|
||||||
if !consistent {
|
if !consistent {
|
||||||
WarningType::InconsistentDigitGrouping.display(&digit_info.grouping_hint(), cx, &lit.span);
|
WarningType::InconsistentDigitGrouping.display(&digit_info.grouping_hint(), cx, &lit.span);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ pub struct MissingDoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::default::Default for MissingDoc {
|
impl ::std::default::Default for MissingDoc {
|
||||||
fn default() -> MissingDoc {
|
fn default() -> Self {
|
||||||
MissingDoc::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MissingDoc {
|
impl MissingDoc {
|
||||||
pub fn new() -> MissingDoc {
|
pub fn new() -> Self {
|
||||||
MissingDoc { doc_hidden_stack: vec![false] }
|
Self { doc_hidden_stack: vec![false] }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn doc_hidden(&self) -> bool {
|
fn doc_hidden(&self) -> bool {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ struct MovedVariablesCtxt<'a, 'tcx: 'a> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
|
||||||
fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
|
fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
|
||||||
MovedVariablesCtxt {
|
Self {
|
||||||
cx: cx,
|
cx: cx,
|
||||||
moved_vars: HashSet::new(),
|
moved_vars: HashSet::new(),
|
||||||
spans_need_deref: HashMap::new(),
|
spans_need_deref: HashMap::new(),
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ pub struct TypeComplexityPass {
|
|||||||
|
|
||||||
impl TypeComplexityPass {
|
impl TypeComplexityPass {
|
||||||
pub fn new(threshold: u64) -> Self {
|
pub fn new(threshold: u64) -> Self {
|
||||||
TypeComplexityPass { threshold: threshold }
|
Self { threshold: threshold }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||||||
|
|
||||||
impl PrintVisitor {
|
impl PrintVisitor {
|
||||||
fn new(s: &'static str) -> Self {
|
fn new(s: &'static str) -> Self {
|
||||||
PrintVisitor {
|
Self {
|
||||||
ids: HashMap::new(),
|
ids: HashMap::new(),
|
||||||
current: s.to_owned(),
|
current: s.to_owned(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ pub struct SpanlessEq<'a, 'tcx: 'a> {
|
|||||||
|
|
||||||
impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
||||||
pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
|
pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
|
||||||
SpanlessEq {
|
Self {
|
||||||
cx: cx,
|
cx: cx,
|
||||||
ignore_fn: false,
|
ignore_fn: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ignore_fn(self) -> Self {
|
pub fn ignore_fn(self) -> Self {
|
||||||
SpanlessEq {
|
Self {
|
||||||
cx: self.cx,
|
cx: self.cx,
|
||||||
ignore_fn: true,
|
ignore_fn: true,
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ pub struct SpanlessHash<'a, 'tcx: 'a> {
|
|||||||
|
|
||||||
impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
||||||
pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
|
pub fn new(cx: &'a LateContext<'a, 'tcx>) -> Self {
|
||||||
SpanlessHash {
|
Self {
|
||||||
cx: cx,
|
cx: cx,
|
||||||
s: DefaultHasher::new(),
|
s: DefaultHasher::new(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -670,8 +670,8 @@ impl Drop for LimitStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LimitStack {
|
impl LimitStack {
|
||||||
pub fn new(limit: u64) -> LimitStack {
|
pub fn new(limit: u64) -> Self {
|
||||||
LimitStack { stack: vec![limit] }
|
Self { stack: vec![limit] }
|
||||||
}
|
}
|
||||||
pub fn limit(&self) -> u64 {
|
pub fn limit(&self) -> u64 {
|
||||||
*self.stack.last().expect(
|
*self.stack.last().expect(
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
//! Contains utility functions to generate suggestions.
|
//! Contains utility functions to generate suggestions.
|
||||||
#![deny(missing_docs_in_private_items)]
|
#![deny(missing_docs_in_private_items)]
|
||||||
|
// currently ignores lifetimes and generics
|
||||||
|
#![allow(use_self)]
|
||||||
|
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::lint::{EarlyContext, LateContext, LintContext};
|
use rustc::lint::{EarlyContext, LateContext, LintContext};
|
||||||
@@ -41,7 +43,7 @@ impl<'a> Display for Sugg<'a> {
|
|||||||
#[allow(wrong_self_convention)] // ok, because of the function `as_ty` method
|
#[allow(wrong_self_convention)] // ok, because of the function `as_ty` method
|
||||||
impl<'a> Sugg<'a> {
|
impl<'a> Sugg<'a> {
|
||||||
/// Prepare a suggestion from an expression.
|
/// Prepare a suggestion from an expression.
|
||||||
pub fn hir_opt(cx: &LateContext, expr: &hir::Expr) -> Option<Sugg<'a>> {
|
pub fn hir_opt(cx: &LateContext, expr: &hir::Expr) -> Option<Self> {
|
||||||
snippet_opt(cx, expr.span).map(|snippet| {
|
snippet_opt(cx, expr.span).map(|snippet| {
|
||||||
let snippet = Cow::Owned(snippet);
|
let snippet = Cow::Owned(snippet);
|
||||||
match expr.node {
|
match expr.node {
|
||||||
@@ -80,12 +82,12 @@ impl<'a> Sugg<'a> {
|
|||||||
|
|
||||||
/// Convenience function around `hir_opt` for suggestions with a default
|
/// Convenience function around `hir_opt` for suggestions with a default
|
||||||
/// text.
|
/// text.
|
||||||
pub fn hir(cx: &LateContext, expr: &hir::Expr, default: &'a str) -> Sugg<'a> {
|
pub fn hir(cx: &LateContext, expr: &hir::Expr, default: &'a str) -> Self {
|
||||||
Self::hir_opt(cx, expr).unwrap_or_else(|| Sugg::NonParen(Cow::Borrowed(default)))
|
Self::hir_opt(cx, expr).unwrap_or_else(|| Sugg::NonParen(Cow::Borrowed(default)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prepare a suggestion from an expression.
|
/// Prepare a suggestion from an expression.
|
||||||
pub fn ast(cx: &EarlyContext, expr: &ast::Expr, default: &'a str) -> Sugg<'a> {
|
pub fn ast(cx: &EarlyContext, expr: &ast::Expr, default: &'a str) -> Self {
|
||||||
use syntax::ast::RangeLimits;
|
use syntax::ast::RangeLimits;
|
||||||
|
|
||||||
let snippet = snippet(cx, expr.span, default);
|
let snippet = snippet(cx, expr.span, default);
|
||||||
@@ -218,7 +220,7 @@ struct ParenHelper<T> {
|
|||||||
impl<T> ParenHelper<T> {
|
impl<T> ParenHelper<T> {
|
||||||
/// Build a `ParenHelper`.
|
/// Build a `ParenHelper`.
|
||||||
fn new(paren: bool, wrapped: T) -> Self {
|
fn new(paren: bool, wrapped: T) -> Self {
|
||||||
ParenHelper {
|
Self {
|
||||||
paren: paren,
|
paren: paren,
|
||||||
wrapped: wrapped,
|
wrapped: wrapped,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user