Skip to content

Commit

Permalink
Why Cow<'a, str> == Cow<'a, str> not matched?
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongmao86 committed Mar 22, 2020
1 parent 1cee809 commit b7faf05
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl EarlyLintPass for CollapsibleCalls {
if let ExprKind::Block(block, _) = &block.kind;
let stmts = &block.stmts;
if stmts.len() == 1;
if let StmtKind::Expr(only_expr) = &stmts[0].kind;
if let StmtKind::Semi(only_expr) = &stmts[0].kind;
if let ExprKind::MethodCall(ref ps, ref span_call_args) = &only_expr.kind;
let and_then_args = get_and_then_args(cx, and_then_args);
then {
Expand Down Expand Up @@ -480,7 +480,6 @@ fn suggestion_args<'a>(cx: &EarlyContext<'_>, span_call_args: &Vec<P<AstExpr>>)

fn suggest_span_suggestion(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndThenArgs<'_>, suggestion_args: SuggestionArgs<'_>) {
if and_then_args.span == suggestion_args.span {
println!("suggestion true");
span_lint_and_sugg (
cx,
COLLAPSIBLE_SPAN_LINT_CALLS,
Expand All @@ -499,6 +498,16 @@ fn suggest_span_suggestion(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args:
),
Applicability::MachineApplicable
);
} else {
span_lint_and_sugg(
cx,
COLLAPSIBLE_SPAN_LINT_CALLS,
expr.span,
"Lint activated",
"Lint helped",
"modify to".to_string(),
Applicability::MachineApplicable
)
}
}

Expand Down Expand Up @@ -562,11 +571,12 @@ fn suggest_span_note(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndTh
"this call is collspible",
"collapse into",
format!(
"span_lint_and_note({},{}, {}, {}, {})",
"span_lint_and_note({}, {}, {}, {}, {}, {})",
and_then_args.cx,
and_then_args.lint,
and_then_args.span,
and_then_args.msg,
and_then_args.span,
note_args.note
),
Applicability::MachineApplicable
Expand All @@ -575,5 +585,5 @@ fn suggest_span_note(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndTh
}

fn snippet<'a>(cx: &EarlyContext<'_>, span: Span) -> Cow<'a, str> {
other_snippet(cx, span, "Should not be")
other_snippet(cx, span, "Should not be this snippet")
}

0 comments on commit b7faf05

Please sign in to comment.