Skip to content

Commit 05cd16a

Browse files
committed
Tweak test and use snippet in utils.
1 parent c9375e2 commit 05cd16a

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

clippy_lints/src/utils/internal_lints.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{
22
is_expn_of, match_def_path, match_type, method_calls, paths, span_lint, span_lint_and_help, span_lint_and_sugg,
3-
walk_ptrs_ty, snippet_opt, match_path_ast
3+
walk_ptrs_ty, snippet as other_snippet, match_path_ast
44
};
55
use if_chain::if_chain;
66
use rustc::hir::map::Map;
@@ -440,10 +440,10 @@ impl EarlyLintPass for CollapsibleCalls {
440440
}
441441

442442
struct AndThenArgs {
443-
cx: String,
444-
lint: String,
445-
span: String,
446-
msg: String,
443+
cx: Cow<'a, str>,
444+
lint: Cow<'a, str>,
445+
span: Cow<'a, str>,
446+
msg: Cow<'a, str>,
447447
}
448448

449449
fn get_and_then_args(cx: &EarlyContext<'_>, and_then_args: &Vec<P<AstExpr>>) -> AndThenArgs {
@@ -461,10 +461,10 @@ fn get_and_then_args(cx: &EarlyContext<'_>, and_then_args: &Vec<P<AstExpr>>) ->
461461
}
462462

463463
struct SuggestionArgs {
464-
span: String,
465-
help: String,
466-
sugg: String,
467-
applicability: String,
464+
span: Cow<'a, str>,
465+
help: Cow<'a, str>,
466+
sugg: Cow<'a, str>,
467+
applicability: Cow<'a, str>,
468468
}
469469

470470
fn suggestion_args(cx: &EarlyContext<'_>, span_call_args: &Vec<P<AstExpr>>) -> SuggestionArgs {
@@ -506,8 +506,8 @@ fn suggest_span_suggestion(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args:
506506
}
507507

508508
struct HelpArgs {
509-
span: String,
510-
help: String,
509+
span: Cow<'a, str>,
510+
help: Cow<'a, str>,
511511
}
512512

513513
fn help_args(cx: &EarlyContext<'_>, span_call_args: &Vec<P<AstExpr>>) -> HelpArgs {
@@ -542,8 +542,8 @@ fn suggest_span_help(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndTh
542542
}
543543

544544
struct NoteArgs {
545-
span: String,
546-
note: String,
545+
span: Cow<'a, str>,
546+
note: Cow<'a, str>,
547547
}
548548

549549
fn note_args(cx: &EarlyContext<'_>, span_call_args: &Vec<P<AstExpr>>) -> NoteArgs {
@@ -577,6 +577,6 @@ fn suggest_span_note(cx: &EarlyContext<'_>, expr: &AstExpr, and_then_args: AndTh
577577
}
578578
}
579579

580-
fn snippet(cx: &EarlyContext<'_>, span: Span) -> String {
581-
snippet_opt(cx, span).expect("should be able to retrive span.")
580+
fn snippet(cx: &EarlyContext<'_>, span: Span) -> Cow<'a, str> {
581+
other_snippet(cx, span, "Should not be")
582582
}

tests/ui/collapsible_span_lint_calls.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ impl EarlyLintPass for Pass {
4141
db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
4242
});
4343
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
44-
db.span_help(expr.span, help_msg);
45-
});
46-
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
47-
db.span_note(expr.span, note_msg);
44+
db.span_help(expr.span, help_msg)
4845
});
46+
span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db|
47+
db.span_note(expr.span, note_msg)
48+
);
4949
}
5050
}
5151

0 commit comments

Comments
 (0)