@@ -16,7 +16,7 @@ use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash};
1616use rustc_span:: def_id:: DefId ;
1717use rustc_span:: hygiene:: Transparency ;
1818use rustc_span:: { ErrorGuaranteed , Ident , Span , Symbol } ;
19- use rustc_structures:: { Limit , SanitizerSet } ;
19+ use rustc_structures:: { CrateType , Limit , SanitizerSet } ;
2020use thin_vec:: ThinVec ;
2121
2222pub use crate :: canonical_symbols:: { CanonicalSymbol , CanonicalSymbols } ;
@@ -691,108 +691,6 @@ pub enum CollapseMacroDebuginfo {
691691 Yes = 3 ,
692692}
693693
694- /// Crate type, as specified by `#![crate_type]`
695- #[ derive( Copy , Clone , Debug , Hash , PartialEq , Default , PartialOrd , Eq , Ord ) ]
696- #[ derive( StableHash , Encodable , Decodable , PrintAttribute ) ]
697- pub enum CrateType {
698- /// `#![crate_type = "bin"]`
699- Executable ,
700- /// `#![crate_type = "dylib"]`
701- Dylib ,
702- /// `#![crate_type = "rlib"]` or `#![crate_type = "lib"]`
703- #[ default]
704- Rlib ,
705- /// `#![crate_type = "staticlib"]`
706- StaticLib ,
707- /// `#![crate_type = "cdylib"]`
708- Cdylib ,
709- /// `#![crate_type = "proc-macro"]`
710- ProcMacro ,
711- /// `#![crate_type = "sdylib"]`
712- // Unstable; feature(export_stable)
713- Sdylib ,
714- }
715-
716- impl CrateType {
717- /// Pairs of each `#[crate_type] = "..."` value and the crate type it resolves to
718- pub fn all ( ) -> & ' static [ ( Symbol , Self ) ] {
719- debug_assert_eq ! ( CrateType :: default ( ) , CrateType :: Rlib ) ;
720- & [
721- ( rustc_span:: sym:: lib, CrateType :: Rlib ) ,
722- ( rustc_span:: sym:: rlib, CrateType :: Rlib ) ,
723- ( rustc_span:: sym:: dylib, CrateType :: Dylib ) ,
724- ( rustc_span:: sym:: cdylib, CrateType :: Cdylib ) ,
725- ( rustc_span:: sym:: staticlib, CrateType :: StaticLib ) ,
726- ( rustc_span:: sym:: proc_dash_macro, CrateType :: ProcMacro ) ,
727- ( rustc_span:: sym:: bin, CrateType :: Executable ) ,
728- ( rustc_span:: sym:: sdylib, CrateType :: Sdylib ) ,
729- ]
730- }
731-
732- /// Same as [`CrateType::all`], but does not include unstable options.
733- /// Used for diagnostics.
734- pub fn all_stable ( ) -> & ' static [ ( Symbol , Self ) ] {
735- debug_assert_eq ! ( CrateType :: default ( ) , CrateType :: Rlib ) ;
736- & [
737- ( rustc_span:: sym:: lib, CrateType :: Rlib ) ,
738- ( rustc_span:: sym:: rlib, CrateType :: Rlib ) ,
739- ( rustc_span:: sym:: dylib, CrateType :: Dylib ) ,
740- ( rustc_span:: sym:: cdylib, CrateType :: Cdylib ) ,
741- ( rustc_span:: sym:: staticlib, CrateType :: StaticLib ) ,
742- ( rustc_span:: sym:: proc_dash_macro, CrateType :: ProcMacro ) ,
743- ( rustc_span:: sym:: bin, CrateType :: Executable ) ,
744- ]
745- }
746-
747- pub fn has_metadata ( self ) -> bool {
748- match self {
749- CrateType :: Rlib | CrateType :: Dylib | CrateType :: ProcMacro => true ,
750- CrateType :: Executable
751- | CrateType :: Cdylib
752- | CrateType :: StaticLib
753- | CrateType :: Sdylib => false ,
754- }
755- }
756- }
757-
758- impl TryFrom < Symbol > for CrateType {
759- type Error = ( ) ;
760-
761- fn try_from ( value : Symbol ) -> Result < Self , Self :: Error > {
762- Ok ( match value {
763- rustc_span:: sym:: bin => CrateType :: Executable ,
764- rustc_span:: sym:: dylib => CrateType :: Dylib ,
765- rustc_span:: sym:: staticlib => CrateType :: StaticLib ,
766- rustc_span:: sym:: cdylib => CrateType :: Cdylib ,
767- rustc_span:: sym:: rlib => CrateType :: Rlib ,
768- rustc_span:: sym:: lib => CrateType :: default ( ) ,
769- rustc_span:: sym:: proc_dash_macro => CrateType :: ProcMacro ,
770- rustc_span:: sym:: sdylib => CrateType :: Sdylib ,
771- _ => return Err ( ( ) ) ,
772- } )
773- }
774- }
775-
776- impl std:: fmt:: Display for CrateType {
777- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
778- match * self {
779- CrateType :: Executable => "bin" . fmt ( f) ,
780- CrateType :: Dylib => "dylib" . fmt ( f) ,
781- CrateType :: Rlib => "rlib" . fmt ( f) ,
782- CrateType :: StaticLib => "staticlib" . fmt ( f) ,
783- CrateType :: Cdylib => "cdylib" . fmt ( f) ,
784- CrateType :: ProcMacro => "proc-macro" . fmt ( f) ,
785- CrateType :: Sdylib => "sdylib" . fmt ( f) ,
786- }
787- }
788- }
789-
790- impl IntoDiagArg for CrateType {
791- fn into_diag_arg ( self , _: & mut Option < std:: path:: PathBuf > ) -> DiagArgValue {
792- self . to_string ( ) . into_diag_arg ( & mut None )
793- }
794- }
795-
796694#[ derive( Clone , Debug , StableHash , Encodable , Decodable , PrintAttribute ) ]
797695pub enum RustcDumpLayoutKind {
798696 Align ,
0 commit comments