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 ;
@@ -440,10 +440,10 @@ impl EarlyLintPass for CollapsibleCalls {
440
440
}
441
441
442
442
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 > ,
447
447
}
448
448
449
449
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>>) ->
461
461
}
462
462
463
463
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 > ,
468
468
}
469
469
470
470
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:
506
506
}
507
507
508
508
struct HelpArgs {
509
- span : String ,
510
- help : String ,
509
+ span : Cow < ' a , str > ,
510
+ help : Cow < ' a , str > ,
511
511
}
512
512
513
513
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
542
542
}
543
543
544
544
struct NoteArgs {
545
- span : String ,
546
- note : String ,
545
+ span : Cow < ' a , str > ,
546
+ note : Cow < ' a , str > ,
547
547
}
548
548
549
549
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
577
577
}
578
578
}
579
579
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 ")
582
582
}
0 commit comments