@@ -2,7 +2,6 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
2
2
use clippy_utils:: source:: { snippet_opt, snippet_with_context} ;
3
3
use clippy_utils:: { fn_def_id, path_to_local_id} ;
4
4
use if_chain:: if_chain;
5
- use rustc_ast:: ast:: Attribute ;
6
5
use rustc_errors:: Applicability ;
7
6
use rustc_hir:: intravisit:: { walk_expr, FnKind , Visitor } ;
8
7
use rustc_hir:: { Block , Body , Expr , ExprKind , FnDecl , HirId , MatchSource , PatKind , StmtKind } ;
@@ -11,7 +10,6 @@ use rustc_middle::lint::in_external_macro;
11
10
use rustc_middle:: ty:: subst:: GenericArgKind ;
12
11
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
13
12
use rustc_span:: source_map:: Span ;
14
- use rustc_span:: sym;
15
13
16
14
declare_clippy_lint ! {
17
15
/// ### What it does
@@ -152,10 +150,6 @@ impl<'tcx> LateLintPass<'tcx> for Return {
152
150
}
153
151
}
154
152
155
- fn attr_is_cfg ( attr : & Attribute ) -> bool {
156
- attr. meta_item_list ( ) . is_some ( ) && attr. has_name ( sym:: cfg)
157
- }
158
-
159
153
fn check_block_return < ' tcx > ( cx : & LateContext < ' tcx > , block : & Block < ' tcx > ) {
160
154
if let Some ( expr) = block. expr {
161
155
check_final_expr ( cx, expr, Some ( expr. span ) , RetReplacement :: Empty ) ;
@@ -178,9 +172,7 @@ fn check_final_expr<'tcx>(
178
172
match expr. kind {
179
173
// simple return is always "bad"
180
174
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 ( ) {
184
176
let borrows = inner. map_or ( false , |inner| last_statement_borrows ( cx, inner) ) ;
185
177
if !borrows {
186
178
emit_return_lint (
0 commit comments