@@ -147,15 +147,15 @@ pub fn get_def_path(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Vec<&'static str>
147147 . collect ( )
148148}
149149
150- /// Checks if type is struct, enum or union type with given def path.
150+ /// Checks if type is struct, enum or union type with the given def path.
151151pub fn match_type ( cx : & LateContext < ' _ , ' _ > , ty : Ty < ' _ > , path : & [ & str ] ) -> bool {
152152 match ty. sty {
153153 ty:: Adt ( adt, _) => match_def_path ( cx. tcx , adt. did , path) ,
154154 _ => false ,
155155 }
156156}
157157
158- /// Checks if the method call given in `expr` belongs to given trait.
158+ /// Checks if the method call given in `expr` belongs to the given trait.
159159pub fn match_trait_method ( cx : & LateContext < ' _ , ' _ > , expr : & Expr , path : & [ & str ] ) -> bool {
160160 let method_call = cx. tables . type_dependent_defs ( ) [ expr. hir_id ] ;
161161 let trt_id = cx. tcx . trait_of_item ( method_call. def_id ( ) ) ;
@@ -434,7 +434,7 @@ pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
434434 }
435435}
436436
437- /// Gets the name of a `Pat`, if any
437+ /// Gets the name of a `Pat`, if any.
438438pub fn get_pat_name ( pat : & Pat ) -> Option < Name > {
439439 match pat. node {
440440 PatKind :: Binding ( .., ref spname, _) => Some ( spname. name ) ,
@@ -614,7 +614,7 @@ fn trim_multiline_inner(s: Cow<'_, str>, ignore_first: bool, ch: char) -> Cow<'_
614614 }
615615}
616616
617- /// Gets a parent expressions if any – this is useful to constrain a lint.
617+ /// Gets the parent expression, if any –- this is useful to constrain a lint.
618618pub fn get_parent_expr < ' c > ( cx : & ' c LateContext < ' _ , ' _ > , e : & Expr ) -> Option < & ' c Expr > {
619619 let map = & cx. tcx . hir ( ) ;
620620 let hir_id = e. hir_id ;
@@ -727,7 +727,7 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
727727 }
728728}
729729
730- /// Returns the pre-expansion span if is this directly comes from an expansion
730+ /// Returns the pre-expansion span if the span directly comes from an expansion
731731/// of the macro `name`.
732732/// The difference with `is_expn_of` is that in
733733/// ```rust,ignore
@@ -749,7 +749,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
749749 }
750750}
751751
752- /// Convenience function to get the return type of a function
752+ /// Convenience function to get the return type of a function.
753753pub fn return_ty < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , fn_item : hir:: HirId ) -> Ty < ' tcx > {
754754 let fn_def_id = cx. tcx . hir ( ) . local_def_id_from_hir_id ( fn_item) ;
755755 let ret_ty = cx. tcx . fn_sig ( fn_def_id) . output ( ) ;
@@ -759,9 +759,9 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: hir::HirId) -> T
759759/// Checks if two types are the same.
760760///
761761/// This discards any lifetime annotations, too.
762- // FIXME: this works correctly for lifetimes bounds (`for <'a> Foo<'a>` == `for
763- // <'b > Foo<'b >` but
764- // not for type parameters.
762+ //
763+ // FIXME: this works correctly for lifetimes bounds (`for <'a > Foo<'a >` ==
764+ // `for <'b> Foo<'b>`, but not for type parameters) .
765765pub fn same_tys < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> bool {
766766 let a = cx. tcx . erase_late_bound_regions ( & Binder :: bind ( a) ) ;
767767 let b = cx. tcx . erase_late_bound_regions ( & Binder :: bind ( b) ) ;
@@ -871,8 +871,8 @@ pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<I
871871 ( 0 ..decl. inputs . len ( ) ) . map ( move |i| & body. arguments [ i] )
872872}
873873
874- /// Checks if a given expression is a match expression
875- /// expanded from `?` operator or `try` macro.
874+ /// Checks if a given expression is a match expression expanded from the `?`
875+ /// operator or the `try` macro.
876876pub fn is_try < ' a > ( cx : & ' _ LateContext < ' _ , ' _ > , expr : & ' a Expr ) -> Option < & ' a Expr > {
877877 fn is_ok ( cx : & ' _ LateContext < ' _ , ' _ > , arm : & Arm ) -> bool {
878878 if_chain ! {
0 commit comments