11use 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} ;
55use if_chain:: if_chain;
66use rustc:: hir:: map:: Map ;
@@ -440,10 +440,10 @@ impl EarlyLintPass for CollapsibleCalls {
440440}
441441
442442struct 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
449449fn 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
463463struct 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
470470fn 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
508508struct HelpArgs {
509- span : String ,
510- help : String ,
509+ span : Cow < ' a , str > ,
510+ help : Cow < ' a , str > ,
511511}
512512
513513fn 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
544544struct NoteArgs {
545- span : String ,
546- note : String ,
545+ span : Cow < ' a , str > ,
546+ note : Cow < ' a , str > ,
547547}
548548
549549fn 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}
0 commit comments