@@ -6,6 +6,7 @@ use std::ptr;
66
77use clippy_utils:: diagnostics:: span_lint_and_then;
88use clippy_utils:: in_constant;
9+ use clippy_utils:: macros:: macro_backtrace;
910use if_chain:: if_chain;
1011use rustc_hir:: def:: { DefKind , Res } ;
1112use rustc_hir:: def_id:: DefId ;
@@ -17,7 +18,7 @@ use rustc_middle::mir::interpret::{ConstValue, ErrorHandled};
1718use rustc_middle:: ty:: adjustment:: Adjust ;
1819use rustc_middle:: ty:: { self , Const , Ty } ;
1920use 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 } ;
2122use rustc_typeck:: hir_ty_to_ty;
2223
2324// FIXME: this is a correctness problem but there's no suitable
@@ -250,8 +251,14 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
250251 fn check_item ( & mut self , cx : & LateContext < ' tcx > , it : & ' tcx Item < ' _ > ) {
251252 if let ItemKind :: Const ( hir_ty, body_id) = it. kind {
252253 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+ {
255262 lint ( cx, Source :: Item { item : it. span } ) ;
256263 }
257264 }
0 commit comments