@@ -25,6 +25,7 @@ impl Error {
25
25
/// created here to ensure that a backtrace exists.
26
26
#[ cfg( feature = "std" ) ]
27
27
#[ cfg_attr( doc_cfg, doc( cfg( feature = "std" ) ) ) ]
28
+ #[ cold]
28
29
pub fn new < E > ( error : E ) -> Self
29
30
where
30
31
E : StdError + Send + Sync + ' static ,
@@ -70,6 +71,7 @@ impl Error {
70
71
/// .await
71
72
/// }
72
73
/// ```
74
+ #[ cold]
73
75
pub fn msg < M > ( message : M ) -> Self
74
76
where
75
77
M : Display + Debug + Send + Sync + ' static ,
@@ -78,6 +80,7 @@ impl Error {
78
80
}
79
81
80
82
#[ cfg( feature = "std" ) ]
83
+ #[ cold]
81
84
pub ( crate ) fn from_std < E > ( error : E , backtrace : Option < Backtrace > ) -> Self
82
85
where
83
86
E : StdError + Send + Sync + ' static ,
@@ -100,6 +103,7 @@ impl Error {
100
103
unsafe { Error :: construct ( error, vtable, backtrace) }
101
104
}
102
105
106
+ #[ cold]
103
107
pub ( crate ) fn from_adhoc < M > ( message : M , backtrace : Option < Backtrace > ) -> Self
104
108
where
105
109
M : Display + Debug + Send + Sync + ' static ,
@@ -125,6 +129,7 @@ impl Error {
125
129
unsafe { Error :: construct ( error, vtable, backtrace) }
126
130
}
127
131
132
+ #[ cold]
128
133
pub ( crate ) fn from_display < M > ( message : M , backtrace : Option < Backtrace > ) -> Self
129
134
where
130
135
M : Display + Send + Sync + ' static ,
@@ -151,6 +156,7 @@ impl Error {
151
156
}
152
157
153
158
#[ cfg( feature = "std" ) ]
159
+ #[ cold]
154
160
pub ( crate ) fn from_context < C , E > ( context : C , error : E , backtrace : Option < Backtrace > ) -> Self
155
161
where
156
162
C : Display + Send + Sync + ' static ,
@@ -177,6 +183,7 @@ impl Error {
177
183
}
178
184
179
185
#[ cfg( feature = "std" ) ]
186
+ #[ cold]
180
187
pub ( crate ) fn from_boxed (
181
188
error : Box < dyn StdError + Send + Sync > ,
182
189
backtrace : Option < Backtrace > ,
@@ -207,6 +214,7 @@ impl Error {
207
214
//
208
215
// Unsafe because the given vtable must have sensible behavior on the error
209
216
// value of type E.
217
+ #[ cold]
210
218
unsafe fn construct < E > (
211
219
error : E ,
212
220
vtable : & ' static ErrorVTable ,
@@ -284,6 +292,7 @@ impl Error {
284
292
/// })
285
293
/// }
286
294
/// ```
295
+ #[ cold]
287
296
pub fn context < C > ( self , context : C ) -> Self
288
297
where
289
298
C : Display + Send + Sync + ' static ,
@@ -373,6 +382,7 @@ impl Error {
373
382
/// ```
374
383
#[ cfg( feature = "std" ) ]
375
384
#[ cfg_attr( doc_cfg, doc( cfg( feature = "std" ) ) ) ]
385
+ #[ cold]
376
386
pub fn chain ( & self ) -> Chain {
377
387
unsafe { ErrorImpl :: chain ( self . inner . by_ref ( ) ) }
378
388
}
@@ -515,6 +525,7 @@ impl<E> From<E> for Error
515
525
where
516
526
E : StdError + Send + Sync + ' static ,
517
527
{
528
+ #[ cold]
518
529
fn from ( error : E ) -> Self {
519
530
let backtrace = backtrace_if_absent ! ( error) ;
520
531
Error :: from_std ( error, backtrace)
@@ -879,6 +890,7 @@ impl ErrorImpl {
879
890
. expect ( "backtrace capture failed" )
880
891
}
881
892
893
+ #[ cold]
882
894
pub ( crate ) unsafe fn chain ( this : Ref < Self > ) -> Chain {
883
895
Chain :: new ( Self :: error ( this) )
884
896
}
@@ -917,6 +929,7 @@ where
917
929
}
918
930
919
931
impl From < Error > for Box < dyn StdError + Send + Sync + ' static > {
932
+ #[ cold]
920
933
fn from ( error : Error ) -> Self {
921
934
let outer = ManuallyDrop :: new ( error) ;
922
935
unsafe {
0 commit comments