Skip to content

Commit

Permalink
Fix 'hidden lifetime parameters in types are deprecated' (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
Enselic authored May 4, 2024
1 parent c49f64d commit b921aa3
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 80 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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#![warn(bare_trait_objects)]
#![warn(unused_extern_crates)]
#![warn(ellipsis_inclusive_range_patterns)]
//#![warn(elided_lifetimes_in_paths)]
#![warn(elided_lifetimes_in_paths)]
#![warn(explicit_outlives_requirements)]
// Style.
#![allow(clippy::bool_to_int_with_if)]
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
32 changes: 22 additions & 10 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 Expand Up @@ -1634,8 +1646,8 @@ mod tests {
#[test]
fn test_send() {
fn assert_is_send<T: Send>() {}
assert_is_send::<Dwarf<EndianSlice<LittleEndian>>>();
assert_is_send::<Unit<EndianSlice<LittleEndian>>>();
assert_is_send::<Dwarf<EndianSlice<'_, LittleEndian>>>();
assert_is_send::<Unit<EndianSlice<'_, LittleEndian>>>();
}

#[test]
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
14 changes: 7 additions & 7 deletions 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 Expand Up @@ -2124,8 +2124,8 @@ mod tests {
const STANDARD_OPCODE_LENGTHS: &[u8] = &[0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1];

fn make_test_header(
buf: EndianSlice<LittleEndian>,
) -> LineProgramHeader<EndianSlice<LittleEndian>> {
buf: EndianSlice<'_, LittleEndian>,
) -> LineProgramHeader<EndianSlice<'_, LittleEndian>> {
let encoding = Encoding {
format: Format::Dwarf32,
version: 4,
Expand Down Expand Up @@ -2170,8 +2170,8 @@ mod tests {
}

fn make_test_program(
buf: EndianSlice<LittleEndian>,
) -> IncompleteLineProgram<EndianSlice<LittleEndian>> {
buf: EndianSlice<'_, LittleEndian>,
) -> IncompleteLineProgram<EndianSlice<'_, LittleEndian>> {
IncompleteLineProgram {
header: make_test_header(buf),
}
Expand All @@ -2198,7 +2198,7 @@ mod tests {
fn test<Operands>(
raw: constants::DwLns,
operands: Operands,
expected: LineInstruction<EndianSlice<LittleEndian>>,
expected: LineInstruction<EndianSlice<'_, LittleEndian>>,
) where
Operands: AsRef<[u8]>,
{
Expand Down Expand Up @@ -2341,7 +2341,7 @@ mod tests {
fn test<Operands>(
raw: constants::DwLne,
operands: Operands,
expected: LineInstruction<EndianSlice<LittleEndian>>,
expected: LineInstruction<EndianSlice<'_, LittleEndian>>,
) where
Operands: AsRef<[u8]>,
{
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/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,7 @@ mod tests {

fn check_op_parse<F>(
input: F,
expect: &Operation<EndianSlice<LittleEndian>>,
expect: &Operation<EndianSlice<'_, LittleEndian>>,
encoding: Encoding,
) where
F: Fn(Section) -> Section,
Expand Down Expand Up @@ -2918,7 +2918,7 @@ mod tests {

fn check_eval_with_args<F>(
program: &[AssemblerEntry],
expect: Result<&[Piece<EndianSlice<LittleEndian>>]>,
expect: Result<&[Piece<EndianSlice<'_, LittleEndian>>]>,
encoding: Encoding,
object_address: Option<u64>,
initial_value: Option<u64>,
Expand Down Expand Up @@ -2967,7 +2967,7 @@ mod tests {

fn check_eval(
program: &[AssemblerEntry],
expect: Result<&[Piece<EndianSlice<LittleEndian>>]>,
expect: Result<&[Piece<EndianSlice<'_, LittleEndian>>]>,
encoding: Encoding,
) {
check_eval_with_args(program, expect, encoding, None, None, None, |_, result| {
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
Loading

0 comments on commit b921aa3

Please sign in to comment.