@@ -102,7 +102,7 @@ fn check_and_apply_linkage(
102102 attrs : & CodegenFnAttrs ,
103103 ty : Ty < ' tcx > ,
104104 sym : LocalInternedString ,
105- span : Option < Span >
105+ span : Span
106106) -> & ' ll Value {
107107 let llty = cx. layout_of ( ty) . llvm_type ( cx) ;
108108 if let Some ( linkage) = attrs. linkage {
@@ -116,11 +116,7 @@ fn check_and_apply_linkage(
116116 let llty2 = if let ty:: RawPtr ( ref mt) = ty. sty {
117117 cx. layout_of ( mt. ty ) . llvm_type ( cx)
118118 } else {
119- if let Some ( span) = span {
120- cx. sess ( ) . span_fatal ( span, "must have type `*const T` or `*mut T`" )
121- } else {
122- bug ! ( "must have type `*const T` or `*mut T`" )
123- }
119+ cx. sess ( ) . span_fatal ( span, "must have type `*const T` or `*mut T`" )
124120 } ;
125121 unsafe {
126122 // Declare a symbol `foo` with the desired linkage.
@@ -136,14 +132,7 @@ fn check_and_apply_linkage(
136132 let mut real_name = "_rust_extern_with_linkage_" . to_string ( ) ;
137133 real_name. push_str ( & sym) ;
138134 let g2 = cx. define_global ( & real_name, llty) . unwrap_or_else ( ||{
139- if let Some ( span) = span {
140- cx. sess ( ) . span_fatal (
141- span,
142- & format ! ( "symbol `{}` is already defined" , & sym)
143- )
144- } else {
145- bug ! ( "symbol `{}` is already defined" , & sym)
146- }
135+ cx. sess ( ) . span_fatal ( span, & format ! ( "symbol `{}` is already defined" , & sym) )
147136 } ) ;
148137 llvm:: LLVMRustSetLinkage ( g2, llvm:: Linkage :: InternalLinkage ) ;
149138 llvm:: LLVMSetInitializer ( g2, g1) ;
@@ -240,7 +229,7 @@ impl CodegenCx<'ll, 'tcx> {
240229 ref attrs, span, node : hir:: ForeignItemKind :: Static ( ..) , ..
241230 } ) => {
242231 let fn_attrs = self . tcx . codegen_fn_attrs ( def_id) ;
243- ( check_and_apply_linkage ( & self , & fn_attrs, ty, sym, Some ( span) ) , attrs)
232+ ( check_and_apply_linkage ( & self , & fn_attrs, ty, sym, span) , attrs)
244233 }
245234
246235 item => bug ! ( "get_static: expected static, found {:?}" , item)
@@ -260,7 +249,8 @@ impl CodegenCx<'ll, 'tcx> {
260249 debug ! ( "get_static: sym={} item_attr={:?}" , sym, self . tcx. item_attrs( def_id) ) ;
261250
262251 let attrs = self . tcx . codegen_fn_attrs ( def_id) ;
263- let g = check_and_apply_linkage ( & self , & attrs, ty, sym, None ) ;
252+ let span = self . tcx . def_span ( def_id) ;
253+ let g = check_and_apply_linkage ( & self , & attrs, ty, sym, span) ;
264254
265255 // Thread-local statics in some other crate need to *always* be linked
266256 // against in a thread-local fashion, so we need to be sure to apply the
0 commit comments