@@ -2735,9 +2735,9 @@ impl PpMode {
27352735crate mod dep_tracking {
27362736 use super :: {
27372737 BranchProtection , CFGuard , CFProtection , CrateType , DebugInfo , ErrorOutputType ,
2738- InstrumentCoverage , LdImpl , LinkerPluginLto , LocationDetail , LtoCli , OptLevel , OutputType ,
2739- OutputTypes , Passes , SourceFileHashAlgorithm , SwitchWithOptPath , SymbolManglingVersion ,
2740- TrimmedDefPaths ,
2738+ InstrumentCoverage , LdImpl , LinkerPluginLto , LocationDetail , LtoCli , OomStrategy , OptLevel ,
2739+ OutputType , OutputTypes , Passes , SourceFileHashAlgorithm , SwitchWithOptPath ,
2740+ SymbolManglingVersion , TrimmedDefPaths ,
27412741 } ;
27422742 use crate :: lint;
27432743 use crate :: options:: WasiExecModel ;
@@ -2833,6 +2833,7 @@ crate mod dep_tracking {
28332833 RealFileName ,
28342834 LocationDetail ,
28352835 BranchProtection ,
2836+ OomStrategy ,
28362837 ) ;
28372838
28382839 impl < T1 , T2 > DepTrackingHash for ( T1 , T2 )
@@ -2922,3 +2923,24 @@ crate mod dep_tracking {
29222923 }
29232924 }
29242925}
2926+
2927+ /// Default behavior to use in out-of-memory situations.
2928+ #[ derive( Clone , Copy , PartialEq , Hash , Debug , Encodable , Decodable , HashStable_Generic ) ]
2929+ pub enum OomStrategy {
2930+ /// Generate a panic that can be caught by `catch_unwind`.
2931+ Panic ,
2932+
2933+ /// Abort the process immediately.
2934+ Abort ,
2935+ }
2936+
2937+ impl OomStrategy {
2938+ pub const SYMBOL : & ' static str = "__rust_alloc_error_handler_should_panic" ;
2939+
2940+ pub fn should_panic ( self ) -> u8 {
2941+ match self {
2942+ OomStrategy :: Panic => 1 ,
2943+ OomStrategy :: Abort => 0 ,
2944+ }
2945+ }
2946+ }
0 commit comments