@@ -2,7 +2,6 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
22use clippy_utils:: source:: { snippet_opt, snippet_with_context} ;
33use clippy_utils:: { fn_def_id, path_to_local_id} ;
44use if_chain:: if_chain;
5- use rustc_ast:: ast:: Attribute ;
65use rustc_errors:: Applicability ;
76use rustc_hir:: intravisit:: { walk_expr, FnKind , Visitor } ;
87use rustc_hir:: { Block , Body , Expr , ExprKind , FnDecl , HirId , MatchSource , PatKind , StmtKind } ;
@@ -11,7 +10,6 @@ use rustc_middle::lint::in_external_macro;
1110use rustc_middle:: ty:: subst:: GenericArgKind ;
1211use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
1312use rustc_span:: source_map:: Span ;
14- use rustc_span:: sym;
1513
1614declare_clippy_lint ! {
1715 /// ### What it does
@@ -152,10 +150,6 @@ impl<'tcx> LateLintPass<'tcx> for Return {
152150 }
153151}
154152
155- fn attr_is_cfg ( attr : & Attribute ) -> bool {
156- attr. meta_item_list ( ) . is_some ( ) && attr. has_name ( sym:: cfg)
157- }
158-
159153fn check_block_return < ' tcx > ( cx : & LateContext < ' tcx > , block : & Block < ' tcx > ) {
160154 if let Some ( expr) = block. expr {
161155 check_final_expr ( cx, expr, Some ( expr. span ) , RetReplacement :: Empty ) ;
@@ -178,9 +172,7 @@ fn check_final_expr<'tcx>(
178172 match expr. kind {
179173 // simple return is always "bad"
180174 ExprKind :: Ret ( ref inner) => {
181- // allow `#[cfg(a)] return a; #[cfg(b)] return b;`
182- let attrs = cx. tcx . hir ( ) . attrs ( expr. hir_id ) ;
183- if !attrs. iter ( ) . any ( attr_is_cfg) {
175+ if cx. tcx . hir ( ) . attrs ( expr. hir_id ) . is_empty ( ) {
184176 let borrows = inner. map_or ( false , |inner| last_statement_borrows ( cx, inner) ) ;
185177 if !borrows {
186178 emit_return_lint (
0 commit comments