rt::Argument: elide lifetimes

This commit is contained in:
Lieselotte 2024-10-14 20:24:30 +02:00
parent 17a19e684c
commit 1364631584
No known key found for this signature in database
GPG Key ID: 68A9A951C7E1F283
4 changed files with 16 additions and 16 deletions

View File

@ -94,11 +94,11 @@ pub struct Argument<'a> {
}
#[rustc_diagnostic_item = "ArgumentMethods"]
impl<'a> Argument<'a> {
impl Argument<'_> {
#[inline(always)]
fn new<'b, T>(x: &'b T, f: fn(&T, &mut Formatter<'_>) -> Result) -> Argument<'b> {
fn new<'a, T>(x: &'a T, f: fn(&T, &mut Formatter<'_>) -> Result) -> Argument<'a> {
Argument {
// INVARIANT: this creates an `ArgumentType<'b>` from a `&'b T` and
// INVARIANT: this creates an `ArgumentType<'a>` from a `&'a T` and
// a `fn(&T, ...)`, so the invariant is maintained.
ty: ArgumentType::Placeholder {
value: NonNull::from(x).cast(),
@ -110,43 +110,43 @@ impl<'a> Argument<'a> {
}
#[inline(always)]
pub fn new_display<'b, T: Display>(x: &'b T) -> Argument<'b> {
pub fn new_display<T: Display>(x: &T) -> Argument<'_> {
Self::new(x, Display::fmt)
}
#[inline(always)]
pub fn new_debug<'b, T: Debug>(x: &'b T) -> Argument<'b> {
pub fn new_debug<T: Debug>(x: &T) -> Argument<'_> {
Self::new(x, Debug::fmt)
}
#[inline(always)]
pub fn new_debug_noop<'b, T: Debug>(x: &'b T) -> Argument<'b> {
pub fn new_debug_noop<T: Debug>(x: &T) -> Argument<'_> {
Self::new(x, |_, _| Ok(()))
}
#[inline(always)]
pub fn new_octal<'b, T: Octal>(x: &'b T) -> Argument<'b> {
pub fn new_octal<T: Octal>(x: &T) -> Argument<'_> {
Self::new(x, Octal::fmt)
}
#[inline(always)]
pub fn new_lower_hex<'b, T: LowerHex>(x: &'b T) -> Argument<'b> {
pub fn new_lower_hex<T: LowerHex>(x: &T) -> Argument<'_> {
Self::new(x, LowerHex::fmt)
}
#[inline(always)]
pub fn new_upper_hex<'b, T: UpperHex>(x: &'b T) -> Argument<'b> {
pub fn new_upper_hex<T: UpperHex>(x: &T) -> Argument<'_> {
Self::new(x, UpperHex::fmt)
}
#[inline(always)]
pub fn new_pointer<'b, T: Pointer>(x: &'b T) -> Argument<'b> {
pub fn new_pointer<T: Pointer>(x: &T) -> Argument<'_> {
Self::new(x, Pointer::fmt)
}
#[inline(always)]
pub fn new_binary<'b, T: Binary>(x: &'b T) -> Argument<'b> {
pub fn new_binary<T: Binary>(x: &T) -> Argument<'_> {
Self::new(x, Binary::fmt)
}
#[inline(always)]
pub fn new_lower_exp<'b, T: LowerExp>(x: &'b T) -> Argument<'b> {
pub fn new_lower_exp<T: LowerExp>(x: &T) -> Argument<'_> {
Self::new(x, LowerExp::fmt)
}
#[inline(always)]
pub fn new_upper_exp<'b, T: UpperExp>(x: &'b T) -> Argument<'b> {
pub fn new_upper_exp<T: UpperExp>(x: &T) -> Argument<'_> {
Self::new(x, UpperExp::fmt)
}
#[inline(always)]

View File

@ -17,7 +17,7 @@ LL | println!("{:?}", foo);
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `dyn Foo`
note: required by an implicit `Sized` bound in `core::fmt::rt::Argument::<'a>::new_debug`
note: required by an implicit `Sized` bound in `core::fmt::rt::Argument::<'_>::new_debug`
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -25,7 +25,7 @@ LL | println!("{:?}", take_array_from_mut(&mut arr, i));
= note: required for `[i32; _]` to implement `Debug`
= note: 1 redundant requirement hidden
= note: required for `&mut [i32; _]` to implement `Debug`
note: required by a bound in `core::fmt::rt::Argument::<'a>::new_debug`
note: required by a bound in `core::fmt::rt::Argument::<'_>::new_debug`
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
help: consider specifying the generic arguments
|

View File

@ -17,7 +17,7 @@ LL | format!("{:X}", "3");
i32
and 9 others
= note: required for `&str` to implement `UpperHex`
note: required by a bound in `core::fmt::rt::Argument::<'a>::new_upper_hex`
note: required by a bound in `core::fmt::rt::Argument::<'_>::new_upper_hex`
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
= note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)