@@ -96,12 +96,12 @@ pub struct Argument<'a> {
96
96
#[ rustc_diagnostic_item = "ArgumentMethods" ]
97
97
impl Argument < ' _ > {
98
98
#[ inline]
99
- fn new < ' a , T > ( x : & ' a T , f : fn ( & T , & mut Formatter < ' _ > ) -> Result ) -> Argument < ' a > {
99
+ const fn new < ' a , T > ( x : & ' a T , f : fn ( & T , & mut Formatter < ' _ > ) -> Result ) -> Argument < ' a > {
100
100
Argument {
101
101
// INVARIANT: this creates an `ArgumentType<'a>` from a `&'a T` and
102
102
// a `fn(&T, ...)`, so the invariant is maintained.
103
103
ty : ArgumentType :: Placeholder {
104
- value : NonNull :: from ( x) . cast ( ) ,
104
+ value : NonNull :: from_ref ( x) . cast ( ) ,
105
105
// SAFETY: function pointers always have the same layout.
106
106
formatter : unsafe { mem:: transmute ( f) } ,
107
107
_lifetime : PhantomData ,
@@ -150,7 +150,7 @@ impl Argument<'_> {
150
150
Self :: new ( x, UpperExp :: fmt)
151
151
}
152
152
#[ inline]
153
- pub fn from_usize ( x : & usize ) -> Argument < ' _ > {
153
+ pub const fn from_usize ( x : & usize ) -> Argument < ' _ > {
154
154
Argument { ty : ArgumentType :: Count ( * x) }
155
155
}
156
156
@@ -181,7 +181,7 @@ impl Argument<'_> {
181
181
}
182
182
183
183
#[ inline]
184
- pub ( super ) fn as_usize ( & self ) -> Option < usize > {
184
+ pub ( super ) const fn as_usize ( & self ) -> Option < usize > {
185
185
match self . ty {
186
186
ArgumentType :: Count ( count) => Some ( count) ,
187
187
ArgumentType :: Placeholder { .. } => None ,
@@ -199,7 +199,7 @@ impl Argument<'_> {
199
199
/// println!("{f}");
200
200
/// ```
201
201
#[ inline]
202
- pub fn none ( ) -> [ Self ; 0 ] {
202
+ pub const fn none ( ) -> [ Self ; 0 ] {
203
203
[ ]
204
204
}
205
205
}
@@ -216,7 +216,7 @@ impl UnsafeArg {
216
216
/// See documentation where `UnsafeArg` is required to know when it is safe to
217
217
/// create and use `UnsafeArg`.
218
218
#[ inline]
219
- pub unsafe fn new ( ) -> Self {
219
+ pub const unsafe fn new ( ) -> Self {
220
220
Self { _private : ( ) }
221
221
}
222
222
}
0 commit comments