1
1
use crate :: utils:: {
2
2
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
4
4
} ;
5
5
use if_chain:: if_chain;
6
6
use rustc:: hir:: map:: Map ;
@@ -439,10 +439,10 @@ impl EarlyLintPass for CollapsibleCalls {
439
439
}
440
440
441
441
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 > ,
446
446
}
447
447
448
448
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>>) ->
460
460
}
461
461
462
462
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 > ,
467
467
}
468
468
469
469
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:
505
505
}
506
506
507
507
struct HelpArgs {
508
- span : String ,
509
- help : String ,
508
+ span : Cow < ' a , str > ,
509
+ help : Cow < ' a , str > ,
510
510
}
511
511
512
512
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
541
541
}
542
542
543
543
struct NoteArgs {
544
- span : String ,
545
- note : String ,
544
+ span : Cow < ' a , str > ,
545
+ note : Cow < ' a , str > ,
546
546
}
547
547
548
548
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
576
576
}
577
577
}
578
578
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 ")
581
581
}
0 commit comments