@@ -5,6 +5,7 @@ use rustc_abi::{
5
5
} ;
6
6
use rustc_codegen_ssa:: common;
7
7
use rustc_codegen_ssa:: traits:: * ;
8
+ use rustc_hir:: LangItem ;
8
9
use rustc_hir:: def:: DefKind ;
9
10
use rustc_hir:: def_id:: DefId ;
10
11
use rustc_middle:: middle:: codegen_fn_attrs:: { CodegenFnAttrFlags , CodegenFnAttrs } ;
@@ -16,7 +17,6 @@ use rustc_middle::mir::mono::{Linkage, MonoItem};
16
17
use rustc_middle:: ty:: layout:: { HasTypingEnv , LayoutOf } ;
17
18
use rustc_middle:: ty:: { self , Instance } ;
18
19
use rustc_middle:: { bug, span_bug} ;
19
- use rustc_span:: sym;
20
20
use tracing:: { debug, instrument, trace} ;
21
21
22
22
use crate :: common:: { AsCCharPtr , CodegenCx } ;
@@ -180,9 +180,9 @@ fn check_and_apply_linkage<'ll, 'tcx>(
180
180
// instead of an extern_weak i8.
181
181
let instance = Instance :: mono ( cx. tcx , def_id) ;
182
182
if let ty:: Adt ( struct_def, generic_args) = instance. ty ( cx. tcx , cx. typing_env ( ) ) . kind ( )
183
- && matches ! ( cx. tcx. get_diagnostic_name ( struct_def. did( ) ) , Some ( sym :: Option ) )
184
- && generic_args . len ( ) == 1
185
- && let ty:: FnPtr ( sig, header) = generic_args . first ( ) . unwrap ( ) . expect_ty ( ) . kind ( )
183
+ && let Some ( LangItem :: Option ) = cx. tcx . lang_items ( ) . from_def_id ( struct_def. did ( ) )
184
+ && let Some ( first_arg ) = generic_args . first ( )
185
+ && let ty:: FnPtr ( sig, header) = first_arg . expect_ty ( ) . kind ( )
186
186
{
187
187
let fn_sig = sig. with ( * header) ;
188
188
0 commit comments