@@ -21,41 +21,14 @@ use rustc::session::config::OptLevel;
2121use rustc:: ty:: { self , Ty , TyCtxt } ;
2222use rustc:: ty:: subst:: Substs ;
2323use syntax:: ast;
24- use syntax:: attr:: { self , InlineAttr } ;
24+ use syntax:: attr:: InlineAttr ;
2525use std:: fmt:: { self , Write } ;
2626use std:: iter;
2727use rustc:: mir:: mono:: Linkage ;
2828use syntax_pos:: symbol:: Symbol ;
2929use syntax:: codemap:: Span ;
3030pub use rustc:: mir:: mono:: MonoItem ;
3131
32- pub fn linkage_by_name ( name : & str ) -> Option < Linkage > {
33- use rustc:: mir:: mono:: Linkage :: * ;
34-
35- // Use the names from src/llvm/docs/LangRef.rst here. Most types are only
36- // applicable to variable declarations and may not really make sense for
37- // Rust code in the first place but whitelist them anyway and trust that
38- // the user knows what s/he's doing. Who knows, unanticipated use cases
39- // may pop up in the future.
40- //
41- // ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
42- // and don't have to be, LLVM treats them as no-ops.
43- match name {
44- "appending" => Some ( Appending ) ,
45- "available_externally" => Some ( AvailableExternally ) ,
46- "common" => Some ( Common ) ,
47- "extern_weak" => Some ( ExternalWeak ) ,
48- "external" => Some ( External ) ,
49- "internal" => Some ( Internal ) ,
50- "linkonce" => Some ( LinkOnceAny ) ,
51- "linkonce_odr" => Some ( LinkOnceODR ) ,
52- "private" => Some ( Private ) ,
53- "weak" => Some ( WeakAny ) ,
54- "weak_odr" => Some ( WeakODR ) ,
55- _ => None ,
56- }
57- }
58-
5932/// Describes how a translation item will be instantiated in object files.
6033#[ derive( PartialEq , Eq , Clone , Copy , Debug , Hash ) ]
6134pub enum InstantiationMode {
@@ -164,21 +137,8 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug {
164137 MonoItem :: GlobalAsm ( ..) => return None ,
165138 } ;
166139
167- let attributes = tcx. get_attrs ( def_id) ;
168- if let Some ( name) = attr:: first_attr_value_str_by_name ( & attributes, "linkage" ) {
169- if let Some ( linkage) = linkage_by_name ( & name. as_str ( ) ) {
170- Some ( linkage)
171- } else {
172- let span = tcx. hir . span_if_local ( def_id) ;
173- if let Some ( span) = span {
174- tcx. sess . span_fatal ( span, "invalid linkage specified" )
175- } else {
176- tcx. sess . fatal ( & format ! ( "invalid linkage specified: {}" , name) )
177- }
178- }
179- } else {
180- None
181- }
140+ let trans_fn_attrs = tcx. trans_fn_attrs ( def_id) ;
141+ trans_fn_attrs. linkage
182142 }
183143
184144 /// Returns whether this instance is instantiable - whether it has no unsatisfied
0 commit comments