@@ -252,11 +252,7 @@ pub fn is_lang_ctor(cx: &LateContext<'_>, qpath: &QPath<'_>, lang_item: LangItem
252252/// Returns `true` if this `span` was expanded by any macro.
253253#[ must_use]
254254pub fn in_macro ( span : Span ) -> bool {
255- if span. from_expansion ( ) {
256- !matches ! ( span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Desugaring ( ..) )
257- } else {
258- false
259- }
255+ span. from_expansion ( ) && !matches ! ( span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Desugaring ( ..) )
260256}
261257
262258pub fn is_unit_expr ( expr : & Expr < ' _ > ) -> bool {
@@ -1286,10 +1282,9 @@ pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool
12861282 }
12871283 let enclosing_body = cx. tcx . hir ( ) . local_def_id ( cx. tcx . hir ( ) . enclosing_body_owner ( e. hir_id ) ) ;
12881284 if let Some ( ( Constant :: Int ( v) , _) ) = constant ( cx, cx. tcx . typeck ( enclosing_body) , e) {
1289- value == v
1290- } else {
1291- false
1285+ return value == v;
12921286 }
1287+ false
12931288}
12941289
12951290/// Checks whether the given expression is a constant literal of the given value.
@@ -1316,7 +1311,7 @@ pub fn is_adjusted(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
13161311
13171312/// Returns the pre-expansion span if is this comes from an expansion of the
13181313/// macro `name`.
1319- /// See also `is_direct_expn_of`.
1314+ /// See also [ `is_direct_expn_of`] .
13201315#[ must_use]
13211316pub fn is_expn_of ( mut span : Span , name : & str ) -> Option < Span > {
13221317 loop {
@@ -1339,13 +1334,13 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
13391334
13401335/// Returns the pre-expansion span if the span directly comes from an expansion
13411336/// of the macro `name`.
1342- /// The difference with `is_expn_of` is that in
1343- /// ```rust,ignore
1337+ /// The difference with [`is_expn_of`] is that in
1338+ /// ```rust
1339+ /// # macro_rules! foo { ($e:tt) => { $e } }; macro_rules! bar { ($e:expr) => { $e } }
13441340/// foo!(bar!(42));
13451341/// ```
13461342/// `42` is considered expanded from `foo!` and `bar!` by `is_expn_of` but only
1347- /// `bar!` by
1348- /// `is_direct_expn_of`.
1343+ /// from `bar!` by `is_direct_expn_of`.
13491344#[ must_use]
13501345pub fn is_direct_expn_of ( span : Span , name : & str ) -> Option < Span > {
13511346 if span. from_expansion ( ) {
@@ -1468,11 +1463,9 @@ pub fn is_self(slf: &Param<'_>) -> bool {
14681463}
14691464
14701465pub fn is_self_ty ( slf : & hir:: Ty < ' _ > ) -> bool {
1471- if_chain ! {
1472- if let TyKind :: Path ( QPath :: Resolved ( None , path) ) = slf. kind;
1473- if let Res :: SelfTy ( ..) = path. res;
1474- then {
1475- return true
1466+ if let TyKind :: Path ( QPath :: Resolved ( None , path) ) = slf. kind {
1467+ if let Res :: SelfTy ( ..) = path. res {
1468+ return true ;
14761469 }
14771470 }
14781471 false
@@ -2064,15 +2057,12 @@ macro_rules! unwrap_cargo_metadata {
20642057}
20652058
20662059pub fn is_hir_ty_cfg_dependant ( cx : & LateContext < ' _ > , ty : & hir:: Ty < ' _ > ) -> bool {
2067- if_chain ! {
2068- if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = ty. kind;
2069- if let Res :: Def ( _, def_id) = path. res;
2070- then {
2071- cx. tcx. has_attr( def_id, sym:: cfg) || cx. tcx. has_attr( def_id, sym:: cfg_attr)
2072- } else {
2073- false
2060+ if let TyKind :: Path ( QPath :: Resolved ( _, path) ) = ty. kind {
2061+ if let Res :: Def ( _, def_id) = path. res {
2062+ return cx. tcx . has_attr ( def_id, sym:: cfg) || cx. tcx . has_attr ( def_id, sym:: cfg_attr) ;
20742063 }
20752064 }
2065+ false
20762066}
20772067
20782068/// Checks whether item either has `test` attribute applied, or
@@ -2084,7 +2074,7 @@ pub fn is_test_module_or_function(tcx: TyCtxt<'_>, item: &Item<'_>) -> bool {
20842074 }
20852075 }
20862076
2087- matches ! ( item. kind, ItemKind :: Mod ( ..) ) && item. ident . name . as_str ( ) . contains ( "test" )
2077+ matches ! ( item. kind, ItemKind :: Mod ( ..) ) && item. ident . name . as_str ( ) . split ( '_' ) . any ( |a| a == "test" || a == "tests ")
20882078}
20892079
20902080macro_rules! op_utils {
0 commit comments