Skip to content

rustup #3705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 27, 2019
Merged

rustup #3705

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
@@ -60,6 +60,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(APPROX_CONSTANT)
}

fn name(&self) -> &'static str {
"ApproxConstant"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
4 changes: 4 additions & 0 deletions clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
@@ -52,6 +52,10 @@ impl LintPass for Arithmetic {
fn get_lints(&self) -> LintArray {
lint_array!(INTEGER_ARITHMETIC, FLOAT_ARITHMETIC)
}

fn name(&self) -> &'static str {
"Arithmetic"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Arithmetic {
4 changes: 4 additions & 0 deletions clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
@@ -34,6 +34,10 @@ impl LintPass for AssertionsOnConstants {
fn get_lints(&self) -> LintArray {
lint_array![ASSERTIONS_ON_CONSTANTS]
}

fn name(&self) -> &'static str {
"AssertionsOnConstants"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
10 changes: 7 additions & 3 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
@@ -57,6 +57,10 @@ impl LintPass for AssignOps {
fn get_lints(&self) -> LintArray {
lint_array!(ASSIGN_OP_PATTERN, MISREFACTORED_ASSIGN_OP)
}

fn name(&self) -> &'static str {
"AssignOps"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
@@ -79,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
let r = &sugg::Sugg::hir(cx, rhs, "..");
let long =
format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r));
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
&format!(
"Did you mean {} = {} {} {} or {}? Consider replacing it with",
@@ -92,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
Applicability::MachineApplicable,
);
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"or",
long,
@@ -179,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
if let (Some(snip_a), Some(snip_r)) =
(snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span))
{
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"replace it with",
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r),
12 changes: 10 additions & 2 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
@@ -199,6 +199,10 @@ impl LintPass for AttrPass {
UNKNOWN_CLIPPY_LINTS,
)
}

fn name(&self) -> &'static str {
"Attributes"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
@@ -269,7 +273,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
"useless lint attribute",
|db| {
sugg = sugg.replacen("#[", "#![", 1);
db.span_suggestion_with_applicability(
db.span_suggestion(
line_span,
"if you just forgot a `!`, use",
sugg,
@@ -332,7 +336,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
// https://github.com/rust-lang/rust/pull/56992
CheckLintNameResult::NoLint(None) => (),
_ => {
db.span_suggestion_with_applicability(
db.span_suggestion(
lint.span,
"lowercase the lint name",
name_lower,
@@ -500,6 +504,10 @@ impl LintPass for CfgAttrPass {
fn get_lints(&self) -> LintArray {
lint_array!(DEPRECATED_CFG_ATTR,)
}

fn name(&self) -> &'static str {
"DeprecatedCfgAttribute"
}
}

impl EarlyLintPass for CfgAttrPass {
5 changes: 4 additions & 1 deletion clippy_lints/src/bit_mask.rs
Original file line number Diff line number Diff line change
@@ -108,6 +108,9 @@ impl LintPass for BitMask {
fn get_lints(&self) -> LintArray {
lint_array!(BAD_BIT_MASK, INEFFECTIVE_BIT_MASK, VERBOSE_BIT_MASK)
}
fn name(&self) -> &'static str {
"BitMask"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
@@ -139,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask {
"bit mask could be simplified with a call to `trailing_zeros`",
|db| {
let sugg = Sugg::hir(cx, left1, "...").maybe_par();
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"try",
format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()),
3 changes: 3 additions & 0 deletions clippy_lints/src/blacklisted_name.rs
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@ impl LintPass for BlackListedName {
fn get_lints(&self) -> LintArray {
lint_array!(BLACKLISTED_NAME)
}
fn name(&self) -> &'static str {
"BlacklistedName"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
4 changes: 4 additions & 0 deletions clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
@@ -49,6 +49,10 @@ impl LintPass for BlockInIfCondition {
fn get_lints(&self) -> LintArray {
lint_array!(BLOCK_IN_IF_CONDITION_EXPR, BLOCK_IN_IF_CONDITION_STMT)
}

fn name(&self) -> &'static str {
"BlockInIfCondition"
}
}

struct ExVisitor<'a, 'tcx: 'a> {
8 changes: 6 additions & 2 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
@@ -58,6 +58,10 @@ impl LintPass for NonminimalBool {
fn get_lints(&self) -> LintArray {
lint_array!(NONMINIMAL_BOOL, LOGIC_BUG)
}

fn name(&self) -> &'static str {
"NonminimalBool"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
@@ -389,7 +393,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
"this expression can be optimized out by applying boolean operations to the \
outer expression",
);
db.span_suggestion_with_applicability(
db.span_suggestion(
e.span,
"it would look like the following",
suggest(self.cx, suggestion, &h2q.terminals).0,
@@ -419,7 +423,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
e.span,
"this boolean expression can be simplified",
|db| {
db.span_suggestions_with_applicability(
db.span_suggestions(
e.span,
"try",
suggestions.into_iter(),
4 changes: 4 additions & 0 deletions clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ impl LintPass for ByteCount {
fn get_lints(&self) -> LintArray {
lint_array!(NAIVE_BYTECOUNT)
}

fn name(&self) -> &'static str {
"ByteCount"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
4 changes: 4 additions & 0 deletions clippy_lints/src/cargo_common_metadata.rs
Original file line number Diff line number Diff line change
@@ -62,6 +62,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(CARGO_COMMON_METADATA)
}

fn name(&self) -> &'static str {
"CargoCommonMetadata"
}
}

impl EarlyLintPass for Pass {
6 changes: 5 additions & 1 deletion clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
@@ -78,6 +78,10 @@ impl LintPass for CollapsibleIf {
fn get_lints(&self) -> LintArray {
lint_array!(COLLAPSIBLE_IF)
}

fn name(&self) -> &'static str {
"CollapsibleIf"
}
}

impl EarlyLintPass for CollapsibleIf {
@@ -150,7 +154,7 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this if statement can be collapsed", |db| {
let lhs = Sugg::ast(cx, check, "..");
let rhs = Sugg::ast(cx, check_inner, "..");
db.span_suggestion_with_applicability(
db.span_suggestion(
expr.span,
"try",
format!(
6 changes: 5 additions & 1 deletion clippy_lints/src/const_static_lifetime.rs
Original file line number Diff line number Diff line change
@@ -32,6 +32,10 @@ impl LintPass for StaticConst {
fn get_lints(&self) -> LintArray {
lint_array!(CONST_STATIC_LIFETIME)
}

fn name(&self) -> &'static str {
"StaticConst"
}
}

impl StaticConst {
@@ -62,7 +66,7 @@ impl StaticConst {
lifetime.ident.span,
"Constants have by default a `'static` lifetime",
|db| {
db.span_suggestion_with_applicability(
db.span_suggestion(
ty.span,
"consider removing `'static`",
sugg,
6 changes: 5 additions & 1 deletion clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
@@ -110,6 +110,10 @@ impl LintPass for CopyAndPaste {
fn get_lints(&self) -> LintArray {
lint_array![IFS_SAME_COND, IF_SAME_THEN_ELSE, MATCH_SAME_ARMS]
}

fn name(&self) -> &'static str {
"CopyAndPaste"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyAndPaste {
@@ -203,7 +207,7 @@ fn lint_match_arms(cx: &LateContext<'_, '_>, expr: &Expr) {
|db| {
db.span_note(i.body.span, "same as this");

// Note: this does not use `span_suggestion_with_applicability` on purpose:
// Note: this does not use `span_suggestion` on purpose:
// there is no clean way
// to remove the other arm. Building a span and suggest to replace it to ""
// makes an even more confusing error message. Also in order not to make up a
4 changes: 4 additions & 0 deletions clippy_lints/src/copy_iterator.rs
Original file line number Diff line number Diff line change
@@ -35,6 +35,10 @@ impl LintPass for CopyIterator {
fn get_lints(&self) -> LintArray {
lint_array![COPY_ITERATOR]
}

fn name(&self) -> &'static str {
"CopyIterator"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
4 changes: 4 additions & 0 deletions clippy_lints/src/cyclomatic_complexity.rs
Original file line number Diff line number Diff line change
@@ -42,6 +42,10 @@ impl LintPass for CyclomaticComplexity {
fn get_lints(&self) -> LintArray {
lint_array!(CYCLOMATIC_COMPLEXITY)
}

fn name(&self) -> &'static str {
"CyclomaticComplexity"
}
}

impl CyclomaticComplexity {
4 changes: 4 additions & 0 deletions clippy_lints/src/default_trait_access.rs
Original file line number Diff line number Diff line change
@@ -35,6 +35,10 @@ impl LintPass for DefaultTraitAccess {
fn get_lints(&self) -> LintArray {
lint_array!(DEFAULT_TRAIT_ACCESS)
}

fn name(&self) -> &'static str {
"DefaultTraitAccess"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
4 changes: 4 additions & 0 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
@@ -68,6 +68,10 @@ impl LintPass for Derive {
fn get_lints(&self) -> LintArray {
lint_array!(EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ)
}

fn name(&self) -> &'static str {
"Derive"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
4 changes: 4 additions & 0 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
@@ -48,6 +48,10 @@ impl LintPass for Doc {
fn get_lints(&self) -> LintArray {
lint_array![DOC_MARKDOWN]
}

fn name(&self) -> &'static str {
"DocMarkdown"
}
}

impl EarlyLintPass for Doc {
4 changes: 4 additions & 0 deletions clippy_lints/src/double_comparison.rs
Original file line number Diff line number Diff line change
@@ -37,6 +37,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(DOUBLE_COMPARISONS)
}

fn name(&self) -> &'static str {
"DoubleComparisons"
}
}

impl<'a, 'tcx> Pass {
4 changes: 4 additions & 0 deletions clippy_lints/src/double_parens.rs
Original file line number Diff line number Diff line change
@@ -29,6 +29,10 @@ impl LintPass for DoubleParens {
fn get_lints(&self) -> LintArray {
lint_array!(DOUBLE_PARENS)
}

fn name(&self) -> &'static str {
"DoubleParens"
}
}

impl EarlyLintPass for DoubleParens {
4 changes: 4 additions & 0 deletions clippy_lints/src/drop_forget_ref.rs
Original file line number Diff line number Diff line change
@@ -112,6 +112,10 @@ impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY)
}

fn name(&self) -> &'static str {
"DropForgetRef"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
4 changes: 4 additions & 0 deletions clippy_lints/src/duration_subsec.rs
Original file line number Diff line number Diff line change
@@ -36,6 +36,10 @@ impl LintPass for DurationSubsec {
fn get_lints(&self) -> LintArray {
lint_array!(DURATION_SUBSEC)
}

fn name(&self) -> &'static str {
"DurationSubsec"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {
4 changes: 4 additions & 0 deletions clippy_lints/src/else_if_without_else.rs
Original file line number Diff line number Diff line change
@@ -46,6 +46,10 @@ impl LintPass for ElseIfWithoutElse {
fn get_lints(&self) -> LintArray {
lint_array!(ELSE_IF_WITHOUT_ELSE)
}

fn name(&self) -> &'static str {
"ElseIfWithoutElse"
}
}

impl EarlyLintPass for ElseIfWithoutElse {
4 changes: 4 additions & 0 deletions clippy_lints/src/empty_enum.rs
Original file line number Diff line number Diff line change
@@ -30,6 +30,10 @@ impl LintPass for EmptyEnum {
fn get_lints(&self) -> LintArray {
lint_array!(EMPTY_ENUM)
}

fn name(&self) -> &'static str {
"EmptyEnum"
}
}

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
Loading