@@ -6,6 +6,7 @@ use std::ptr;
6
6
7
7
use clippy_utils:: diagnostics:: span_lint_and_then;
8
8
use clippy_utils:: in_constant;
9
+ use clippy_utils:: macros:: macro_backtrace;
9
10
use if_chain:: if_chain;
10
11
use rustc_hir:: def:: { DefKind , Res } ;
11
12
use rustc_hir:: def_id:: DefId ;
@@ -17,7 +18,7 @@ use rustc_middle::mir::interpret::{ConstValue, ErrorHandled};
17
18
use rustc_middle:: ty:: adjustment:: Adjust ;
18
19
use rustc_middle:: ty:: { self , Const , Ty } ;
19
20
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
20
- use rustc_span:: { InnerSpan , Span , DUMMY_SP } ;
21
+ use rustc_span:: { sym , InnerSpan , Span , DUMMY_SP } ;
21
22
use rustc_typeck:: hir_ty_to_ty;
22
23
23
24
// FIXME: this is a correctness problem but there's no suitable
@@ -250,8 +251,14 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
250
251
fn check_item ( & mut self , cx : & LateContext < ' tcx > , it : & ' tcx Item < ' _ > ) {
251
252
if let ItemKind :: Const ( hir_ty, body_id) = it. kind {
252
253
let ty = hir_ty_to_ty ( cx. tcx , hir_ty) ;
253
-
254
- if is_unfrozen ( cx, ty) && is_value_unfrozen_poly ( cx, body_id, ty) {
254
+ if !macro_backtrace ( it. span ) . last ( ) . map_or ( false , |macro_call| {
255
+ matches ! (
256
+ cx. tcx. get_diagnostic_name( macro_call. def_id) ,
257
+ Some ( sym:: thread_local_macro)
258
+ )
259
+ } ) && is_unfrozen ( cx, ty)
260
+ && is_value_unfrozen_poly ( cx, body_id, ty)
261
+ {
255
262
lint ( cx, Source :: Item { item : it. span } ) ;
256
263
}
257
264
}
0 commit comments