Rollup merge of #131697 - ShE3py:rt-arg-lifetimes, r=Amanieu

`rt::Argument`: elide lifetimes

`@rustbot` label +C-cleanup
This commit is contained in:
Jubilee 2024-10-21 20:32:01 -07:00 committed by GitHub
commit 763fbf8a90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 16 deletions

View File

@ -94,11 +94,11 @@ pub struct Argument<'a> {
} }
#[rustc_diagnostic_item = "ArgumentMethods"] #[rustc_diagnostic_item = "ArgumentMethods"]
impl<'a> Argument<'a> { impl Argument<'_> {
#[inline(always)] #[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 { 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. // a `fn(&T, ...)`, so the invariant is maintained.
ty: ArgumentType::Placeholder { ty: ArgumentType::Placeholder {
value: NonNull::from(x).cast(), value: NonNull::from(x).cast(),
@ -110,43 +110,43 @@ impl<'a> Argument<'a> {
} }
#[inline(always)] #[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) Self::new(x, Display::fmt)
} }
#[inline(always)] #[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) Self::new(x, Debug::fmt)
} }
#[inline(always)] #[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(())) Self::new(x, |_, _| Ok(()))
} }
#[inline(always)] #[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) Self::new(x, Octal::fmt)
} }
#[inline(always)] #[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) Self::new(x, LowerHex::fmt)
} }
#[inline(always)] #[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) Self::new(x, UpperHex::fmt)
} }
#[inline(always)] #[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) Self::new(x, Pointer::fmt)
} }
#[inline(always)] #[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) Self::new(x, Binary::fmt)
} }
#[inline(always)] #[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) Self::new(x, LowerExp::fmt)
} }
#[inline(always)] #[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) Self::new(x, UpperExp::fmt)
} }
#[inline(always)] #[inline(always)]

View File

@ -17,7 +17,7 @@ LL | println!("{:?}", foo);
| required by a bound introduced by this call | required by a bound introduced by this call
| |
= help: the trait `Sized` is not implemented for `dyn Foo` = 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 --> $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) = 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: required for `[i32; _]` to implement `Debug`
= note: 1 redundant requirement hidden = note: 1 redundant requirement hidden
= note: required for `&mut [i32; _]` to implement `Debug` = 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 --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
help: consider specifying the generic arguments help: consider specifying the generic arguments
| |

View File

@ -17,7 +17,7 @@ LL | format!("{:X}", "3");
i32 i32
and 9 others and 9 others
= note: required for `&str` to implement `UpperHex` = 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 --> $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) = 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)