Skip to content

Commit

Permalink
Fix 'hidden lifetime parameters in types are deprecated'
Browse files Browse the repository at this point in the history
  • Loading branch information
Enselic committed May 2, 2024
1 parent c49f64d commit 3475420
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 48 deletions.
2 changes: 1 addition & 1 deletion crates/examples/src/bin/dwarfdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum Error {

impl fmt::Display for Error {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> {
Debug::fmt(self, f)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use core::{fmt, ops};
// }
//
// impl fmt::Display for DwFoo {
// fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
// ...
// }
// }
Expand Down Expand Up @@ -83,7 +83,7 @@ macro_rules! dw {
}

impl fmt::Display for $struct_name {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
if let Some(s) = self.static_string() {
f.pad(s)
} else {
Expand Down
20 changes: 10 additions & 10 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<R: Reader> ParsedEhFrameHdr<R> {
}

/// Retrieves the CFI binary search table, if there is one.
pub fn table(&self) -> Option<EhHdrTable<R>> {
pub fn table(&self) -> Option<EhHdrTable<'_, R>> {
// There are two big edge cases here:
// * You search the table for an invalid address. As this is just a binary
// search table, we always have to return a valid result for that (unless
Expand Down Expand Up @@ -1245,7 +1245,7 @@ struct AugmentationData {
impl AugmentationData {
fn parse<R: Reader>(
augmentation: &Augmentation,
encoding_parameters: &PointerEncodingParameters<R>,
encoding_parameters: &PointerEncodingParameters<'_, R>,
input: &mut R,
) -> Result<AugmentationData> {
// In theory, we should be iterating over the original augmentation
Expand Down Expand Up @@ -1712,7 +1712,7 @@ impl<R: Reader> FrameDescriptionEntry<R> {
fn parse_addresses(
input: &mut R,
cie: &CommonInformationEntry<R>,
parameters: &PointerEncodingParameters<R>,
parameters: &PointerEncodingParameters<'_, R>,
) -> Result<(u64, u64)> {
let encoding = cie.augmentation().and_then(|a| a.fde_address_encoding);
if let Some(encoding) = encoding {
Expand Down Expand Up @@ -1990,7 +1990,7 @@ pub struct UnwindContext<T: ReaderOffset, A: UnwindContextStorage<T> = StoreOnHe
}

impl<T: ReaderOffset, S: UnwindContextStorage<T>> Debug for UnwindContext<T, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("UnwindContext")
.field("stack", &self.stack)
.field("initial_rule", &self.initial_rule)
Expand Down Expand Up @@ -2524,7 +2524,7 @@ struct RegisterRuleMap<T: ReaderOffset, S: UnwindContextStorage<T> = StoreOnHeap
}

impl<T: ReaderOffset, S: UnwindContextStorage<T>> Debug for RegisterRuleMap<T, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RegisterRuleMap")
.field("rules", &self.rules)
.finish()
Expand Down Expand Up @@ -2594,7 +2594,7 @@ impl<T: ReaderOffset, S: UnwindContextStorage<T>> RegisterRuleMap<T, S> {
.map_err(|_| Error::TooManyRegisterRules)
}

fn iter(&self) -> RegisterRuleIter<T> {
fn iter(&self) -> RegisterRuleIter<'_, T> {
RegisterRuleIter(self.rules.iter())
}
}
Expand Down Expand Up @@ -2671,7 +2671,7 @@ pub struct UnwindTableRow<T: ReaderOffset, S: UnwindContextStorage<T> = StoreOnH
}

impl<T: ReaderOffset, S: UnwindContextStorage<T>> Debug for UnwindTableRow<T, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("UnwindTableRow")
.field("start_address", &self.start_address)
.field("end_address", &self.end_address)
Expand Down Expand Up @@ -2812,7 +2812,7 @@ impl<T: ReaderOffset, S: UnwindContextStorage<T>> UnwindTableRow<T, S> {
/// }
/// # }
/// ```
pub fn registers(&self) -> RegisterRuleIter<T> {
pub fn registers(&self) -> RegisterRuleIter<'_, T> {
self.registers.iter()
}
}
Expand Down Expand Up @@ -3209,7 +3209,7 @@ impl<T: ReaderOffset> CallFrameInstruction<T> {
fn parse<R: Reader<Offset = T>>(
input: &mut R,
address_encoding: Option<DwEhPe>,
parameters: &PointerEncodingParameters<R>,
parameters: &PointerEncodingParameters<'_, R>,
vendor: Vendor,
) -> Result<CallFrameInstruction<T>> {
let instruction = input.read_u8()?;
Expand Down Expand Up @@ -3557,7 +3557,7 @@ struct PointerEncodingParameters<'a, R: Reader> {

fn parse_encoded_pointer<R: Reader>(
encoding: constants::DwEhPe,
parameters: &PointerEncodingParameters<R>,
parameters: &PointerEncodingParameters<'_, R>,
input: &mut R,
) -> Result<Pointer> {
// TODO: check this once only in parse_pointer_encoding
Expand Down
28 changes: 20 additions & 8 deletions src/read/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl<R: Reader> Dwarf<R> {
pub fn die_ranges(
&self,
unit: &Unit<R>,
entry: &DebuggingInformationEntry<R>,
entry: &DebuggingInformationEntry<'_, '_, R>,
) -> Result<RangeIter<R>> {
let mut low_pc = None;
let mut high_pc = None;
Expand Down Expand Up @@ -992,7 +992,7 @@ impl<R: Reader> DwarfPackage<R> {
/// This function should only be needed by low level parsers.
pub fn sections(
&self,
sections: UnitIndexSectionIterator<R>,
sections: UnitIndexSectionIterator<'_, R>,
parent: &Dwarf<R>,
) -> Result<Dwarf<R>> {
let mut abbrev_offset = 0;
Expand Down Expand Up @@ -1276,33 +1276,45 @@ impl<R: Reader> Unit<R> {
}

/// Read the `DebuggingInformationEntry` at the given offset.
pub fn entry(&self, offset: UnitOffset<R::Offset>) -> Result<DebuggingInformationEntry<R>> {
pub fn entry(
&self,
offset: UnitOffset<R::Offset>,
) -> Result<DebuggingInformationEntry<'_, '_, R>> {
self.header.entry(&self.abbreviations, offset)
}

/// Navigate this unit's `DebuggingInformationEntry`s.
#[inline]
pub fn entries(&self) -> EntriesCursor<R> {
pub fn entries(&self) -> EntriesCursor<'_, '_, R> {
self.header.entries(&self.abbreviations)
}

/// Navigate this unit's `DebuggingInformationEntry`s
/// starting at the given offset.
#[inline]
pub fn entries_at_offset(&self, offset: UnitOffset<R::Offset>) -> Result<EntriesCursor<R>> {
pub fn entries_at_offset(
&self,
offset: UnitOffset<R::Offset>,
) -> Result<EntriesCursor<'_, '_, R>> {
self.header.entries_at_offset(&self.abbreviations, offset)
}

/// Navigate this unit's `DebuggingInformationEntry`s as a tree
/// starting at the given offset.
#[inline]
pub fn entries_tree(&self, offset: Option<UnitOffset<R::Offset>>) -> Result<EntriesTree<R>> {
pub fn entries_tree(
&self,
offset: Option<UnitOffset<R::Offset>>,
) -> Result<EntriesTree<'_, '_, R>> {
self.header.entries_tree(&self.abbreviations, offset)
}

/// Read the raw data that defines the Debugging Information Entries.
#[inline]
pub fn entries_raw(&self, offset: Option<UnitOffset<R::Offset>>) -> Result<EntriesRaw<R>> {
pub fn entries_raw(
&self,
offset: Option<UnitOffset<R::Offset>>,
) -> Result<EntriesRaw<'_, '_, R>> {
self.header.entries_raw(&self.abbreviations, offset)
}

Expand Down Expand Up @@ -1466,7 +1478,7 @@ impl<'a, R: Reader> UnitRef<'a, R> {
/// Return an iterator for the address ranges of a `DebuggingInformationEntry`.
///
/// This uses `DW_AT_low_pc`, `DW_AT_high_pc` and `DW_AT_ranges`.
pub fn die_ranges(&self, entry: &DebuggingInformationEntry<R>) -> Result<RangeIter<R>> {
pub fn die_ranges(&self, entry: &DebuggingInformationEntry<'_, '_, R>) -> Result<RangeIter<R>> {
self.dwarf.die_ranges(self.unit, entry)
}

Expand Down
6 changes: 3 additions & 3 deletions src/read/endian_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,20 +448,20 @@ where
}

#[inline]
fn to_slice(&self) -> Result<Cow<[u8]>> {
fn to_slice(&self) -> Result<Cow<'_, [u8]>> {
Ok(self.bytes().into())
}

#[inline]
fn to_string(&self) -> Result<Cow<str>> {
fn to_string(&self) -> Result<Cow<'_, str>> {
match str::from_utf8(self.bytes()) {
Ok(s) => Ok(s.into()),
_ => Err(Error::BadUtf8),
}
}

#[inline]
fn to_string_lossy(&self) -> Result<Cow<str>> {
fn to_string_lossy(&self) -> Result<Cow<'_, str>> {
Ok(String::from_utf8_lossy(self.bytes()))
}

Expand Down
6 changes: 3 additions & 3 deletions src/read/endian_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ where

#[cfg(feature = "read")]
#[inline]
fn to_slice(&self) -> Result<Cow<[u8]>> {
fn to_slice(&self) -> Result<Cow<'_, [u8]>> {
Ok(self.slice.into())
}

#[cfg(feature = "read")]
#[inline]
fn to_string(&self) -> Result<Cow<str>> {
fn to_string(&self) -> Result<Cow<'_, str>> {
match str::from_utf8(self.slice) {
Ok(s) => Ok(s.into()),
_ => Err(Error::BadUtf8),
Expand All @@ -319,7 +319,7 @@ where

#[cfg(feature = "read")]
#[inline]
fn to_string_lossy(&self) -> Result<Cow<str>> {
fn to_string_lossy(&self) -> Result<Cow<'_, str>> {
Ok(String::from_utf8_lossy(self.slice))
}

Expand Down
2 changes: 1 addition & 1 deletion src/read/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<R: Reader> UnitIndex<R> {
}

/// Return the section offsets and sizes for the given row index.
pub fn sections(&self, mut row: u32) -> Result<UnitIndexSectionIterator<R>> {
pub fn sections(&self, mut row: u32) -> Result<UnitIndexSectionIterator<'_, R>> {
if row == 0 {
return Err(Error::InvalidIndexRow);
}
Expand Down
2 changes: 1 addition & 1 deletion src/read/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ where
R: Reader<Offset = Offset>,
Offset: ReaderOffset,
{
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> result::Result<(), fmt::Error> {
match *self {
LineInstruction::Special(opcode) => write!(f, "Special opcode {}", opcode),
LineInstruction::Copy => write!(f, "{}", constants::DW_LNS_copy),
Expand Down
2 changes: 1 addition & 1 deletion src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub enum Error {

impl fmt::Display for Error {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> ::core::result::Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> ::core::result::Result<(), fmt::Error> {
write!(f, "{}", self.description())
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/read/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub trait Reader: Debug + Clone {
///
/// Does not advance the reader.
#[cfg(feature = "read")]
fn to_slice(&self) -> Result<Cow<[u8]>>;
fn to_slice(&self) -> Result<Cow<'_, [u8]>>;

/// Convert all remaining data to a clone-on-write string.
///
Expand All @@ -285,7 +285,7 @@ pub trait Reader: Debug + Clone {
///
/// Returns an error if the data contains invalid characters.
#[cfg(feature = "read")]
fn to_string(&self) -> Result<Cow<str>>;
fn to_string(&self) -> Result<Cow<'_, str>>;

/// Convert all remaining data to a clone-on-write string, including invalid characters.
///
Expand All @@ -294,7 +294,7 @@ pub trait Reader: Debug + Clone {
///
/// Does not advance the reader.
#[cfg(feature = "read")]
fn to_string_lossy(&self) -> Result<Cow<str>>;
fn to_string_lossy(&self) -> Result<Cow<'_, str>>;

/// Read exactly `buf.len()` bytes into `buf`.
fn read_slice(&mut self, buf: &mut [u8]) -> Result<()>;
Expand Down
6 changes: 3 additions & 3 deletions src/read/relocate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ where

#[cfg(feature = "read")]
#[inline]
fn to_slice(&self) -> Result<Cow<[u8]>> {
fn to_slice(&self) -> Result<Cow<'_, [u8]>> {
self.reader.to_slice()
}

#[cfg(feature = "read")]
#[inline]
fn to_string(&self) -> Result<Cow<str>> {
fn to_string(&self) -> Result<Cow<'_, str>> {
self.reader.to_string()
}

#[cfg(feature = "read")]
#[inline]
fn to_string_lossy(&self) -> Result<Cow<str>> {
fn to_string_lossy(&self) -> Result<Cow<'_, str>> {
self.reader.to_string_lossy()
}

Expand Down
2 changes: 1 addition & 1 deletion src/read/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ValueType {
/// Construct a `ValueType` from a base type DIE.
#[cfg(feature = "read")]
pub fn from_entry<R: Reader>(
entry: &DebuggingInformationEntry<R>,
entry: &DebuggingInformationEntry<'_, '_, R>,
) -> Result<Option<ValueType>> {
if entry.tag() != constants::DW_TAG_base_type {
return Ok(None);
Expand Down
2 changes: 1 addition & 1 deletion src/write/loc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ mod convert {
/// Create a location list by reading the data from the give location list iter.
pub(crate) fn from<R: Reader<Offset = usize>>(
mut from: read::RawLocListIter<R>,
context: &ConvertUnitContext<R>,
context: &ConvertUnitContext<'_, R>,
) -> ConvertResult<Self> {
let mut have_base_address = context.base_address != Address::Constant(0);
let convert_address =
Expand Down
4 changes: 2 additions & 2 deletions src/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub enum Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> result::Result<(), fmt::Error> {
match *self {
Error::OffsetOutOfBounds => write!(f, "The given offset is out of bounds."),
Error::LengthOutOfBounds => write!(f, "The given length is out of bounds."),
Expand Down Expand Up @@ -364,7 +364,7 @@ mod convert {
}

impl fmt::Display for ConvertError {
fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> result::Result<(), fmt::Error> {
use self::ConvertError::*;
match *self {
Read(ref e) => e.fmt(f),
Expand Down
2 changes: 1 addition & 1 deletion src/write/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod convert {
/// Create a range list by reading the data from the give range list iter.
pub(crate) fn from<R: Reader<Offset = usize>>(
mut from: read::RawRngListIter<R>,
context: &ConvertUnitContext<R>,
context: &ConvertUnitContext<'_, R>,
) -> ConvertResult<Self> {
let mut have_base_address = context.base_address != Address::Constant(0);
let convert_address =
Expand Down
Loading

0 comments on commit 3475420

Please sign in to comment.