Skip to content

Commit fbd2e6f

Browse files
committed
Tweak test and use snippet in utils.
1 parent b9050d4 commit fbd2e6f

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;
@@ -439,10 +439,10 @@ impl EarlyLintPass for CollapsibleCalls {
439439
}
440440

441441
struct AndThenArgs {
442-
cx: String,
443-
lint: String,
444-
span: String,
445-
msg: String,
442+
cx: Cow<'a, str>,
443+
lint: Cow<'a, str>,
444+
span: Cow<'a, str>,
445+
msg: Cow<'a, str>,
446446
}
447447

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

462462
struct SuggestionArgs {
463-
span: String,
464-
help: String,
465-
sugg: String,
466-
applicability: String,
463+
span: Cow<'a, str>,
464+
help: Cow<'a, str>,
465+
sugg: Cow<'a, str>,
466+
applicability: Cow<'a, str>,
467467
}
468468

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

507507
struct HelpArgs {
508-
span: String,
509-
help: String,
508+
span: Cow<'a, str>,
509+
help: Cow<'a, str>,
510510
}
511511

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

543543
struct NoteArgs {
544-
span: String,
545-
note: String,
544+
span: Cow<'a, str>,
545+
note: Cow<'a, str>,
546546
}
547547

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

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

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)