File tree 3 files changed +14
-0
lines changed 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,7 @@ check-cfg = [
259
259
' cfg(linux_kernel)' ,
260
260
' cfg(linux_like)' ,
261
261
' cfg(linux_raw)' ,
262
+ ' cfg(lower_upper_exp_for_non_zero)' ,
262
263
' cfg(netbsdlike)' ,
263
264
' cfg(rustc_attrs)' ,
264
265
' cfg(solarish)' ,
Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ fn main() {
79
79
use_feature ( "static_assertions" ) ;
80
80
}
81
81
82
+ // `LowerExp`/`UpperExp` for `NonZeroI32` etc.
83
+ if has_lower_upper_exp_for_non_zero ( ) {
84
+ use_feature ( "lower_upper_exp_for_non_zero" ) ;
85
+ }
86
+
82
87
// WASI support can utilize wasi_ext if present.
83
88
if os == "wasi" {
84
89
use_feature_or_nothing ( "wasi_ext" ) ;
@@ -188,6 +193,12 @@ fn use_thumb_mode() -> bool {
188
193
!can_compile ( "pub unsafe fn f() { core::arch::asm!(\" udf #16\" , in(\" r7\" ) 0); }" )
189
194
}
190
195
196
+ fn has_lower_upper_exp_for_non_zero ( ) -> bool {
197
+ // LowerExp/UpperExp for NonZero* were added in Rust 1.84.
198
+ // <https://doc.rust-lang.org/stable/std/fmt/trait.LowerExp.html#impl-LowerExp-for-NonZero%3CT%3E>
199
+ can_compile ( "fn a(x: &core::num::NonZeroI32, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { core::fmt::LowerExp::fmt(x, f) }" )
200
+ }
201
+
191
202
fn use_feature_or_nothing ( feature : & str ) {
192
203
if has_feature ( feature) {
193
204
use_feature ( feature) ;
Original file line number Diff line number Diff line change @@ -127,11 +127,13 @@ impl fmt::UpperHex for Pid {
127
127
self . 0 . fmt ( f)
128
128
}
129
129
}
130
+ #[ cfg( lower_upper_exp_for_non_zero) ]
130
131
impl fmt:: LowerExp for Pid {
131
132
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
132
133
self . 0 . fmt ( f)
133
134
}
134
135
}
136
+ #[ cfg( lower_upper_exp_for_non_zero) ]
135
137
impl fmt:: UpperExp for Pid {
136
138
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
137
139
self . 0 . fmt ( f)
You can’t perform that action at this time.
0 commit comments