File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5252//! * Using [`ExitCode`] is not recommended but can be useful for converting utils to use
5353//! [`UResult`].
5454
55- // spell-checker:ignore uioerror rustdoc
55+ // spell-checker:ignore codegen-units uioerror rustdoc
5656
5757use std:: {
5858 cell:: Cell ,
@@ -394,13 +394,20 @@ impl UIoError {
394394 #[ allow( clippy:: new_ret_no_self) ]
395395 /// Create a new `UIoError` with a given exit code and message.
396396 pub fn new < S : Into < String > > ( kind : std:: io:: ErrorKind , context : S ) -> Box < dyn UError > {
397- Box :: new ( Self {
398- context : Some ( context. into ( ) ) ,
399- inner : kind. into ( ) ,
400- } )
397+ cold_io_error ( kind, context. into ( ) )
401398 }
402399}
403400
401+ // avoid performance regression with codegen-units=1
402+ #[ cold]
403+ #[ inline( never) ]
404+ fn cold_io_error ( kind : std:: io:: ErrorKind , context : String ) -> Box < dyn UError > {
405+ Box :: new ( UIoError {
406+ context : Some ( context) ,
407+ inner : kind. into ( ) ,
408+ } )
409+ }
410+
404411impl UError for UIoError { }
405412
406413impl Error for UIoError { }
You can’t perform that action at this time.
0 commit comments